linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/22] Coda updates for linux-5.1
@ 2019-03-20 16:45 Jan Harkes
  2019-03-20 16:45 ` [PATCH 01/22] uapi linux/coda.h: use __kernel_pid_t for userspace Jan Harkes
                   ` (21 more replies)
  0 siblings, 22 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

The following patch series is a collection of various fixes for Coda,
most of which were collected from linux-fsdevel or linux-kernel but
which have as yet not found their way upstream.

Arnd Bergmann (1):
  coda: stop using 'struct timespec' in user API

Colin Ian King (1):
  coda: clean up indentation, replace spaces with tab

Dan Carpenter (2):
  coda: get rid of CODA_ALLOC()
  coda: get rid of CODA_FREE()

David Howells (1):
  coda: Move internal defs out of include/linux/ [ver #2]

Fabian Frederick (6):
  coda: destroy mutex in put_super()
  coda: use SIZE() for stat
  coda: add __init to init_coda_psdev()
  coda: remove sysctl object from module when unused
  coda: remove sb test in coda_fid_to_inode()
  coda: ftoc validity check integration

Jan Harkes (6):
  coda: potential buffer overflow in coda_psdev_write()
  coda: don't try to print names that were considered too long
  uapi linux/coda_psdev.h: Move CODA_REQ_ from uapi to kernel side
    headers
  coda: change Coda's user api to use 64-bit time_t in timespec
  coda: bump module version
  coda: remove uapi/linux/coda_psdev.h

Mikko Rapeli (2):
  uapi linux/coda.h: use __kernel_pid_t for userspace
  uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel
    side headers

Sabyasachi Gupta (1):
  coda: Remove duplicate header

Sam Protsenko (1):
  coda: Fix build using bare-metal toolchain

Zhouyang Jia (1):
  coda: add error handling for fget

 Documentation/filesystems/coda.txt      | 11 ++--
 fs/coda/Makefile                        |  3 +-
 fs/coda/cache.c                         |  2 +-
 fs/coda/cnode.c                         | 17 ++++--
 fs/coda/coda_fs_i.h                     |  3 +-
 fs/coda/coda_int.h                      | 10 ++++
 fs/coda/coda_linux.c                    | 45 +++++++++-----
 fs/coda/coda_linux.h                    | 16 -----
 {include/linux => fs/coda}/coda_psdev.h | 52 ++++++++++++-----
 fs/coda/dir.c                           | 12 ++--
 fs/coda/file.c                          | 20 ++-----
 fs/coda/inode.c                         |  3 +-
 fs/coda/pioctl.c                        |  3 +-
 fs/coda/psdev.c                         | 37 +++++++-----
 fs/coda/symlink.c                       |  3 +-
 fs/coda/sysctl.c                        | 11 ----
 fs/coda/upcall.c                        | 78 +++++++++++++++++--------
 include/linux/coda.h                    |  3 +-
 include/uapi/linux/coda.h               | 29 ++++-----
 include/uapi/linux/coda_psdev.h         | 28 ---------
 20 files changed, 206 insertions(+), 180 deletions(-)
 rename {include/linux => fs/coda}/coda_psdev.h (62%)
 delete mode 100644 include/uapi/linux/coda_psdev.h

-- 
2.20.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 01/22] uapi linux/coda.h: use __kernel_pid_t for userspace
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 02/22] uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers Jan Harkes
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Mikko Rapeli

From: Mikko Rapeli <mikko.rapeli@iki.fi>

