From patchwork Fri May 17 18:36:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7E426C5 for ; Fri, 17 May 2019 18:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6D5C28173 for ; Fri, 17 May 2019 18:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A90ED28420; Fri, 17 May 2019 18:37:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 035EE28173 for ; Fri, 17 May 2019 18:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729386AbfEQShD (ORCPT ); Fri, 17 May 2019 14:37:03 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57564 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000nj-CI; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 01/22] coda: pass the host file in vma->vm_file on mmap Date: Fri, 17 May 2019 14:36:39 -0400 Message-Id: <0e850c6e59c0b147dc2dcd51a3af004c948c3697.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Various file systems expect that vma->vm_file points at their own file handle, several use file_inode(vma->vm_file) to get at their inode or use vma->vm_file->private_data. However the way Coda wrapped mmap on a host file broke this assumption, vm_file was still pointing at the Coda file and the host file systems would scribble over Coda's inode and private file data. This patch fixes the incorrect expectation and wraps vm_ops->open and vm_ops->close to allow Coda to track when the vm_area_struct is destroyed so we still release the reference on the Coda file handle at the right time. Cc: stable@vger.kernel.org Signed-off-by: Jan Harkes --- fs/coda/file.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/fs/coda/file.c b/fs/coda/file.c index 1cbc1f2298ee..43d371551d2b 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -27,6 +27,13 @@ #include "coda_linux.h" #include "coda_int.h" +struct coda_vm_ops { + atomic_t refcnt; + struct file *coda_file; + const struct vm_operations_struct *host_vm_ops; + struct vm_operations_struct vm_ops; +}; + static ssize_t coda_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { @@ -61,6 +68,34 @@ coda_file_write_iter(struct kiocb *iocb, struct iov_iter *to) return ret; } +static void +coda_vm_open(struct vm_area_struct *vma) +{ + struct coda_vm_ops *cvm_ops = + container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); + + atomic_inc(&cvm_ops->refcnt); + + if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->open) + cvm_ops->host_vm_ops->open(vma); +} + +static void +coda_vm_close(struct vm_area_struct *vma) +{ + struct coda_vm_ops *cvm_ops = + container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); + + if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->close) + cvm_ops->host_vm_ops->close(vma); + + if (atomic_dec_and_test(&cvm_ops->refcnt)) { + vma->vm_ops = cvm_ops->host_vm_ops; + fput(cvm_ops->coda_file); + kfree(cvm_ops); + } +} + static int coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) { @@ -68,6 +103,8 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) struct coda_inode_info *cii; struct file *host_file; struct inode *coda_inode, *host_inode; + struct coda_vm_ops *cvm_ops; + int ret; cfi = CODA_FTOC(coda_file); BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); @@ -76,6 +113,13 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) if (!host_file->f_op->mmap) return -ENODEV; + if (WARN_ON(coda_file != vma->vm_file)) + return -EIO; + + cvm_ops = kmalloc(sizeof(struct coda_vm_ops), GFP_KERNEL); + if (!cvm_ops) + return -ENOMEM; + coda_inode = file_inode(coda_file); host_inode = file_inode(host_file); @@ -89,6 +133,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) * the container file on us! */ else if (coda_inode->i_mapping != host_inode->i_mapping) { spin_unlock(&cii->c_lock); + kfree(cvm_ops); return -EBUSY; } @@ -97,7 +142,29 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) cfi->cfi_mapcount++; spin_unlock(&cii->c_lock); - return call_mmap(host_file, vma); + vma->vm_file = get_file(host_file); + ret = call_mmap(vma->vm_file, vma); + + if (ret) { + /* if call_mmap fails, our caller will put coda_file so we + * should drop the reference to the host_file that we got. + */ + fput(host_file); + kfree(cvm_ops); + } else { + /* here we add redirects for the open/close vm_operations */ + cvm_ops->host_vm_ops = vma->vm_ops; + if (vma->vm_ops) + cvm_ops->vm_ops = *vma->vm_ops; + + cvm_ops->vm_ops.open = coda_vm_open; + cvm_ops->vm_ops.close = coda_vm_close; + cvm_ops->coda_file = coda_file; + atomic_set(&cvm_ops->refcnt, 1); + + vma->vm_ops = &cvm_ops->vm_ops; + } + return ret; } int coda_open(struct inode *coda_inode, struct file *coda_file) @@ -207,4 +274,3 @@ const struct file_operations coda_file_operations = { .fsync = coda_fsync, .splice_read = generic_file_splice_read, }; - From patchwork Fri May 17 18:36:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 623CA1395 for ; Fri, 17 May 2019 18:37:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C6FB28173 for ; Fri, 17 May 2019 18:37:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 410EA28420; Fri, 17 May 2019 18:37:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2D9E28173 for ; Fri, 17 May 2019 18:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbfEQShS (ORCPT ); Fri, 17 May 2019 14:37:18 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57600 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729363AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000nn-Dx; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Mikko Rapeli Subject: [PATCH 02/22] uapi linux/coda.h: use __kernel_pid_t for userspace Date: Fri, 17 May 2019 14:36:40 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mikko Rapeli 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 Signed-off-by: Jan Harkes --- 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; }; From patchwork Fri May 17 18:36:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD6C514C0 for ; Fri, 17 May 2019 18:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B00A628173 for ; Fri, 17 May 2019 18:37:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A467C283E8; Fri, 17 May 2019 18:37:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4423B28173 for ; Fri, 17 May 2019 18:37:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728927AbfEQShW (ORCPT ); Fri, 17 May 2019 14:37:22 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57602 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729364AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000ns-FH; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Mikko Rapeli Subject: [PATCH 03/22] uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers Date: Fri, 17 May 2019 14:36:41 -0400 Message-Id: <9f99f5ce6a0563d5266e6cf7aa9585aac2cae971.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mikko Rapeli 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 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 Cc: coda@cs.cmu.edu Cc: Jan Harkes Signed-off-by: Jan Harkes --- 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 From patchwork Fri May 17 18:36:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1746914C0 for ; Fri, 17 May 2019 18:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B02C28173 for ; Fri, 17 May 2019 18:37:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3AF6283C9; Fri, 17 May 2019 18:37:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8735C28420 for ; Fri, 17 May 2019 18:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbfEQShR (ORCPT ); Fri, 17 May 2019 14:37:17 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57558 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729356AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000nw-Gc; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Zhouyang Jia Subject: [PATCH 04/22] coda: add error handling for fget Date: Fri, 17 May 2019 14:36:42 -0400 Message-Id: <2514ec03df9c33b86e56748513267a80dd8004d9.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Zhouyang Jia 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 Signed-off-by: Jan Harkes --- 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 f2bb7985d21c..12cec325384c 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -186,8 +186,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); From patchwork Fri May 17 18:36:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DF786C5 for ; Fri, 17 May 2019 18:37:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914AB28173 for ; Fri, 17 May 2019 18:37:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8527428415; Fri, 17 May 2019 18:37:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D51828173 for ; Fri, 17 May 2019 18:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728723AbfEQShE (ORCPT ); Fri, 17 May 2019 14:37:04 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57578 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728546AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000o3-Ii; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Dan Carpenter Subject: [PATCH 05/22] coda: potential buffer overflow in coda_psdev_write() Date: Fri, 17 May 2019 14:36:43 -0400 Message-Id: <894fb6b250add09e4e3935f14649f21284a5cb18.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Jan Harkes --- 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 12cec325384c..0cd646a5d0c2 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -104,8 +104,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)) { @@ -131,7 +135,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); From patchwork Fri May 17 18:36:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F2AF1395 for ; Fri, 17 May 2019 18:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82844283C9 for ; Fri, 17 May 2019 18:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7724A283E8; Fri, 17 May 2019 18:37:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21F4328173 for ; Fri, 17 May 2019 18:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729409AbfEQShW (ORCPT ); Fri, 17 May 2019 14:37:22 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57584 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728820AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000o8-LD; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Sam Protsenko Subject: [PATCH 06/22] coda: Fix build using bare-metal toolchain Date: Fri, 17 May 2019 14:36:44 -0400 Message-Id: <3cbb40b0a57b6f9923a9d67b53473c0b691a3eaa.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sam Protsenko 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 Signed-off-by: Jan Harkes --- 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 #endif From patchwork Fri May 17 18:36:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 983EC1395 for ; Fri, 17 May 2019 18:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BB2228173 for ; Fri, 17 May 2019 18:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 807F7283E8; Fri, 17 May 2019 18:37:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50A4428173 for ; Fri, 17 May 2019 18:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729418AbfEQShZ (ORCPT ); Fri, 17 May 2019 14:37:25 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57566 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729352AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000oB-O4; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org Subject: [PATCH 07/22] coda: don't try to print names that were considered too long Date: Fri, 17 May 2019 14:36:45 -0400 Message-Id: <582ae759a4fdfa31a64c35de489fa4efabac09d6.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Probably safer to just show the unexpected length and debug it from the userspace side. Signed-off-by: Jan Harkes --- 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); } From patchwork Fri May 17 18:36:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3B4514C0 for ; Fri, 17 May 2019 18:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D757C28173 for ; Fri, 17 May 2019 18:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB3F6283E8; Fri, 17 May 2019 18:37:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 817E928173 for ; Fri, 17 May 2019 18:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729410AbfEQShW (ORCPT ); Fri, 17 May 2019 14:37:22 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57572 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728253AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000oH-Qd; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org Subject: [PATCH 08/22] uapi linux/coda_psdev.h: Move CODA_REQ_ from uapi to kernel side headers Date: Fri, 17 May 2019 14:36:46 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These constants only used internally and not exposed to userspace. Signed-off-by: Jan Harkes --- 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 */ From patchwork Fri May 17 18:36:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948329 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 089211395 for ; Fri, 17 May 2019 18:37:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFD9A28173 for ; Fri, 17 May 2019 18:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3D4D28415; Fri, 17 May 2019 18:37:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 833FC283E8 for ; Fri, 17 May 2019 18:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729387AbfEQShD (ORCPT ); Fri, 17 May 2019 14:37:03 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57596 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729360AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000oN-SY; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Colin Ian King Subject: [PATCH 09/22] coda: clean up indentation, replace spaces with tab Date: Fri, 17 May 2019 14:36:47 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King Trivial fix to clean up indentation, replace spaces with tab Signed-off-by: Colin Ian King Signed-off-by: Jan Harkes --- 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 0cd646a5d0c2..7e9ee614ec57 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -364,7 +364,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)) { From patchwork Fri May 17 18:36:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F6C06C5 for ; Fri, 17 May 2019 18:37:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8113D28173 for ; Fri, 17 May 2019 18:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75895283C9; Fri, 17 May 2019 18:37:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D001828421 for ; Fri, 17 May 2019 18:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728865AbfEQShQ (ORCPT ); Fri, 17 May 2019 14:37:16 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57606 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729367AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000oU-Tg; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Arnd Bergmann Subject: [PATCH 10/22] coda: stop using 'struct timespec' in user API Date: Fri, 17 May 2019 14:36:48 -0400 Message-Id: <562b7324149461743e4fbe2fedbf7c242f7e274a.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Arnd Bergmann 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 Link: https://patchwork.kernel.org/patch/10474735/ Signed-off-by: Arnd Bergmann Signed-off-by: Jan Harkes --- 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 */ From patchwork Fri May 17 18:36:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 234E56C5 for ; Fri, 17 May 2019 18:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15BA428173 for ; Fri, 17 May 2019 18:37:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A26A283E8; Fri, 17 May 2019 18:37:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F87928173 for ; Fri, 17 May 2019 18:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729412AbfEQShX (ORCPT ); Fri, 17 May 2019 14:37:23 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57598 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729361AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj2-0000oZ-Ui; Fri, 17 May 2019 14:37:00 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org Subject: [PATCH 11/22] coda: change Coda's user api to use 64-bit time_t in timespec Date: Fri, 17 May 2019 14:36:49 -0400 Message-Id: <8d089068823bfb292a4020f773922fbd82ffad39.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the 32-bit time_t problems to userspace. Signed-off-by: Jan Harkes --- 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 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 From patchwork Fri May 17 18:36:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81CE66C5 for ; Fri, 17 May 2019 18:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7343C28173 for ; Fri, 17 May 2019 18:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67D44283E8; Fri, 17 May 2019 18:37:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB7A28173 for ; Fri, 17 May 2019 18:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729389AbfEQShE (ORCPT ); Fri, 17 May 2019 14:37:04 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57586 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000og-02; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Dan Carpenter Subject: [PATCH 12/22] coda: get rid of CODA_ALLOC() Date: Fri, 17 May 2019 14:36:50 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Carpenter 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 Signed-off-by: Jan Harkes --- 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; From patchwork Fri May 17 18:36:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AF0E6C5 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EFF6283E8 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1384B28420; Fri, 17 May 2019 18:37:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8848628173 for ; Fri, 17 May 2019 18:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729406AbfEQShL (ORCPT ); Fri, 17 May 2019 14:37:11 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57612 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000oo-1Y; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Dan Carpenter Subject: [PATCH 13/22] coda: get rid of CODA_FREE() Date: Fri, 17 May 2019 14:36:51 -0400 Message-Id: <4950a94fd30ec5f84835dd4ca0bb67c0448672f5.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dan Carpenter The CODA_FREE() macro just calls kvfree(). We can call that directly instead. Signed-off-by: Dan Carpenter Signed-off-by: Jan Harkes --- 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; } From patchwork Fri May 17 18:36:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89A9614C0 for ; Fri, 17 May 2019 18:37:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D72528173 for ; Fri, 17 May 2019 18:37:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7259B283E8; Fri, 17 May 2019 18:37:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 245A0283C9 for ; Fri, 17 May 2019 18:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729356AbfEQShS (ORCPT ); Fri, 17 May 2019 14:37:18 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57604 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729366AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000pP-52; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org Subject: [PATCH 14/22] coda: bump module version Date: Fri, 17 May 2019 14:36:52 -0400 Message-Id: <8b0ab50a2da2f0180ac32c79d91811b4d1d0bd8b.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) { From patchwork Fri May 17 18:36:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCA5B1395 for ; Fri, 17 May 2019 18:37:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC6228173 for ; Fri, 17 May 2019 18:37:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3FFD28420; Fri, 17 May 2019 18:37:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17AFC28173 for ; Fri, 17 May 2019 18:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729090AbfEQShP (ORCPT ); Fri, 17 May 2019 14:37:15 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57610 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729372AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000pb-80; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, David Howells Subject: [PATCH 15/22] coda: Move internal defs out of include/linux/ [ver #2] Date: Fri, 17 May 2019 14:36:53 -0400 Message-Id: <3ceeee0415a929b89fb02700b6b4b3a07938acb8.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Howells Move include/linux/coda_psdev.h to fs/coda/ as there's nothing else that uses it. Signed-off-by: David Howells cc: Yann Droneaud cc: Jan Harkes 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 --- 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 #include -#include +#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 #include -#include #include +#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 #include -#include +#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 #include -#include +#include 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 #include -#include +#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 43d371551d2b..a6b32c883a50 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -22,8 +22,7 @@ #include #include -#include - +#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 23f6ebd08e80..96d832ed23b5 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -27,7 +27,7 @@ #include #include -#include +#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 #include -#include - +#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 #include -#include - +#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 #include -#include - +#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 #include -#include +#include "coda_psdev.h" #include "coda_linux.h" #include "coda_cache.h" From patchwork Fri May 17 18:36:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B1B71395 for ; Fri, 17 May 2019 18:37:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1BA428173 for ; Fri, 17 May 2019 18:37:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E64F528415; Fri, 17 May 2019 18:37:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0BF0283E8 for ; Fri, 17 May 2019 18:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729390AbfEQShE (ORCPT ); Fri, 17 May 2019 14:37:04 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57608 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729368AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000pg-A1; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org Subject: [PATCH 16/22] coda: remove uapi/linux/coda_psdev.h Date: Fri, 17 May 2019 14:36:54 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Nothing is left in this header that is used by userspace. Signed-off-by: Jan Harkes Signed-off-by: Jan Harkes Signed-off-by: Andrew Morton --- 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 +#include #include -#include + +#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 - -#define CODA_PSDEV_MAJOR 67 -#define MAX_CODADEVS 5 /* how many do we allow */ - -#endif /* _UAPI__CODA_PSDEV_H */ From patchwork Fri May 17 18:36:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5479A14C0 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46FF8283C9 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B77F28420; Fri, 17 May 2019 18:37:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E94B8283C9 for ; Fri, 17 May 2019 18:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729402AbfEQShL (ORCPT ); Fri, 17 May 2019 14:37:11 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57644 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729376AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000pl-C4; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 17/22] coda: destroy mutex in put_super() Date: Fri, 17 May 2019 14:36:55 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick we can safely destroy vc_mutex at the end of umount process. Signed-off-by: Fabian Frederick Signed-off-by: Jan Harkes --- fs/coda/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 96d832ed23b5..321f56e487cb 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -236,6 +236,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"); } From patchwork Fri May 17 18:36:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 438CF6C5 for ; Fri, 17 May 2019 18:37:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F3B28173 for ; Fri, 17 May 2019 18:37:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B88228421; Fri, 17 May 2019 18:37:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A32928173 for ; Fri, 17 May 2019 18:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729392AbfEQShF (ORCPT ); Fri, 17 May 2019 14:37:05 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57642 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729375AbfEQShD (ORCPT ); Fri, 17 May 2019 14:37:03 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000pu-E8; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 18/22] coda: use SIZE() for stat Date: Fri, 17 May 2019 14:36:56 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick max_t expression was already defined in coda sources Signed-off-by: Fabian Frederick Signed-off-by: Jan Harkes --- 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); From patchwork Fri May 17 18:36:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D03691880 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2D6E28173 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B771F283E8; Fri, 17 May 2019 18:37:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7547F283C9 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729394AbfEQShK (ORCPT ); Fri, 17 May 2019 14:37:10 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57648 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729379AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000q2-Fy; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 19/22] coda: add __init to init_coda_psdev() Date: Fri, 17 May 2019 14:36:57 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick init_coda_psdev() was only called by __init function. Signed-off-by: Fabian Frederick Signed-off-by: Jan Harkes --- 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)) { From patchwork Fri May 17 18:36:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 319DB1395 for ; Fri, 17 May 2019 18:37:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23E9E28173 for ; Fri, 17 May 2019 18:37:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1880C28421; Fri, 17 May 2019 18:37:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B29D528173 for ; Fri, 17 May 2019 18:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729113AbfEQShF (ORCPT ); Fri, 17 May 2019 14:37:05 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57646 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729377AbfEQShD (ORCPT ); Fri, 17 May 2019 14:37:03 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000q7-HW; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 20/22] coda: remove sysctl object from module when unused Date: Fri, 17 May 2019 14:36:58 -0400 Message-Id: <9afcc2cd09490849b309786bbf47fef75de7f91c.1558117389.git.jaharkes@cs.cmu.edu> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick Inspired by NFS sysctl process Signed-off-by: Fabian Frederick Signed-off-by: Jan Harkes --- 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 From patchwork Fri May 17 18:36:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A370514C0 for ; Fri, 17 May 2019 18:37:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92C0628173 for ; Fri, 17 May 2019 18:37:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87560283C9; Fri, 17 May 2019 18:37:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85256283E8 for ; Fri, 17 May 2019 18:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729393AbfEQShF (ORCPT ); Fri, 17 May 2019 14:37:05 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57672 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbfEQShD (ORCPT ); Fri, 17 May 2019 14:37:03 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000qD-KP; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 21/22] coda: remove sb test in coda_fid_to_inode() Date: Fri, 17 May 2019 14:36:59 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick coda_fid_to_inode() is only called by coda_downcall() where sb is already being tested. Signed-off-by: Fabian Frederick Signed-off-by: Jan Harkes --- 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; From patchwork Fri May 17 18:37:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Harkes X-Patchwork-Id: 10948347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAC491395 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B05E28173 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FAE528420; Fri, 17 May 2019 18:37:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16D0928173 for ; Fri, 17 May 2019 18:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729398AbfEQShK (ORCPT ); Fri, 17 May 2019 14:37:10 -0400 Received: from hurricane.elijah.cs.cmu.edu ([128.2.209.191]:57650 "EHLO hurricane.elijah.cs.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729378AbfEQShC (ORCPT ); Fri, 17 May 2019 14:37:02 -0400 Received: from jaharkes by hurricane.elijah.cs.cmu.edu with local (Exim 4.92) (envelope-from ) id 1hRhj3-0000qK-Mi; Fri, 17 May 2019 14:37:01 -0400 From: Jan Harkes To: Andrew Morton Cc: Jan Harkes , linux-fsdevel@vger.kernel.org, Fabian Frederick Subject: [PATCH 22/22] coda: ftoc validity check integration Date: Fri, 17 May 2019 14:37:00 -0400 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabian Frederick 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 Signed-off-by: Jan Harkes --- 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 a6b32c883a50..0dbd13ab72e3 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -37,9 +37,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); } @@ -49,12 +47,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); @@ -105,8 +101,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) struct coda_vm_ops *cvm_ops; 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->mmap) @@ -208,8 +203,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); @@ -251,8 +245,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);