git: 4f4111d2c5ab - main - fusefs: delete some dead code

Alan Somers asomers at FreeBSD.org
Mon Dec 28 19:05:43 UTC 2020


The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/src/commit/?id=4f4111d2c5ab64591b9e15dab4257d8187458fd1

commit 4f4111d2c5ab64591b9e15dab4257d8187458fd1
Author:     Alan Somers <asomers at FreeBSD.org>
AuthorDate: 2020-12-24 19:21:00 +0000
Commit:     Alan Somers <asomers at FreeBSD.org>
CommitDate: 2020-12-28 19:05:35 +0000

    fusefs: delete some dead code
    
    The original fusefs GSoC project seems to have envisioned exchanging two
    types of messages with FUSE servers.  Perhaps vectored and non-vectored?
    But in practice only one type has ever been used.  Delete the other type.
    
    Reviewed by:            cem
    Differential Revision:  https://reviews.freebsd.org/D27770
---
 sys/fs/fuse/fuse_device.c | 64 ++++++++++++++++-------------------------------
 sys/fs/fuse/fuse_ipc.c    | 33 ++----------------------
 sys/fs/fuse/fuse_ipc.h    |  7 ------
 3 files changed, 24 insertions(+), 80 deletions(-)

diff --git a/sys/fs/fuse/fuse_device.c b/sys/fs/fuse/fuse_device.c
index 1698f962415f..cab5925c91de 100644
--- a/sys/fs/fuse/fuse_device.c
+++ b/sys/fs/fuse/fuse_device.c
@@ -287,9 +287,8 @@ fuse_device_read(struct cdev *dev, struct uio *uio, int ioflag)
 	int err;
 	struct fuse_data *data;
 	struct fuse_ticket *tick;
-	void *buf[] = {NULL, NULL, NULL};
-	int buflen[3];
-	int i;
+	void *buf;
+	int buflen;
 
 	SDT_PROBE2(fusefs, , device, trace, 1, "fuse device read");
 
@@ -352,46 +351,27 @@ again:
 	SDT_PROBE2(fusefs, , device, trace, 1,
 		"fuse device read message successfully");
 
-	KASSERT(tick->tk_ms_bufdata || tick->tk_ms_bufsize == 0,
-	    ("non-null buf pointer with positive size"));
-
-	switch (tick->tk_ms_type) {
-	case FT_M_FIOV:
-		buf[0] = tick->tk_ms_fiov.base;
-		buflen[0] = tick->tk_ms_fiov.len;
-		break;
-	case FT_M_BUF:
-		buf[0] = tick->tk_ms_fiov.base;
-		buflen[0] = tick->tk_ms_fiov.len;
-		buf[1] = tick->tk_ms_bufdata;
-		buflen[1] = tick->tk_ms_bufsize;
-		break;
-	default:
-		panic("unknown message type for fuse_ticket %p", tick);
-	}
+	buf = tick->tk_ms_fiov.base;
+	buflen = tick->tk_ms_fiov.len;
 
-	for (i = 0; buf[i]; i++) {
-		/*
-		 * Why not ban mercilessly stupid daemons who can't keep up
-		 * with us? (There is no much use of a partial read here...)
-		 */
-		/*
-		 * XXX note that in such cases Linux FUSE throws EIO at the
-		 * syscall invoker and stands back to the message queue. The
-		 * rationale should be made clear (and possibly adopt that
-		 * behaviour). Keeping the current scheme at least makes
-		 * fallacy as loud as possible...
-		 */
-		if (uio->uio_resid < buflen[i]) {
-			fdata_set_dead(data);
-			SDT_PROBE2(fusefs, , device, trace, 2,
-			    "daemon is stupid, kick it off...");
-			err = ENODEV;
-			break;
-		}
-		err = uiomove(buf[i], buflen[i], uio);
-		if (err)
-			break;
+	/*
+	 * Why not ban mercilessly stupid daemons who can't keep up
+	 * with us? (There is no much use of a partial read here...)
+	 */
+	/*
+	 * XXX note that in such cases Linux FUSE throws EIO at the
+	 * syscall invoker and stands back to the message queue. The
+	 * rationale should be made clear (and possibly adopt that
+	 * behaviour). Keeping the current scheme at least makes
+	 * fallacy as loud as possible...
+	 */
+	if (uio->uio_resid < buflen) {
+		fdata_set_dead(data);
+		SDT_PROBE2(fusefs, , device, trace, 2,
+		    "daemon is stupid, kick it off...");
+		err = ENODEV;
+	} else {
+		err = uiomove(buf, buflen, uio);
 	}
 
 	FUSE_ASSERT_MS_DONE(tick);
diff --git a/sys/fs/fuse/fuse_ipc.c b/sys/fs/fuse/fuse_ipc.c
index 8d82cc492b4c..776a4ecd11d7 100644
--- a/sys/fs/fuse/fuse_ipc.c
+++ b/sys/fs/fuse/fuse_ipc.c
@@ -356,11 +356,9 @@ fticket_init(void *mem, int size, int flags)
 	bzero(ftick, sizeof(struct fuse_ticket));
 
 	fiov_init(&ftick->tk_ms_fiov, sizeof(struct fuse_in_header));
-	ftick->tk_ms_type = FT_M_FIOV;
 
 	mtx_init(&ftick->tk_aw_mtx, "fuse answer delivery mutex", NULL, MTX_DEF);
 	fiov_init(&ftick->tk_aw_fiov, 0);
-	ftick->tk_aw_type = FT_A_FIOV;
 
 	return 0;
 }