Part of a patch by Mikko Rapeli, as Arnd Bergman commented on
the original patch.

   pid_t might differ between libc and the kernel, so the kernel interface
   has to use types that the kernel defines.

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 include/uapi/linux/coda.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index 695fade33c64..ed8cb263e482 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -295,8 +295,8 @@ struct coda_statfs {
 struct coda_in_hdr {
     u_int32_t opcode;
     u_int32_t unique;	    /* Keep multiple outstanding msgs distinct */
-    pid_t pid;
-    pid_t pgid;
+    __kernel_pid_t pid;
+    __kernel_pid_t pgid;
     vuid_t uid;
 };
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 02/22] uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
  2019-03-20 16:45 ` [PATCH 01/22] uapi linux/coda.h: use __kernel_pid_t for userspace Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 03/22] coda: add error handling for fget Jan Harkes
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Mikko Rapeli

From: Mikko Rapeli <mikko.rapeli@iki.fi>

Only users of upc_req in kernel side fs/coda/psdev.c and fs/coda/upcall.c
already include linux/coda_psdev.h.

Suggested by Jan Harkes <jaharkes@cs.cmu.edu> on lkml message
<20150531111913.GA23377@cs.cmu.edu>.

Fixes these include/uapi/linux/coda_psdev.h compilation errors in userspace:

./linux/coda_psdev.h:12:19: error: field ‘uc_chain’ has incomplete type
  struct list_head    uc_chain;
                   ^
./linux/coda_psdev.h:13:2: error: unknown type name ‘caddr_t’
  caddr_t             uc_data;
  ^
./linux/coda_psdev.h:14:2: error: unknown type name ‘u_short’
  u_short             uc_flags;
  ^
./linux/coda_psdev.h:15:2: error: unknown type name ‘u_short’
  u_short             uc_inSize;  /* Size is at most 5000 bytes */
  ^
./linux/coda_psdev.h:16:2: error: unknown type name ‘u_short’
  u_short             uc_outSize;
  ^
./linux/coda_psdev.h:17:2: error: unknown type name ‘u_short’
  u_short             uc_opcode;  /* copied from data to save lookup */
  ^
./linux/coda_psdev.h:19:2: error: unknown type name ‘wait_queue_head_t’
  wait_queue_head_t   uc_sleep;   /* process' wait queue */
  ^

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
Cc: coda@cs.cmu.edu
Cc: Jan Harkes <jaharkes@cs.cmu.edu>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 include/linux/coda_psdev.h      | 11 +++++++++++
 include/uapi/linux/coda_psdev.h | 13 -------------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
index 15170954aa2b..57d2b2faf6a3 100644
--- a/include/linux/coda_psdev.h
+++ b/include/linux/coda_psdev.h
@@ -19,6 +19,17 @@ struct venus_comm {
 	struct mutex	    vc_mutex;
 };
 
+/* messages between coda filesystem in kernel and Venus */
+struct upc_req {
+	struct list_head	uc_chain;
+	caddr_t			uc_data;
+	u_short			uc_flags;
+	u_short			uc_inSize;  /* Size is at most 5000 bytes */
+	u_short			uc_outSize;
+	u_short			uc_opcode;  /* copied from data to save lookup */
+	int			uc_unique;
+	wait_queue_head_t	uc_sleep;   /* process' wait queue */
+};
 
 static inline struct venus_comm *coda_vcp(struct super_block *sb)
 {
diff --git a/include/uapi/linux/coda_psdev.h b/include/uapi/linux/coda_psdev.h
index aa6623efd2dd..d50d51a57fe4 100644
--- a/include/uapi/linux/coda_psdev.h
+++ b/include/uapi/linux/coda_psdev.h
@@ -7,19 +7,6 @@
 #define CODA_PSDEV_MAJOR 67
 #define MAX_CODADEVS  5	   /* how many do we allow */
 
-
-/* messages between coda filesystem in kernel and Venus */
-struct upc_req {
-	struct list_head    uc_chain;
-	caddr_t	            uc_data;
-	u_short	            uc_flags;
-	u_short             uc_inSize;  /* Size is at most 5000 bytes */
-	u_short	            uc_outSize;
-	u_short	            uc_opcode;  /* copied from data to save lookup */
-	int		    uc_unique;
-	wait_queue_head_t   uc_sleep;   /* process' wait queue */
-};
-
 #define CODA_REQ_ASYNC  0x1
 #define CODA_REQ_READ   0x2
 #define CODA_REQ_WRITE  0x4
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 03/22] coda: add error handling for fget
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
  2019-03-20 16:45 ` [PATCH 01/22] uapi linux/coda.h: use __kernel_pid_t for userspace Jan Harkes
  2019-03-20 16:45 ` [PATCH 02/22] uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 04/22] coda: potential buffer overflow in coda_psdev_write() Jan Harkes
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Zhouyang Jia

From: Zhouyang Jia <jiazhouyang09@gmail.com>

When fget fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling fget.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index c5234c21b539..55824cba3245 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -187,8 +187,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 	if (req->uc_opcode == CODA_OPEN_BY_FD) {
 		struct coda_open_by_fd_out *outp =
 			(struct coda_open_by_fd_out *)req->uc_data;
-		if (!outp->oh.result)
+		if (!outp->oh.result) {
 			outp->fh = fget(outp->fd);
+			if (!outp->fh)
+				return -EBADF;
+		}
 	}
 
         wake_up(&req->uc_sleep);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 04/22] coda: potential buffer overflow in coda_psdev_write()
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (2 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 03/22] coda: add error handling for fget Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 05/22] coda: Fix build using bare-metal toolchain Jan Harkes
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Dan Carpenter

Add checks to make sure the downcall message we got from the Coda cache
manager is large enough to contain the data it is supposed to have.
i.e. when we get a CODA_ZAPDIR we can access &out->coda_zapdir.CodaFid.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c            |  8 ++++++--
 fs/coda/upcall.c           | 34 +++++++++++++++++++++++++++++++++-
 include/linux/coda_psdev.h |  3 ++-
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 55824cba3245..623be0cbcba5 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -105,8 +105,12 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 	ssize_t retval = 0, count = 0;
 	int error;
 
+	/* make sure there is enough to copy out the (opcode, unique) values */
+	if (nbytes < (2 * sizeof(u_int32_t)))
+		return -EINVAL;
+
         /* Peek at the opcode, uniquefier */
-	if (copy_from_user(&hdr, buf, 2 * sizeof(u_long)))
+	if (copy_from_user(&hdr, buf, 2 * sizeof(u_int32_t)))
 	        return -EFAULT;
 
         if (DOWNCALL(hdr.opcode)) {
@@ -132,7 +136,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 		}
 
 		/* what downcall errors does Venus handle ? */
-		error = coda_downcall(vcp, hdr.opcode, dcbuf);
+		error = coda_downcall(vcp, hdr.opcode, dcbuf, nbytes);
 
 		CODA_FREE(dcbuf, nbytes);
 		if (error) {
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index 1175a1722411..cf1e662681a5 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -804,12 +804,44 @@ static int coda_upcall(struct venus_comm *vcp,
  *
  * CODA_REPLACE -- replace one CodaFid with another throughout the name cache */
 
-int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out)
+int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out,
+		  size_t nbytes)
 {
 	struct inode *inode = NULL;
 	struct CodaFid *fid = NULL, *newfid;
 	struct super_block *sb;
 
+	/*
+	 * Make sure we have received enough data from the cache
+	 * manager to populate the necessary fields in the buffer
+	 */
+	switch (opcode) {
+	case CODA_PURGEUSER:
+		if (nbytes < sizeof(struct coda_purgeuser_out))
+			return -EINVAL;
+		break;
+
+	case CODA_ZAPDIR:
+		if (nbytes < sizeof(struct coda_zapdir_out))
+			return -EINVAL;
+		break;
+
+	case CODA_ZAPFILE:
+		if (nbytes < sizeof(struct coda_zapfile_out))
+			return -EINVAL;
+		break;
+
+	case CODA_PURGEFID:
+		if (nbytes < sizeof(struct coda_purgefid_out))
+			return -EINVAL;
+		break;
+
+	case CODA_REPLACE:
+		if (nbytes < sizeof(struct coda_replace_out))
+			return -EINVAL;
+		break;
+	}
+
 	/* Handle invalidation requests. */
 	mutex_lock(&vcp->vc_mutex);
 	sb = vcp->vc_sb;
diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
index 57d2b2faf6a3..d1672fd5e638 100644
--- a/include/linux/coda_psdev.h
+++ b/include/linux/coda_psdev.h
@@ -71,7 +71,8 @@ int venus_symlink(struct super_block *sb, struct CodaFid *fid,
 int venus_access(struct super_block *sb, struct CodaFid *fid, int mask);
 int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
 		 unsigned int cmd, struct PioctlData *data);
-int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out);
+int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out,
+		  size_t nbytes);
 int venus_fsync(struct super_block *sb, struct CodaFid *fid);
 int venus_statfs(struct dentry *dentry, struct kstatfs *sfs);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 05/22] coda: Fix build using bare-metal toolchain
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (3 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 04/22] coda: potential buffer overflow in coda_psdev_write() Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 06/22] coda: don't try to print names that were considered too long Jan Harkes
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Sam Protsenko

From: Sam Protsenko <semen.protsenko@linaro.org>

The kernel is self-contained project and can be built with bare-metal
toolchain. But bare-metal toolchain doesn't define __linux__. Because of
this u_quad_t type is not defined when using bare-metal toolchain and
codafs build fails. This patch fixes it by defining u_quad_t type
unconditionally.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 include/linux/coda.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/coda.h b/include/linux/coda.h
index d30209b9cef8..0ca0c83fdb1c 100644
--- a/include/linux/coda.h
+++ b/include/linux/coda.h
@@ -58,8 +58,7 @@ Mellon the rights to redistribute these changes without encumbrance.
 #ifndef _CODA_HEADER_
 #define _CODA_HEADER_
 
-#if defined(__linux__)
 typedef unsigned long long u_quad_t;
-#endif
+
 #include <uapi/linux/coda.h>
 #endif 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 06/22] coda: don't try to print names that were considered too long
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (4 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 05/22] coda: Fix build using bare-metal toolchain Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 07/22] uapi linux/coda_psdev.h: Move CODA_REQ_ from uapi to kernel side headers Jan Harkes
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

Probably safer to just show the unexpected length and debug it from
the userspace side.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 00876ddadb43..7e103eb8ffcd 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -47,8 +47,8 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig
 	int type = 0;
 
 	if (length > CODA_MAXNAMLEN) {
-		pr_err("name too long: lookup, %s (%*s)\n",
-		       coda_i2s(dir), (int)length, name);
+		pr_err("name too long: lookup, %s %zu\n",
+		       coda_i2s(dir), length);
 		return ERR_PTR(-ENAMETOOLONG);
 	}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 07/22] uapi linux/coda_psdev.h: Move CODA_REQ_ from uapi to kernel side headers
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (5 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 06/22] coda: don't try to print names that were considered too long Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 08/22] coda: clean up indentation, replace spaces with tab Jan Harkes
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

These constants only used internally and not exposed to userspace.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 include/linux/coda_psdev.h      | 5 +++++
 include/uapi/linux/coda_psdev.h | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
index d1672fd5e638..9487f792770c 100644
--- a/include/linux/coda_psdev.h
+++ b/include/linux/coda_psdev.h
@@ -31,6 +31,11 @@ struct upc_req {
 	wait_queue_head_t	uc_sleep;   /* process' wait queue */
 };
 
+#define CODA_REQ_ASYNC  0x1
+#define CODA_REQ_READ   0x2
+#define CODA_REQ_WRITE  0x4
+#define CODA_REQ_ABORT  0x8
+
 static inline struct venus_comm *coda_vcp(struct super_block *sb)
 {
 	return (struct venus_comm *)((sb)->s_fs_info);
diff --git a/include/uapi/linux/coda_psdev.h b/include/uapi/linux/coda_psdev.h
index d50d51a57fe4..3dacb7fad66a 100644
--- a/include/uapi/linux/coda_psdev.h
+++ b/include/uapi/linux/coda_psdev.h
@@ -7,9 +7,4 @@
 #define CODA_PSDEV_MAJOR 67
 #define MAX_CODADEVS  5	   /* how many do we allow */
 
-#define CODA_REQ_ASYNC  0x1
-#define CODA_REQ_READ   0x2
-#define CODA_REQ_WRITE  0x4
-#define CODA_REQ_ABORT  0x8
-
 #endif /* _UAPI__CODA_PSDEV_H */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 08/22] coda: clean up indentation, replace spaces with tab
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (6 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 07/22] uapi linux/coda_psdev.h: Move CODA_REQ_ from uapi to kernel side headers Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 09/22] coda: stop using 'struct timespec' in user API Jan Harkes
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Colin Ian King

From: Colin Ian King <colin.king@canonical.com>

Trivial fix to clean up indentation, replace spaces with tab

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 623be0cbcba5..dde6c6a767c2 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -365,7 +365,7 @@ static int init_coda_psdev(void)
 	if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) {
 		pr_err("%s: unable to get major %d\n",
 		       __func__, CODA_PSDEV_MAJOR);
-              return -EIO;
+		return -EIO;
 	}
 	coda_psdev_class = class_create(THIS_MODULE, "coda");
 	if (IS_ERR(coda_psdev_class)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 09/22] coda: stop using 'struct timespec' in user API
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (7 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 08/22] coda: clean up indentation, replace spaces with tab Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 10/22] coda: Remove duplicate header Jan Harkes
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Arnd Bergmann

From: Arnd Bergmann <arnd@arndb.de>

We exchange file timestamps with user space using psdev device
read/write operations with a fixed but architecture specific binary
layout.

On 32-bit systems, this uses a 'timespec' structure that is defined by
the C library to contain two 32-bit values for seconds and nanoseconds.
As we get ready for the year 2038 overflow of the 32-bit signed seconds,
the kernel now uses 64-bit timestamps internally, and user space will
do the same change by changing the 'timespec' definition in the future.

Unfortunately, this breaks the layout of the coda_vattr structure, so
we need to redefine that in terms of something that does not change.
I'm introducing a new 'struct vtimespec' structure here that keeps
the existing layout, and the same change has to be done in the coda
user space copy of linux/coda.h before anyone can use that on a 32-bit
architecture with 64-bit time_t.

An open question is what should happen to actual times past y2038,
as they are now truncated to the last valid date when sent to user
space, and interpreted as pre-1970 times when a timestamp with the
MSB set is read back into the kernel. Alternatively, we could
change the new timespec64_to_coda()/coda_to_timespec64() functions
to use a different interpretation and extend the available range
further to the future by disallowing past timestamps. This would
require more changes in the user space side though.

Acked-by: Jan Harkes <jaharkes@cs.cmu.edu>
Link: https://patchwork.kernel.org/patch/10474735/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 Documentation/filesystems/coda.txt | 11 ++++---
 fs/coda/coda_linux.c               | 50 +++++++++++++++++++++++-------
 include/uapi/linux/coda.h          | 20 ++++++++++--
 3 files changed, 62 insertions(+), 19 deletions(-)

diff --git a/Documentation/filesystems/coda.txt b/Documentation/filesystems/coda.txt
index 61311356025d..ea5969068895 100644
--- a/Documentation/filesystems/coda.txt
+++ b/Documentation/filesystems/coda.txt
@@ -481,7 +481,10 @@ kernel support.
 
 
 
-
+  struct vtimespec {
+          long            tv_sec;         /* seconds */
+          long            tv_nsec;        /* nanoseconds */
+  };
 
   struct coda_vattr {
           enum coda_vtype va_type;        /* vnode type (for create) */
@@ -493,9 +496,9 @@ kernel support.
           long            va_fileid;      /* file id */
           u_quad_t        va_size;        /* file size in bytes */
           long            va_blocksize;   /* blocksize preferred for i/o */
-          struct timespec va_atime;       /* time of last access */
-          struct timespec va_mtime;       /* time of last modification */
-          struct timespec va_ctime;       /* time file changed */
+          struct vtimespec va_atime;      /* time of last access */
+          struct vtimespec va_mtime;      /* time of last modification */
+          struct vtimespec va_ctime;      /* time file changed */
           u_long          va_gen;         /* generation number of file */
           u_long          va_flags;       /* flags defined for file */
           dev_t           va_rdev;        /* device special file represents */
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index f3d543dd9a98..8addcd166908 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -66,6 +66,32 @@ unsigned short coda_flags_to_cflags(unsigned short flags)
 	return coda_flags;
 }
 
+static struct timespec64 coda_to_timespec64(struct vtimespec ts)
+{
+	/*
+	 * We interpret incoming timestamps as 'signed' to match traditional
+	 * usage and support pre-1970 timestamps, but this breaks in y2038
+	 * on 32-bit machines.
+	 */
+	struct timespec64 ts64 = {
+		.tv_sec = ts.tv_sec,
+		.tv_nsec = ts.tv_nsec,
+	};
+
+	return ts64;
+}
+
+static struct vtimespec timespec64_to_coda(struct timespec64 ts64)
+{
+	/* clamp the timestamps to the maximum range rather than wrapping */
+	struct vtimespec ts = {
+		.tv_sec = lower_32_bits(clamp_t(time64_t, ts64.tv_sec,
+						LONG_MIN, LONG_MAX)),
+		.tv_nsec = ts64.tv_nsec,
+	};
+
+	return ts;
+}
 
 /* utility functions below */
 void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
@@ -105,11 +131,11 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
 	if (attr->va_size != -1)
 		inode->i_blocks = (attr->va_size + 511) >> 9;
 	if (attr->va_atime.tv_sec != -1) 
-		inode->i_atime = timespec_to_timespec64(attr->va_atime);
+		inode->i_atime = coda_to_timespec64(attr->va_atime);
 	if (attr->va_mtime.tv_sec != -1)
-		inode->i_mtime = timespec_to_timespec64(attr->va_mtime);
+		inode->i_mtime = coda_to_timespec64(attr->va_mtime);
         if (attr->va_ctime.tv_sec != -1)
-		inode->i_ctime = timespec_to_timespec64(attr->va_ctime);
+		inode->i_ctime = coda_to_timespec64(attr->va_ctime);
 }
 
 
@@ -130,12 +156,12 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr)
         vattr->va_uid = (vuid_t) -1; 
         vattr->va_gid = (vgid_t) -1;
         vattr->va_size = (off_t) -1;
-	vattr->va_atime.tv_sec = (time_t) -1;
-	vattr->va_atime.tv_nsec =  (time_t) -1;
-        vattr->va_mtime.tv_sec = (time_t) -1;
-        vattr->va_mtime.tv_nsec = (time_t) -1;
-	vattr->va_ctime.tv_sec = (time_t) -1;
-	vattr->va_ctime.tv_nsec = (time_t) -1;
+	vattr->va_atime.tv_sec = (long) -1;
+	vattr->va_atime.tv_nsec = (long) -1;
+	vattr->va_mtime.tv_sec = (long) -1;
+	vattr->va_mtime.tv_nsec = (long) -1;
+	vattr->va_ctime.tv_sec = (long) -1;
+	vattr->va_ctime.tv_nsec = (long) -1;
         vattr->va_type = C_VNON;
 	vattr->va_fileid = -1;
 	vattr->va_gen = -1;
@@ -175,13 +201,13 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr)
                 vattr->va_size = iattr->ia_size;
 	}
         if ( valid & ATTR_ATIME ) {
-		vattr->va_atime = timespec64_to_timespec(iattr->ia_atime);
+		vattr->va_atime = timespec64_to_coda(iattr->ia_atime);
 	}
         if ( valid & ATTR_MTIME ) {
-		vattr->va_mtime = timespec64_to_timespec(iattr->ia_mtime);
+		vattr->va_mtime = timespec64_to_coda(iattr->ia_mtime);
 	}
         if ( valid & ATTR_CTIME ) {
-		vattr->va_ctime = timespec64_to_timespec(iattr->ia_ctime);
+		vattr->va_ctime = timespec64_to_coda(iattr->ia_ctime);
 	}
 }
 
diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index ed8cb263e482..fc5f7874208a 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -211,6 +211,20 @@ struct CodaFid {
  */
 enum coda_vtype	{ C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
 
+#ifdef __linux__
+/*
+ * This matches the traditional Linux 'timespec' structure binary layout,
+ * before using 64-bit time_t everywhere. Overflows in y2038 on 32-bit
+ * architectures.
+ */
+struct vtimespec {
+	long		tv_sec;		/* seconds */
+	long		tv_nsec;	/* nanoseconds */
+};
+#else
+#define vtimespec timespec
+#endif
+
 struct coda_vattr {
 	long     	va_type;	/* vnode type (for create) */
 	u_short		va_mode;	/* files access mode and type */
@@ -220,9 +234,9 @@ struct coda_vattr {
 	long		va_fileid;	/* file id */
 	u_quad_t	va_size;	/* file size in bytes */
 	long		va_blocksize;	/* blocksize preferred for i/o */
-	struct timespec	va_atime;	/* time of last access */
-	struct timespec	va_mtime;	/* time of last modification */
-	struct timespec	va_ctime;	/* time file changed */
+	struct vtimespec va_atime;	/* time of last access */
+	struct vtimespec va_mtime;	/* time of last modification */
+	struct vtimespec va_ctime;	/* time file changed */
 	u_long		va_gen;		/* generation number of file */
 	u_long		va_flags;	/* flags defined for file */
 	cdev_t	        va_rdev;	/* device special file represents */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 10/22] coda: Remove duplicate header
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (8 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 09/22] coda: stop using 'struct timespec' in user API Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 11/22] coda: change Coda's user api to use 64-bit time_t in timespec Jan Harkes
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Sabyasachi Gupta

From: Sabyasachi Gupta <sabyasachi.linux@gmail.com>

Remove linux/poll.h which is included more than once

Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index dde6c6a767c2..7e9ee614ec57 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -39,7 +39,6 @@
 #include <linux/device.h>
 #include <linux/pid_namespace.h>
 #include <asm/io.h>
-#include <linux/poll.h>
 #include <linux/uaccess.h>
 
 #include <linux/coda.h>
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 11/22] coda: change Coda's user api to use 64-bit time_t in timespec
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (9 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 10/22] coda: Remove duplicate header Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 12/22] coda: get rid of CODA_ALLOC() Jan Harkes
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

Move the 32-bit time_t problems to userspace.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 Documentation/filesystems/coda.txt | 10 ++++-----
 fs/coda/coda_linux.c               | 21 +++++++------------
 include/uapi/linux/coda.h          | 33 +++++++-----------------------
 3 files changed, 19 insertions(+), 45 deletions(-)

diff --git a/Documentation/filesystems/coda.txt b/Documentation/filesystems/coda.txt
index ea5969068895..545262c167c3 100644
--- a/Documentation/filesystems/coda.txt
+++ b/Documentation/filesystems/coda.txt
@@ -481,8 +481,8 @@ kernel support.
 
 
 
-  struct vtimespec {
-          long            tv_sec;         /* seconds */
+  struct coda_timespec {
+          int64_t         tv_sec;         /* seconds */
           long            tv_nsec;        /* nanoseconds */
   };
 
@@ -496,9 +496,9 @@ kernel support.
           long            va_fileid;      /* file id */
           u_quad_t        va_size;        /* file size in bytes */
           long            va_blocksize;   /* blocksize preferred for i/o */
-          struct vtimespec va_atime;      /* time of last access */
-          struct vtimespec va_mtime;      /* time of last modification */
-          struct vtimespec va_ctime;      /* time file changed */
+          struct coda_timespec va_atime;  /* time of last access */
+          struct coda_timespec va_mtime;  /* time of last modification */
+          struct coda_timespec va_ctime;  /* time file changed */
           u_long          va_gen;         /* generation number of file */
           u_long          va_flags;       /* flags defined for file */
           dev_t           va_rdev;        /* device special file represents */
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index 8addcd166908..e4b5f02f0dd4 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -66,13 +66,8 @@ unsigned short coda_flags_to_cflags(unsigned short flags)
 	return coda_flags;
 }
 
-static struct timespec64 coda_to_timespec64(struct vtimespec ts)
+static struct timespec64 coda_to_timespec64(struct coda_timespec ts)
 {
-	/*
-	 * We interpret incoming timestamps as 'signed' to match traditional
-	 * usage and support pre-1970 timestamps, but this breaks in y2038
-	 * on 32-bit machines.
-	 */
 	struct timespec64 ts64 = {
 		.tv_sec = ts.tv_sec,
 		.tv_nsec = ts.tv_nsec,
@@ -81,12 +76,10 @@ static struct timespec64 coda_to_timespec64(struct vtimespec ts)
 	return ts64;
 }
 
-static struct vtimespec timespec64_to_coda(struct timespec64 ts64)
+static struct coda_timespec timespec64_to_coda(struct timespec64 ts64)
 {
-	/* clamp the timestamps to the maximum range rather than wrapping */
-	struct vtimespec ts = {
-		.tv_sec = lower_32_bits(clamp_t(time64_t, ts64.tv_sec,
-						LONG_MIN, LONG_MAX)),
+	struct coda_timespec ts = {
+		.tv_sec = ts64.tv_sec,
 		.tv_nsec = ts64.tv_nsec,
 	};
 
@@ -156,11 +149,11 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr)
         vattr->va_uid = (vuid_t) -1; 
         vattr->va_gid = (vgid_t) -1;
         vattr->va_size = (off_t) -1;
-	vattr->va_atime.tv_sec = (long) -1;
+	vattr->va_atime.tv_sec = (int64_t) -1;
 	vattr->va_atime.tv_nsec = (long) -1;
-	vattr->va_mtime.tv_sec = (long) -1;
+	vattr->va_mtime.tv_sec = (int64_t) -1;
 	vattr->va_mtime.tv_nsec = (long) -1;
-	vattr->va_ctime.tv_sec = (long) -1;
+	vattr->va_ctime.tv_sec = (int64_t) -1;
 	vattr->va_ctime.tv_nsec = (long) -1;
         vattr->va_type = C_VNON;
 	vattr->va_fileid = -1;
diff --git a/include/uapi/linux/coda.h b/include/uapi/linux/coda.h
index fc5f7874208a..5dba636b6e11 100644
--- a/include/uapi/linux/coda.h
+++ b/include/uapi/linux/coda.h
@@ -86,10 +86,6 @@ typedef unsigned long long u_quad_t;
 
 #define inline
 
-struct timespec {
-        long       ts_sec;
-        long       ts_nsec;
-};
 #else  /* DJGPP but not KERNEL */
 #include <sys/time.h>
 typedef unsigned long long u_quad_t;
@@ -110,13 +106,6 @@ typedef unsigned long long u_quad_t;
 #define cdev_t dev_t
 #endif
 
-#ifdef __CYGWIN32__
-struct timespec {
-        time_t  tv_sec;         /* seconds */
-        long    tv_nsec;        /* nanoseconds */
-};
-#endif
-
 #ifndef __BIT_TYPES_DEFINED__
 #define __BIT_TYPES_DEFINED__
 typedef signed char	      int8_t;
@@ -211,19 +200,10 @@ struct CodaFid {
  */
 enum coda_vtype	{ C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
 
-#ifdef __linux__
-/*
- * This matches the traditional Linux 'timespec' structure binary layout,
- * before using 64-bit time_t everywhere. Overflows in y2038 on 32-bit
- * architectures.
- */
-struct vtimespec {
-	long		tv_sec;		/* seconds */
+struct coda_timespec {
+	int64_t		tv_sec;		/* seconds */
 	long		tv_nsec;	/* nanoseconds */
 };
-#else
-#define vtimespec timespec
-#endif
 
 struct coda_vattr {
 	long     	va_type;	/* vnode type (for create) */
@@ -234,9 +214,9 @@ struct coda_vattr {
 	long		va_fileid;	/* file id */
 	u_quad_t	va_size;	/* file size in bytes */
 	long		va_blocksize;	/* blocksize preferred for i/o */
-	struct vtimespec va_atime;	/* time of last access */
-	struct vtimespec va_mtime;	/* time of last modification */
-	struct vtimespec va_ctime;	/* time file changed */
+	struct coda_timespec va_atime;	/* time of last access */
+	struct coda_timespec va_mtime;	/* time of last modification */
+	struct coda_timespec va_ctime;	/* time file changed */
 	u_long		va_gen;		/* generation number of file */
 	u_long		va_flags;	/* flags defined for file */
 	cdev_t	        va_rdev;	/* device special file represents */
@@ -301,7 +281,8 @@ struct coda_statfs {
 
 #define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
 
-#define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
+//      CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
+#define CODA_KERNEL_VERSION 4 /* 64-bit timespec */
 
 /*
  *        Venus <-> Coda  RPC arguments
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 12/22] coda: get rid of CODA_ALLOC()
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (10 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 11/22] coda: change Coda's user api to use 64-bit time_t in timespec Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 13/22] coda: get rid of CODA_FREE() Jan Harkes
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Dan Carpenter

From: Dan Carpenter <dan.carpenter@oracle.com>

These days we have kvzalloc() so we can delete CODA_ALLOC().

I made a couple related changes in coda_psdev_write().  First, I
added some error handling to avoid a NULL dereference if the allocation
failed.  Second, I used kvmalloc() instead of kvzalloc() because we
copy over the memory on the next line so there is no need to zero it
first.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/coda_linux.h | 10 ----------
 fs/coda/psdev.c      |  6 +++++-
 fs/coda/upcall.c     |  4 ++--
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index 126155cadfa9..1ea9521e79d7 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -63,16 +63,6 @@ unsigned short coda_flags_to_cflags(unsigned short);
 void coda_sysctl_init(void);
 void coda_sysctl_clean(void);
 
-#define CODA_ALLOC(ptr, cast, size) do { \
-    if (size < PAGE_SIZE) \
-        ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
-    else \
-        ptr = (cast)vzalloc((unsigned long) size); \
-    if (!ptr) \
-	pr_warn("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
-} while (0)
-
-
 #define CODA_FREE(ptr, size) kvfree((ptr))
 
 /* inode to cnode access functions */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 7e9ee614ec57..e90ac440fa29 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -127,7 +127,11 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 				hdr.opcode, hdr.unique);
 		        nbytes = size;
 		}
-		CODA_ALLOC(dcbuf, union outputArgs *, nbytes);
+		dcbuf = kvmalloc(nbytes, GFP_KERNEL);
+		if (!dcbuf) {
+			retval = -ENOMEM;
+			goto out;
+		}
 		if (copy_from_user(dcbuf, buf, nbytes)) {
 			CODA_FREE(dcbuf, nbytes);
 			retval = -EFAULT;
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index cf1e662681a5..b6ac5fc98189 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -46,7 +46,7 @@ static void *alloc_upcall(int opcode, int size)
 {
 	union inputArgs *inp;
 
-	CODA_ALLOC(inp, union inputArgs *, size);
+	inp = kvzalloc(size, GFP_KERNEL);
         if (!inp)
 		return ERR_PTR(-ENOMEM);
 
@@ -743,7 +743,7 @@ static int coda_upcall(struct venus_comm *vcp,
 	sig_req = kmalloc(sizeof(struct upc_req), GFP_KERNEL);
 	if (!sig_req) goto exit;
 
-	CODA_ALLOC((sig_req->uc_data), char *, sizeof(struct coda_in_hdr));
+	sig_req->uc_data = kvzalloc(sizeof(struct coda_in_hdr), GFP_KERNEL);
 	if (!sig_req->uc_data) {
 		kfree(sig_req);
 		goto exit;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 13/22] coda: get rid of CODA_FREE()
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (11 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 12/22] coda: get rid of CODA_ALLOC() Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 14/22] coda: bump module version Jan Harkes
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Dan Carpenter

From: Dan Carpenter <dan.carpenter@oracle.com>

The CODA_FREE() macro just calls kvfree().  We can call that directly
instead.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/coda_linux.h |  2 --
 fs/coda/psdev.c      |  8 ++++----
 fs/coda/upcall.c     | 36 ++++++++++++++++++------------------
 3 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index 1ea9521e79d7..517a363245c9 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -63,8 +63,6 @@ unsigned short coda_flags_to_cflags(unsigned short);
 void coda_sysctl_init(void);
 void coda_sysctl_clean(void);
 
-#define CODA_FREE(ptr, size) kvfree((ptr))
-
 /* inode to cnode access functions */
 
 static inline struct coda_inode_info *ITOC(struct inode *inode)
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index e90ac440fa29..4c8d968031bb 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -133,7 +133,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 			goto out;
 		}
 		if (copy_from_user(dcbuf, buf, nbytes)) {
-			CODA_FREE(dcbuf, nbytes);
+			kvfree(dcbuf);
 			retval = -EFAULT;
 			goto out;
 		}
@@ -141,7 +141,7 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 		/* what downcall errors does Venus handle ? */
 		error = coda_downcall(vcp, hdr.opcode, dcbuf, nbytes);
 
-		CODA_FREE(dcbuf, nbytes);
+		kvfree(dcbuf);
 		if (error) {
 			pr_warn("%s: coda_downcall error: %d\n",
 				__func__, error);
@@ -267,7 +267,7 @@ static ssize_t coda_psdev_read(struct file * file, char __user * buf,
 		goto out;
 	}
 
-	CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr));
+	kvfree(req->uc_data);
 	kfree(req);
 out:
 	mutex_unlock(&vcp->vc_mutex);
@@ -329,7 +329,7 @@ static int coda_psdev_release(struct inode * inode, struct file * file)
 
 		/* Async requests need to be freed here */
 		if (req->uc_flags & CODA_REQ_ASYNC) {
-			CODA_FREE(req->uc_data, sizeof(struct coda_in_hdr));
+			kvfree(req->uc_data);
 			kfree(req);
 			continue;
 		}
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index b6ac5fc98189..1e2f50722107 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -85,7 +85,7 @@ int venus_rootfid(struct super_block *sb, struct CodaFid *fidp)
 	if (!error)
 		*fidp = outp->coda_root.VFid;
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -104,7 +104,7 @@ int venus_getattr(struct super_block *sb, struct CodaFid *fid,
 	if (!error)
 		*attr = outp->coda_getattr.attr;
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
@@ -123,7 +123,7 @@ int venus_setattr(struct super_block *sb, struct CodaFid *fid,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-        CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
@@ -153,7 +153,7 @@ int venus_lookup(struct super_block *sb, struct CodaFid *fid,
 		*type = outp->coda_lookup.vtype;
 	}
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -173,7 +173,7 @@ int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
@@ -194,7 +194,7 @@ int venus_open(struct super_block *sb, struct CodaFid *fid,
 	if (!error)
 		*fh = outp->coda_open_by_fd.fh;
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }	
 
@@ -224,7 +224,7 @@ int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid,
 		*newfid = outp->coda_mkdir.VFid;
 	}
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;        
 }
 
@@ -262,7 +262,7 @@ int venus_rename(struct super_block *sb, struct CodaFid *old_fid,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -295,7 +295,7 @@ int venus_create(struct super_block *sb, struct CodaFid *dirfid,
 		*newfid = outp->coda_create.VFid;
 	}
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;        
 }
 
@@ -318,7 +318,7 @@ int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -340,7 +340,7 @@ int venus_remove(struct super_block *sb, struct CodaFid *dirfid,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -370,7 +370,7 @@ int venus_readlink(struct super_block *sb, struct CodaFid *fid,
 		*(buffer + retlen) = '\0';
 	}
 
-        CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
@@ -398,7 +398,7 @@ int venus_link(struct super_block *sb, struct CodaFid *fid,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
@@ -433,7 +433,7 @@ int venus_symlink(struct super_block *sb, struct CodaFid *fid,
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
@@ -449,7 +449,7 @@ int venus_fsync(struct super_block *sb, struct CodaFid *fid)
 	inp->coda_fsync.VFid = *fid;
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -467,7 +467,7 @@ int venus_access(struct super_block *sb, struct CodaFid *fid, int mask)
 
 	error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
 
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -543,7 +543,7 @@ int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
 	}
 
  exit:
-	CODA_FREE(inp, insize);
+	kvfree(inp);
 	return error;
 }
 
@@ -565,7 +565,7 @@ int venus_statfs(struct dentry *dentry, struct kstatfs *sfs)
 		sfs->f_ffree  = outp->coda_statfs.stat.f_ffree;
 	}
 
-        CODA_FREE(inp, insize);
+	kvfree(inp);
         return error;
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 14/22] coda: bump module version
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (12 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 13/22] coda: get rid of CODA_FREE() Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 15/22] coda: Move internal defs out of include/linux/ [ver #2] Jan Harkes
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

The out of tree module version had been bumped several times already,
but we haven't kept this in-tree one in sync, partly because most
changes go from here to the out-of-tree copy.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 4c8d968031bb..67092f069b32 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -393,7 +393,7 @@ MODULE_AUTHOR("Jan Harkes, Peter J. Braam");
 MODULE_DESCRIPTION("Coda Distributed File System VFS interface");
 MODULE_ALIAS_CHARDEV_MAJOR(CODA_PSDEV_MAJOR);
 MODULE_LICENSE("GPL");
-MODULE_VERSION("6.6");
+MODULE_VERSION("6.11");
 
 static int __init init_coda(void)
 {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 15/22] coda: Move internal defs out of include/linux/ [ver #2]
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (13 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 14/22] coda: bump module version Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 16/22] coda: remove uapi/linux/coda_psdev.h Jan Harkes
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, David Howells

From: David Howells <dhowells@redhat.com>

Move include/linux/coda_psdev.h to fs/coda/ as there's nothing else that
uses it.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Yann Droneaud <ydroneaud@opteya.com>
cc: Jan Harkes <jaharkes@cs.cmu.edu>
cc: coda@cs.cmu.edu
cc: codalist@coda.cs.cmu.edu
cc: linux-fsdevel@vger.kernel.org
Link: https://patchwork.kernel.org/patch/10590257/
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/cache.c                         |  2 +-
 fs/coda/cnode.c                         |  2 +-
 fs/coda/coda_linux.c                    |  2 +-
 {include/linux => fs/coda}/coda_psdev.h | 50 ++++++++++++-------------
 fs/coda/dir.c                           |  2 +-
 fs/coda/file.c                          |  3 +-
 fs/coda/inode.c                         |  2 +-
 fs/coda/pioctl.c                        |  3 +-
 fs/coda/psdev.c                         |  3 +-
 fs/coda/symlink.c                       |  3 +-
 fs/coda/upcall.c                        |  2 +-
 11 files changed, 35 insertions(+), 39 deletions(-)
 rename {include/linux => fs/coda}/coda_psdev.h (79%)

diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index 201fc08a8b4f..3b8c4513118f 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -21,7 +21,7 @@
 #include <linux/spinlock.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
+#include "coda_psdev.h"
 #include "coda_linux.h"
 #include "coda_cache.h"
 
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 845b5a66952a..2e5badf67f98 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -8,8 +8,8 @@
 #include <linux/time.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
 #include <linux/pagemap.h>
+#include "coda_psdev.h"
 #include "coda_linux.h"
 
 static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2)
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index e4b5f02f0dd4..2e1a5a192074 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -18,7 +18,7 @@
 #include <linux/string.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
+#include "coda_psdev.h"
 #include "coda_linux.h"
 
 /* initialize the debugging variables */
diff --git a/include/linux/coda_psdev.h b/fs/coda/coda_psdev.h
similarity index 79%
rename from include/linux/coda_psdev.h
rename to fs/coda/coda_psdev.h
index 9487f792770c..012e16f741a6 100644
--- a/include/linux/coda_psdev.h
+++ b/fs/coda/coda_psdev.h
@@ -4,21 +4,10 @@
 
 #include <linux/backing-dev.h>
 #include <linux/mutex.h>
-#include <uapi/linux/coda_psdev.h>
+#include <linux/coda_psdev.h>
 
 struct kstatfs;
 
-/* communication pending/processing queues */
-struct venus_comm {
-	u_long		    vc_seq;
-	wait_queue_head_t   vc_waitq; /* Venus wait queue */
-	struct list_head    vc_pending;
-	struct list_head    vc_processing;
-	int                 vc_inuse;
-	struct super_block *vc_sb;
-	struct mutex	    vc_mutex;
-};
-
 /* messages between coda filesystem in kernel and Venus */
 struct upc_req {
 	struct list_head	uc_chain;
@@ -36,6 +25,17 @@ struct upc_req {
 #define CODA_REQ_WRITE  0x4
 #define CODA_REQ_ABORT  0x8
 
+/* communication pending/processing queues */
+struct venus_comm {
+	u_long		    vc_seq;
+	wait_queue_head_t   vc_waitq; /* Venus wait queue */
+	struct list_head    vc_pending;
+	struct list_head    vc_processing;
+	int                 vc_inuse;
+	struct super_block *vc_sb;
+	struct mutex	    vc_mutex;
+};
+
 static inline struct venus_comm *coda_vcp(struct super_block *sb)
 {
 	return (struct venus_comm *)((sb)->s_fs_info);
@@ -46,30 +46,30 @@ int venus_rootfid(struct super_block *sb, struct CodaFid *fidp);
 int venus_getattr(struct super_block *sb, struct CodaFid *fid,
 		  struct coda_vattr *attr);
 int venus_setattr(struct super_block *, struct CodaFid *, struct coda_vattr *);
-int venus_lookup(struct super_block *sb, struct CodaFid *fid, 
-		 const char *name, int length, int *type, 
+int venus_lookup(struct super_block *sb, struct CodaFid *fid,
+		 const char *name, int length, int *type,
 		 struct CodaFid *resfid);
 int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
 		kuid_t uid);
 int venus_open(struct super_block *sb, struct CodaFid *fid, int flags,
 	       struct file **f);
-int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid, 
-		const char *name, int length, 
+int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid,
+		const char *name, int length,
 		struct CodaFid *newfid, struct coda_vattr *attrs);
-int venus_create(struct super_block *sb, struct CodaFid *dirfid, 
+int venus_create(struct super_block *sb, struct CodaFid *dirfid,
 		 const char *name, int length, int excl, int mode,
-		 struct CodaFid *newfid, struct coda_vattr *attrs) ;
-int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid, 
+		 struct CodaFid *newfid, struct coda_vattr *attrs);
+int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid,
 		const char *name, int length);
-int venus_remove(struct super_block *sb, struct CodaFid *dirfid, 
+int venus_remove(struct super_block *sb, struct CodaFid *dirfid,
 		 const char *name, int length);
-int venus_readlink(struct super_block *sb, struct CodaFid *fid, 
+int venus_readlink(struct super_block *sb, struct CodaFid *fid,
 		   char *buffer, int *length);
-int venus_rename(struct super_block *, struct CodaFid *new_fid, 
-		 struct CodaFid *old_fid, size_t old_length, 
-		 size_t new_length, const char *old_name, 
+int venus_rename(struct super_block *sb, struct CodaFid *new_fid,
+		 struct CodaFid *old_fid, size_t old_length,
+		 size_t new_length, const char *old_name,
 		 const char *new_name);
-int venus_link(struct super_block *sb, struct CodaFid *fid, 
+int venus_link(struct super_block *sb, struct CodaFid *fid,
 		  struct CodaFid *dirfid, const char *name, int len );
 int venus_symlink(struct super_block *sb, struct CodaFid *fid,
 		  const char *name, int len, const char *symname, int symlen);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 7e103eb8ffcd..716a0b932ec0 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -23,7 +23,7 @@
 #include <linux/uaccess.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
+#include "coda_psdev.h"
 #include "coda_linux.h"
 #include "coda_cache.h"
 
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 1cbc1f2298ee..ef135b209e18 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -22,8 +22,7 @@
 #include <linux/uaccess.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
-
+#include "coda_psdev.h"
 #include "coda_linux.h"
 #include "coda_int.h"
 
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 97424cf206c0..4c512572f257 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -27,7 +27,7 @@
 #include <linux/vmalloc.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
+#include "coda_psdev.h"
 #include "coda_linux.h"
 #include "coda_cache.h"
 
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index e0c17b7dccce..644d48c12ce8 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -20,8 +20,7 @@
 #include <linux/uaccess.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
-
+#include "coda_psdev.h"
 #include "coda_linux.h"
 
 /* pioctl ops */
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 67092f069b32..b69b6108f595 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -42,8 +42,7 @@
 #include <linux/uaccess.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
-
+#include "coda_psdev.h"
 #include "coda_linux.h"
 
 #include "coda_int.h"
diff --git a/fs/coda/symlink.c b/fs/coda/symlink.c
index 202297d156df..8907d0508198 100644
--- a/fs/coda/symlink.c
+++ b/fs/coda/symlink.c
@@ -17,8 +17,7 @@
 #include <linux/pagemap.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
-
+#include "coda_psdev.h"
 #include "coda_linux.h"
 
 static int coda_symlink_filler(struct file *file, struct page *page)
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index 1e2f50722107..eb8cc30f2589 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -33,7 +33,7 @@
 #include <linux/vfs.h>
 
 #include <linux/coda.h>
-#include <linux/coda_psdev.h>
+#include "coda_psdev.h"
 #include "coda_linux.h"
 #include "coda_cache.h"
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 16/22] coda: remove uapi/linux/coda_psdev.h
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (14 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 15/22] coda: Move internal defs out of include/linux/ [ver #2] Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 17/22] coda: destroy mutex in put_super() Jan Harkes
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

Nothing is left in this header that is used by userspace.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/coda_psdev.h            |  5 ++++-
 include/uapi/linux/coda_psdev.h | 10 ----------
 2 files changed, 4 insertions(+), 11 deletions(-)
 delete mode 100644 include/uapi/linux/coda_psdev.h

diff --git a/fs/coda/coda_psdev.h b/fs/coda/coda_psdev.h
index 012e16f741a6..801423cbbdfc 100644
--- a/fs/coda/coda_psdev.h
+++ b/fs/coda/coda_psdev.h
@@ -3,8 +3,11 @@
 #define __CODA_PSDEV_H
 
 #include <linux/backing-dev.h>
+#include <linux/magic.h>
 #include <linux/mutex.h>
-#include <linux/coda_psdev.h>
+
+#define CODA_PSDEV_MAJOR 67
+#define MAX_CODADEVS  5	   /* how many do we allow */
 
 struct kstatfs;
 
diff --git a/include/uapi/linux/coda_psdev.h b/include/uapi/linux/coda_psdev.h
deleted file mode 100644
index 3dacb7fad66a..000000000000
--- a/include/uapi/linux/coda_psdev.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _UAPI__CODA_PSDEV_H
-#define _UAPI__CODA_PSDEV_H
-
-#include <linux/magic.h>
-
-#define CODA_PSDEV_MAJOR 67
-#define MAX_CODADEVS  5	   /* how many do we allow */
-
-#endif /* _UAPI__CODA_PSDEV_H */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 17/22] coda: destroy mutex in put_super()
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (15 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 16/22] coda: remove uapi/linux/coda_psdev.h Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 18/22] coda: use SIZE() for stat Jan Harkes
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Fabian Frederick

From: Fabian Frederick <fabf@skynet.be>

we can safely destroy vc_mutex at the end of umount process.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 4c512572f257..1aba71eec385 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -242,6 +242,7 @@ static void coda_put_super(struct super_block *sb)
 	vcp->vc_sb = NULL;
 	sb->s_fs_info = NULL;
 	mutex_unlock(&vcp->vc_mutex);
+	mutex_destroy(&vcp->vc_mutex);
 
 	pr_info("Bye bye.\n");
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 18/22] coda: use SIZE() for stat
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (16 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 17/22] coda: destroy mutex in put_super() Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 19/22] coda: add __init to init_coda_psdev() Jan Harkes
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Fabian Frederick

From: Fabian Frederick <fabf@skynet.be>

max_t expression was already defined in coda sources

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/upcall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index eb8cc30f2589..15c0e4fdb0e3 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -553,7 +553,7 @@ int venus_statfs(struct dentry *dentry, struct kstatfs *sfs)
         union outputArgs *outp;
         int insize, outsize, error;
         
-	insize = max_t(unsigned int, INSIZE(statfs), OUTSIZE(statfs));
+	insize = SIZE(statfs);
 	UPARG(CODA_STATFS);
 
 	error = coda_upcall(coda_vcp(dentry->d_sb), insize, &outsize, inp);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 19/22] coda: add __init to init_coda_psdev()
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (17 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 18/22] coda: use SIZE() for stat Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 20/22] coda: remove sysctl object from module when unused Jan Harkes
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Fabian Frederick

From: Fabian Frederick <fabf@skynet.be>

init_coda_psdev() was only called by __init function.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index b69b6108f595..482b7ba0339c 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -361,7 +361,7 @@ static const struct file_operations coda_psdev_fops = {
 	.llseek		= noop_llseek,
 };
 
-static int init_coda_psdev(void)
+static int __init init_coda_psdev(void)
 {
 	int i, err = 0;
 	if (register_chrdev(CODA_PSDEV_MAJOR, "coda", &coda_psdev_fops)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 20/22] coda: remove sysctl object from module when unused
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (18 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 19/22] coda: add __init to init_coda_psdev() Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 21/22] coda: remove sb test in coda_fid_to_inode() Jan Harkes
  2019-03-20 16:45 ` [PATCH 22/22] coda: ftoc validity check integration Jan Harkes
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Fabian Frederick

