From patchwork Tue Feb 7 09:12:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9559565 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 638B560434 for ; Tue, 7 Feb 2017 09:12:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46B2128285 for ; Tue, 7 Feb 2017 09:12:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3955928306; Tue, 7 Feb 2017 09:12:51 +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.9 required=2.0 tests=BAYES_00,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 C070828285 for ; Tue, 7 Feb 2017 09:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752011AbdBGJMt (ORCPT ); Tue, 7 Feb 2017 04:12:49 -0500 Received: from verein.lst.de ([213.95.11.211]:39405 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751567AbdBGJMq (ORCPT ); Tue, 7 Feb 2017 04:12:46 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id A51AA68D55; Tue, 7 Feb 2017 10:12:44 +0100 (CET) Date: Tue, 7 Feb 2017 10:12:44 +0100 From: Christoph Hellwig To: "J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: don't get write =?utf-8?Q?ac?= =?utf-8?Q?cess_tw=D1=96ce?= in nfsd_setattr Message-ID: <20170207091244.GA14911@lst.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) 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 Turns out doing mnt_want_write twice for the same process makes lockdep unhappy, so move the fh_want_write down to after calling vfs_truncate in nfsd_setattr. No changes to error handling required as the want write state is automatically cleaned up by the caller based on a flag in the svc_fh. Fixes: 41f53350 ("nfsd: special case truncates some more") Signed-off-by: Christoph Hellwig Reported-by: Dave Jones --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index ca13236dbb1f..a974368026a1 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -359,11 +359,6 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, err = fh_verify(rqstp, fhp, ftype, accmode); if (err) return err; - if (get_write_count) { - host_err = fh_want_write(fhp); - if (host_err) - goto out_host_err; - } dentry = fhp->fh_dentry; inode = d_inode(dentry); @@ -416,6 +411,12 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, iap->ia_valid |= ATTR_CTIME; + if (get_write_count) { + host_err = fh_want_write(fhp); + if (host_err) + goto out_host_err; + } + fh_lock(fhp); host_err = notify_change(dentry, iap, NULL); fh_unlock(fhp);