From patchwork Fri Oct 19 08:19:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 10648799 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 BC54C3B73 for ; Fri, 19 Oct 2018 08:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEA5B28AA7 for ; Fri, 19 Oct 2018 08:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A29CC28AB1; Fri, 19 Oct 2018 08:20:34 +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 ADA6428AAC for ; Fri, 19 Oct 2018 08:20:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbeJSQZU (ORCPT ); Fri, 19 Oct 2018 12:25:20 -0400 Received: from mailrelay101.isp.belgacom.be ([195.238.20.128]:36172 "EHLO mailrelay101.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727366AbeJSQZT (ORCPT ); Fri, 19 Oct 2018 12:25:19 -0400 X-Belgacom-Dynamic: yes IronPort-PHdr: 9a23:FTLfSxfCLYXT9hgsbdMGYWx+lGMj4u6mDksu8pMizoh2WeGdxcWzZx7h7PlgxGXEQZ/co6odzbaO7Oa4ASQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5P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o+jx+F96d3H2VT2FogmMIQCc73K5lrkNmxFeOyrN4g/9YFNxV+fxJTh02OoXCwL8yN9enUwHZe/+NSVC7UpCoBiw3QtstwtgIJUFnFIaMlBfGigSjCb4ckfSlHpE4/7jd1Hu5c8h0wXjuz6owiVQ6BMFCYz71zpVj/hTeUtaa236SkLynIPwR X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AQAACMkslb/7dPQldjGwEBAQEDAQEBBwMBAQGBUQYBAQELAYEIfIFTEiiMDV+NfgGIUI4JgXo4AYRAAoUDIjQNDQEDAQECAQECAWwogjYigmIGJy8jEFE5HhmDIYF1EadaM4N9hieHLIQ6gUE/gRGNagKIbZVUCYYhiksCFZApmBU4gVVNIBiDJ4ImF44cPTCBAwE9AYoyAQE X-IPAS-Result: A2AQAACMkslb/7dPQldjGwEBAQEDAQEBBwMBAQGBUQYBAQELAYEIfIFTEiiMDV+NfgGIUI4JgXo4AYRAAoUDIjQNDQEDAQECAQECAWwogjYigmIGJy8jEFE5HhmDIYF1EadaM4N9hieHLIQ6gUE/gRGNagKIbZVUCYYhiksCFZApmBU4gVVNIBiDJ4ImF44cPTCBAwE9AYoyAQE Received: from 183.79-66-87.adsl-dyn.isp.belgacom.be (HELO localhost.localdomain) ([87.66.79.183]) by relay.skynet.be with ESMTP; 19 Oct 2018 10:20:14 +0200 From: Fabian Frederick To: akpm@linux-foundation.org Cc: jaharkes@cs.cmu.edu, coda@cs.cmu.edu, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, fabf@skynet.be Subject: [PATCH 7/7 linux-next] coda: ftoc validity check integration Date: Fri, 19 Oct 2018 10:19:33 +0200 Message-Id: <1539937173-26260-8-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1539937173-26260-1-git-send-email-fabf@skynet.be> References: <1539937173-26260-1-git-send-email-fabf@skynet.be> 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 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 --- 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 c42d340..36414438 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 d702ba1a..c99d574 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 00876dd..3e80770 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 1cbc1f2..55c22e2 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -31,9 +31,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); } @@ -43,12 +41,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); @@ -69,8 +65,7 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) struct file *host_file; struct inode *coda_inode, *host_inode; - cfi = CODA_FTOC(coda_file); - BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); + cfi = coda_ftoc(coda_file); host_file = cfi->cfi_container; if (!host_file->f_op->mmap) @@ -142,8 +137,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); @@ -185,8 +179,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);