From: Fabian Frederick <fabf@skynet.be>

Inspired by NFS sysctl process

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/Makefile     |  3 ++-
 fs/coda/coda_int.h   | 10 ++++++++++
 fs/coda/coda_linux.h |  4 ----
 fs/coda/sysctl.c     | 11 -----------
 4 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/fs/coda/Makefile b/fs/coda/Makefile
index 1bab69a0d347..30e4e1bd22bb 100644
--- a/fs/coda/Makefile
+++ b/fs/coda/Makefile
@@ -5,7 +5,8 @@
 obj-$(CONFIG_CODA_FS) += coda.o
 
 coda-objs := psdev.o cache.o cnode.o inode.o dir.o file.o upcall.o \
-	     coda_linux.o symlink.o pioctl.o sysctl.o 
+	     coda_linux.o symlink.o pioctl.o
+coda-$(CONFIG_SYSCTL) += sysctl.o
 
 # If you want debugging output, please uncomment the following line.
 
diff --git a/fs/coda/coda_int.h b/fs/coda/coda_int.h
index bb0b3e0ed6c2..f82b59c9dd28 100644
--- a/fs/coda/coda_int.h
+++ b/fs/coda/coda_int.h
@@ -13,9 +13,19 @@ extern int coda_fake_statfs;
 void coda_destroy_inodecache(void);
 int __init coda_init_inodecache(void);
 int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync);
