From patchwork Sat Dec 31 13:00:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9492721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 360B562ABB for ; Sat, 31 Dec 2016 13:00:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EF4C223A6 for ; Sat, 31 Dec 2016 13:00:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2178F24B44; Sat, 31 Dec 2016 13:00:24 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 37BF3223A6 for ; Sat, 31 Dec 2016 13:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754540AbcLaNAV (ORCPT ); Sat, 31 Dec 2016 08:00:21 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36507 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbcLaNAU (ORCPT ); Sat, 31 Dec 2016 08:00:20 -0500 Received: by mail-pf0-f194.google.com with SMTP id c4so23051576pfb.3 for ; Sat, 31 Dec 2016 05:00:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=ExYS++ILxQ2re4jym5WkX1RiiMSEbGJaqcy9wz9VNUg=; b=q3QgWqEPEIBaGyBxg2k085sMa4iQi/C2XkjUnii7QGy3efrfNHHSZXaNUpjZiBfjDR vqdr8PoebpKMDE+zrYAurDURhcWcg5x8MEq+HKFMImWUu3PHPTLqBiTvfTSFYGwe6FTB ZW9uwi9Oqq2eoBidGY1x/UiRqV4TE0gO7GRUCys5obDY/an7lAKklRPkT+kNKyjxM36V Ry5DtSjfCdMpIkgxyzW70KBbBQsHcVjr3bH5FI+Xq0omW0agCqjrXiNMrQHB/yf2czXq UTCYkfvOCeKaMNUPTfds4SwU0L2F6y2Z5O6jETLmPM9JMmb/W+LgwkZseQb/iwV8Qae5 2k6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=ExYS++ILxQ2re4jym5WkX1RiiMSEbGJaqcy9wz9VNUg=; b=HhqiI8t1LF+U0qxDPe+afS9PosGn/+mb5gJsoEZzKXKqnenbhfK79U67+O54DZ+2Gc QDRexYEGsgDZoqcWWPL7bF4vsmQcQO4g+XklqFVZu11RyOSTJ+kSEoxRgkzrbIkgl7K+ 3AFWv2TTjPbNbYNa8SkYMlE6sobo5pQrTg88WFqucaW59GP4FuXK/BnQq/wn7sSMCQ8L 3lZI0j11c+r35YyCb8it1y++G3DLoTnveEc8AFM/xQlSuHmjEHWpv0u/BxHrgPxsvo2J vp23/yA+SLipp3hKv7qJ3gflqOYJ4rV8PI/iWKiRqGVql/8Mmelr95HSnv/kp6SlvRML Gbyg== X-Gm-Message-State: AIkVDXInD3XJlw3/gLu2oFvv4N3GZVePDUe2yE2dYep40b8URAXcsXH8aNC16jJ035wOsA== X-Received: by 10.98.67.138 with SMTP id l10mr48163172pfi.101.1483189219959; Sat, 31 Dec 2016 05:00:19 -0800 (PST) Received: from [192.168.0.104] ([183.228.30.39]) by smtp.googlemail.com with ESMTPSA id d15sm119865594pfl.46.2016.12.31.05.00.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Dec 2016 05:00:19 -0800 (PST) From: Kinglong Mee Subject: [PATCH 2/3 v2] NFSD: cleanup dead codes and values in nfsd_write To: "J. Bruce Fields" , linux-nfs@vger.kernel.org Cc: Christoph Hellwig , kinglongmee@gmail.com Message-ID: <187726e9-d42e-bf0a-30a3-6f10ce0eed3a@gmail.com> Date: Sat, 31 Dec 2016 21:00:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP v2, move arguments to make codes readable Signed-off-by: Kinglong Mee Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs3proc.c | 8 +++----- fs/nfsd/nfsproc.c | 7 ++----- fs/nfsd/vfs.c | 35 +++++++++++------------------------ fs/nfsd/vfs.h | 4 ++-- 4 files changed, 18 insertions(+), 36 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 69cd0f1..045c908 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -193,11 +193,9 @@ nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp, fh_copy(&resp->fh, &argp->fh); resp->committed = argp->stable; - nfserr = nfsd_write(rqstp, &resp->fh, NULL, - argp->offset, - rqstp->rq_vec, argp->vlen, - &cnt, - resp->committed); + nfserr = nfsd_write(rqstp, &resp->fh, argp->offset, + rqstp->rq_vec, argp->vlen, + &cnt, resp->committed); resp->count = cnt; RETURN_STATUS(nfserr); } diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index f157c7e..fa82b77 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -210,11 +210,8 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp, SVCFH_fmt(&argp->fh), argp->len, argp->offset); - nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, - argp->offset, - rqstp->rq_vec, argp->vlen, - &cnt, - NFS_DATA_SYNC); + nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), argp->offset, + rqstp->rq_vec, argp->vlen, &cnt, NFS_DATA_SYNC); return nfsd_return_attrs(nfserr, resp); } diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 726b2d2..d1d4a11 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1034,35 +1034,22 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, * N.B. After this call fhp needs an fh_put */ __be32 -nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, - loff_t offset, struct kvec *vec, int vlen, unsigned long *cnt, - int stable) +nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, + struct kvec *vec, int vlen, unsigned long *cnt, int stable) { - __be32 err = 0; + struct file *file = NULL; + __be32 err = 0; trace_write_start(rqstp, fhp, offset, vlen); - if (file) { - err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry, - NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE); - if (err) - goto out; - trace_write_opened(rqstp, fhp, offset, vlen); - err = nfsd_vfs_write(rqstp, fhp, file, offset, vec, vlen, cnt, - stable); - trace_write_io_done(rqstp, fhp, offset, vlen); - } else { - err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_WRITE, &file); - if (err) - goto out; + err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_WRITE, &file); + if (err) + goto out; - trace_write_opened(rqstp, fhp, offset, vlen); - if (cnt) - err = nfsd_vfs_write(rqstp, fhp, file, offset, vec, vlen, - cnt, stable); - trace_write_io_done(rqstp, fhp, offset, vlen); - fput(file); - } + trace_write_opened(rqstp, fhp, offset, vlen); + err = nfsd_vfs_write(rqstp, fhp, file, offset, vec, vlen, cnt, stable); + trace_write_io_done(rqstp, fhp, offset, vlen); + fput(file); out: trace_write_done(rqstp, fhp, offset, vlen); return err; diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index 8458d8c..db98c48 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -83,8 +83,8 @@ __be32 nfsd_readv(struct file *, loff_t, struct kvec *, int, unsigned long *); __be32 nfsd_read(struct svc_rqst *, struct svc_fh *, loff_t, struct kvec *, int, unsigned long *); -__be32 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *, - loff_t, struct kvec *,int, unsigned long *, int); +__be32 nfsd_write(struct svc_rqst *, struct svc_fh *, loff_t, + struct kvec *, int, unsigned long *, int); __be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, loff_t offset, struct kvec *vec, int vlen, unsigned long *cnt,