@@ -395,18 +393,11 @@ fticket_refresh(struct fuse_ticket *ftick)
 	FUSE_ASSERT_AW_DONE(ftick);
 
 	fiov_refresh(&ftick->tk_ms_fiov);
-	ftick->tk_ms_bufdata = NULL;
-	ftick->tk_ms_bufsize = 0;
-	ftick->tk_ms_type = FT_M_FIOV;
 
 	bzero(&ftick->tk_aw_ohead, sizeof(struct fuse_out_header));
 
 	fiov_refresh(&ftick->tk_aw_fiov);
 	ftick->tk_aw_errno = 0;
-	ftick->tk_aw_bufdata = NULL;
-	ftick->tk_aw_bufsize = 0;
-	ftick->tk_aw_type = FT_A_FIOV;
-
 	ftick->tk_flag = 0;
 }
 
@@ -417,17 +408,9 @@ fticket_reset(struct fuse_ticket *ftick)
 	FUSE_ASSERT_MS_DONE(ftick);
 	FUSE_ASSERT_AW_DONE(ftick);
 
-	ftick->tk_ms_bufdata = NULL;
-	ftick->tk_ms_bufsize = 0;
-	ftick->tk_ms_type = FT_M_FIOV;
-
 	bzero(&ftick->tk_aw_ohead, sizeof(struct fuse_out_header));
 
 	ftick->tk_aw_errno = 0;
-	ftick->tk_aw_bufdata = NULL;
-	ftick->tk_aw_bufsize = 0;
-	ftick->tk_aw_type = FT_A_FIOV;
-
 	ftick->tk_flag = 0;
 }
 
@@ -546,20 +529,8 @@ fticket_aw_pull_uio(struct fuse_ticket *ftick, struct uio *uio)
 	size_t len = uio_resid(uio);
 
 	if (len) {
-		switch (ftick->tk_aw_type) {
-		case FT_A_FIOV:
-			fiov_adjust(fticket_resp(ftick), len);
-			err = uiomove(fticket_resp(ftick)->base, len, uio);
-			break;
-
-		case FT_A_BUF:
-			ftick->tk_aw_bufsize = len;
-			err = uiomove(ftick->tk_aw_bufdata, len, uio);
-			break;
-
-		default:
-			panic("FUSE: unknown answer type for ticket %p", ftick);
-		}
+		fiov_adjust(fticket_resp(ftick), len);
+		err = uiomove(fticket_resp(ftick)->base, len, uio);
 	}
 	return err;
 }
diff --git a/sys/fs/fuse/fuse_ipc.h b/sys/fs/fuse/fuse_ipc.h
index 980a52052218..c8a665abded7 100644
--- a/sys/fs/fuse/fuse_ipc.h
+++ b/sys/fs/fuse/fuse_ipc.h
@@ -123,17 +123,10 @@ struct fuse_ticket {
 
 	/* fields for initiating an upgoing message */
 	struct fuse_iov			tk_ms_fiov;
-	void				*tk_ms_bufdata;
-	size_t				tk_ms_bufsize;
-	enum { FT_M_FIOV, FT_M_BUF }	tk_ms_type;
 	STAILQ_ENTRY(fuse_ticket)	tk_ms_link;
 
 	/* fields for handling answers coming from userspace */
 	struct fuse_iov			tk_aw_fiov;
-	void				*tk_aw_bufdata;
-	size_t				tk_aw_bufsize;
-	enum { FT_A_FIOV, FT_A_BUF }	tk_aw_type;
-
 	struct fuse_out_header		tk_aw_ohead;
 	int				tk_aw_errno;
 	struct mtx			tk_aw_mtx;


More information about the dev-commits-src-all mailing list