+
+#ifdef CONFIG_SYSCTL
 void coda_sysctl_init(void);
 void coda_sysctl_clean(void);
+#else
+static inline void coda_sysctl_init(void)
+{
+}
 
+static inline void coda_sysctl_clean(void)
+{
+}
+#endif
 #endif  /*  _CODA_INT_  */
 
 
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index 517a363245c9..d5ebd36fb2cc 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -59,10 +59,6 @@ void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
 void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
 unsigned short coda_flags_to_cflags(unsigned short);
 
-/* sysctl.h */
-void coda_sysctl_init(void);
-void coda_sysctl_clean(void);
-
 /* inode to cnode access functions */
 
 static inline struct coda_inode_info *ITOC(struct inode *inode)
diff --git a/fs/coda/sysctl.c b/fs/coda/sysctl.c
index 0301d45000a8..fda3b702b1c5 100644
--- a/fs/coda/sysctl.c
+++ b/fs/coda/sysctl.c
@@ -12,7 +12,6 @@
 
 #include "coda_int.h"
 
-#ifdef CONFIG_SYSCTL
 static struct ctl_table_header *fs_table_header;
 
 static struct ctl_table coda_table[] = {
@@ -62,13 +61,3 @@ void coda_sysctl_clean(void)
 		fs_table_header = NULL;
 	}
 }
-
-#else
-void coda_sysctl_init(void)
-{
-}
-
-void coda_sysctl_clean(void)
-{
-}
-#endif
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 21/22] coda: remove sb test in coda_fid_to_inode()
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (19 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 20/22] coda: remove sysctl object from module when unused Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  2019-03-20 16:45 ` [PATCH 22/22] coda: ftoc validity check integration Jan Harkes
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Fabian Frederick

From: Fabian Frederick <fabf@skynet.be>

coda_fid_to_inode() is only called by coda_downcall() where
sb is already being tested.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/cnode.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 2e5badf67f98..e2dcf2addf3f 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -137,11 +137,6 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb)
 	struct inode *inode;
 	unsigned long hash = coda_f2i(fid);
 
-	if ( !sb ) {
-		pr_warn("%s: no sb!\n", __func__);
-		return NULL;
-	}
-
 	inode = ilookup5(sb, hash, coda_test_inode, fid);
 	if ( !inode )
 		return NULL;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 22/22] coda: ftoc validity check integration
  2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
                   ` (20 preceding siblings ...)
  2019-03-20 16:45 ` [PATCH 21/22] coda: remove sb test in coda_fid_to_inode() Jan Harkes
@ 2019-03-20 16:45 ` Jan Harkes
  21 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-03-20 16:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel, Fabian Frederick

From: Fabian Frederick <fabf@skynet.be>

This patch moves cfi check in coda_ftoc() instead of repeating
it in the wild.

Module size
   text	   data	    bss	    dec	    hex	filename
  28297	   1040	    700	  30037	   7555	fs/coda/coda.ko.before
  28263	    980	    700	  29943	   74f7	fs/coda/coda.ko.after

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/cnode.c     | 10 ++++++++++
 fs/coda/coda_fs_i.h |  3 +--
 fs/coda/dir.c       |  6 ++----
 fs/coda/file.c      | 17 +++++------------
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index e2dcf2addf3f..06855f6c7902 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -148,6 +148,16 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb)
 	return inode;
 }
 
+struct coda_file_info *coda_ftoc(struct file *file)
+{
+	struct coda_file_info *cfi = file->private_data;
+
+	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+
+	return cfi;
+
+}
+
 /* the CONTROL inode is made without asking attributes from Venus */
 struct inode *coda_cnode_makectl(struct super_block *sb)
 {
diff --git a/fs/coda/coda_fs_i.h b/fs/coda/coda_fs_i.h
index d702ba1a2bf9..c99d574d1c43 100644
--- a/fs/coda/coda_fs_i.h
+++ b/fs/coda/coda_fs_i.h
@@ -42,8 +42,6 @@ struct coda_file_info {
 	unsigned int	   cfi_mapcount;  /* nr of times this file is mapped */
 };
 
-#define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data))
-
 /* flags */
 #define C_VATTR       0x1   /* Validity of vattr in inode */
 #define C_FLUSH       0x2   /* used after a flush */
@@ -54,6 +52,7 @@ struct inode *coda_cnode_make(struct CodaFid *, struct super_block *);
 struct inode *coda_iget(struct super_block *sb, struct CodaFid *fid, struct coda_vattr *attr);
 struct inode *coda_cnode_makectl(struct super_block *sb);
 struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
+struct coda_file_info *coda_ftoc(struct file *file);
 void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
 
 #endif
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 716a0b932ec0..ca40c2556ba6 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -356,8 +356,7 @@ static int coda_venus_readdir(struct file *coda_file, struct dir_context *ctx)
 	ino_t ino;
 	int ret;
 
-	cfi = CODA_FTOC(coda_file);
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	cfi = coda_ftoc(coda_file);
 	host_file = cfi->cfi_container;
 
 	cii = ITOC(file_inode(coda_file));
@@ -426,8 +425,7 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx)
 	struct file *host_file;
 	int ret;
 
-	cfi = CODA_FTOC(coda_file);
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	cfi = coda_ftoc(coda_file);
 	host_file = cfi->cfi_container;
 
 	if (host_file->f_op->iterate || host_file->f_op->iterate_shared) {
diff --git a/fs/coda/file.c b/fs/coda/file.c
index ef135b209e18..f2f640b37466 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -30,9 +30,7 @@ static ssize_t
 coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct file *coda_file = iocb->ki_filp;
-	struct coda_file_info *cfi = CODA_FTOC(coda_file);
-
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	struct coda_file_info *cfi = coda_ftoc(coda_file);
 
 	return vfs_iter_read(cfi->cfi_container, to, &iocb->ki_pos, 0);
 }
@@ -42,12 +40,10 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct file *coda_file = iocb->ki_filp;
 	struct inode *coda_inode = file_inode(coda_file);
-	struct coda_file_info *cfi = CODA_FTOC(coda_file);
+	struct coda_file_info *cfi = coda_ftoc(coda_file);
 	struct file *host_file;
 	ssize_t ret;
 
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
-
 	host_file = cfi->cfi_container;
 	file_start_write(host_file);
 	inode_lock(coda_inode);
@@ -68,8 +64,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)
 	struct file *host_file;
 	struct inode *coda_inode, *host_inode;
 
-	cfi = CODA_FTOC(coda_file);
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	cfi = coda_ftoc(coda_file);
 	host_file = cfi->cfi_container;
 
 	if (!host_file->f_op->mmap)
@@ -141,8 +136,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
 	struct inode *host_inode;
 	int err;
 
-	cfi = CODA_FTOC(coda_file);
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	cfi = coda_ftoc(coda_file);
 
 	err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
 			  coda_flags, coda_file->f_cred->fsuid);
@@ -184,8 +178,7 @@ int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)
 		return err;
 	inode_lock(coda_inode);
 
-	cfi = CODA_FTOC(coda_file);
-	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
+	cfi = coda_ftoc(coda_file);
 	host_file = cfi->cfi_container;
 
 	err = vfs_fsync(host_file, datasync);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 14/22] coda: bump module version
  2019-05-17 18:36 [PATCH 00/22] Coda updates Jan Harkes
@ 2019-05-17 18:36 ` Jan Harkes
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Harkes @ 2019-05-17 18:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Jan Harkes, linux-fsdevel

The out of tree module version had been bumped several times already,
but we haven't kept this in-tree one in sync, partly because most
changes go from here to the out-of-tree copy.

Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 4c8d968031bb..67092f069b32 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -393,7 +393,7 @@ MODULE_AUTHOR("Jan Harkes, Peter J. Braam");
 MODULE_DESCRIPTION("Coda Distributed File System VFS interface");
 MODULE_ALIAS_CHARDEV_MAJOR(CODA_PSDEV_MAJOR);
 MODULE_LICENSE("GPL");
-MODULE_VERSION("6.6");
+MODULE_VERSION("6.11");
 
 static int __init init_coda(void)
 {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2019-05-17 18:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 16:45 [PATCH 00/22] Coda updates for linux-5.1 Jan Harkes
2019-03-20 16:45 ` [PATCH 01/22] uapi linux/coda.h: use __kernel_pid_t for userspace Jan Harkes
2019-03-20 16:45 ` [PATCH 02/22] uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers Jan Harkes
2019-03-20 16:45 ` [PATCH 03/22] coda: add error handling for fget Jan Harkes
2019-03-20 16:45 ` [PATCH 04/22] coda: potential buffer overflow in coda_psdev_write() Jan Harkes
2019-03-20 16:45 ` [PATCH 05/22] coda: Fix build using bare-metal toolchain Jan Harkes
2019-03-20 16:45 ` [PATCH 06/22] coda: don't try to print names that were considered too long Jan Harkes
2019-03-20 16:45 ` [PATCH 07/22] uapi linux/coda_psdev.h: Move CODA_REQ_ from uapi to kernel side headers Jan Harkes
2019-03-20 16:45 ` [PATCH 08/22] coda: clean up indentation, replace spaces with tab Jan Harkes
2019-03-20 16:45 ` [PATCH 09/22] coda: stop using 'struct timespec' in user API Jan Harkes
2019-03-20 16:45 ` [PATCH 10/22] coda: Remove duplicate header Jan Harkes
2019-03-20 16:45 ` [PATCH 11/22] coda: change Coda's user api to use 64-bit time_t in timespec Jan Harkes
2019-03-20 16:45 ` [PATCH 12/22] coda: get rid of CODA_ALLOC() Jan Harkes
2019-03-20 16:45 ` [PATCH 13/22] coda: get rid of CODA_FREE() Jan Harkes
2019-03-20 16:45 ` [PATCH 14/22] coda: bump module version Jan Harkes
2019-03-20 16:45 ` [PATCH 15/22] coda: Move internal defs out of include/linux/ [ver #2] Jan Harkes
2019-03-20 16:45 ` [PATCH 16/22] coda: remove uapi/linux/coda_psdev.h Jan Harkes
2019-03-20 16:45 ` [PATCH 17/22] coda: destroy mutex in put_super() Jan Harkes
2019-03-20 16:45 ` [PATCH 18/22] coda: use SIZE() for stat Jan Harkes
2019-03-20 16:45 ` [PATCH 19/22] coda: add __init to init_coda_psdev() Jan Harkes
2019-03-20 16:45 ` [PATCH 20/22] coda: remove sysctl object from module when unused Jan Harkes
2019-03-20 16:45 ` [PATCH 21/22] coda: remove sb test in coda_fid_to_inode() Jan Harkes
2019-03-20 16:45 ` [PATCH 22/22] coda: ftoc validity check integration Jan Harkes
2019-05-17 18:36 [PATCH 00/22] Coda updates Jan Harkes
2019-05-17 18:36 ` [PATCH 14/22] coda: bump module version Jan Harkes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).