From patchwork Tue Jul 1 22:27:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4462751 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BF4F6BEEAA for ; Tue, 1 Jul 2014 22:27:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFAAC20304 for ; Tue, 1 Jul 2014 22:27:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8A30202EB for ; Tue, 1 Jul 2014 22:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030361AbaGAW15 (ORCPT ); Tue, 1 Jul 2014 18:27:57 -0400 Received: from mail-yk0-f180.google.com ([209.85.160.180]:39624 "EHLO mail-yk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030325AbaGAW14 (ORCPT ); Tue, 1 Jul 2014 18:27:56 -0400 Received: by mail-yk0-f180.google.com with SMTP id 131so6058350ykp.11 for ; Tue, 01 Jul 2014 15:27:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8YvgSkbzA2KemohIWzx7G9cOdogv9bovUKoRZNmd8Rg=; b=Tkge30gGNDK1I5Te6Ipyo7IQac2RgAo8a57QZHw8bHgXX7XHAIRoZZg07NTOAMYB5p 3Mumu2H7bP3h/RTAIRtGeYlxr81LtXWKRUTLe9X4dFYgywd/EDZmpBSbN62QXMhOfeS6 Nf96KWQ3Oj5NCni4IwrP1fCLwDqDia5+XqPGM8G7vGHRmtqLWq0WCuR5zQw/XvznSfhE t38VKld/HCiEdlmr8eqmjRlEevmYXlPHQWXkS0cb7rXjHQN9Mx/LqeulbD+/kRpGoCFZ yLxoiQQ2tJevpo4QI7jIjGlLpheEEf47cLBSa6+SEL184xfkbys/LTOuo4q4oEPdrGvd zFBg== X-Gm-Message-State: ALoCoQlR9vcd8SXeZ3FpwLMK+EhQZB5dRdbiSp7AFvypmAQ+tw+qaImAt6C+MWsyZkoo2pkLmCot X-Received: by 10.236.10.6 with SMTP id 6mr73781503yhu.23.1404253676016; Tue, 01 Jul 2014 15:27:56 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (50-33-230-70.drr02.mskg.mi.frontiernet.net. [50.33.230.70]) by mx.google.com with ESMTPSA id w36sm30342554yhn.4.2014.07.01.15.27.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Jul 2014 15:27:55 -0700 (PDT) From: Trond Myklebust To: Bruce Fields Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: Ensure that nfsd_create_setattr commits files to stable storage Date: Tue, 1 Jul 2014 18:27:53 -0400 Message-Id: <1404253673-12676-1-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.3 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since nfsd_create_setattr strips the mode from the struct iattr, it is quite possible that it will optimise away the call to nfsd_setattr altogether. If this is the case, then we never call commit_metadata() on the newly created file. Also ensure that both nfsd_setattr() and nfsd_create_setattr() fail when the call to commit_metadata fails. Signed-off-by: Trond Myklebust --- fs/nfsd/vfs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 140c496f612c..5fd9095268cb 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -464,7 +464,7 @@ out_put_write_access: if (size_change) put_write_access(inode); if (!err) - commit_metadata(fhp); + err = commit_metadata(fhp); out: return err; } @@ -1121,7 +1121,8 @@ nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp, iap->ia_valid &= ~(ATTR_UID|ATTR_GID); if (iap->ia_valid) return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); - return 0; + /* Callers expect file metadata to be committed here */ + return commit_metadata(resfhp); } /* HPUX client sometimes creates a file in mode 000, and sets size to 0. @@ -1253,9 +1254,10 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, err = nfsd_create_setattr(rqstp, resfhp, iap); /* - * nfsd_setattr already committed the child. Transactional filesystems - * had a chance to commit changes for both parent and child - * simultaneously making the following commit_metadata a noop. + * nfsd_create_setattr already committed the child. Transactional + * filesystems had a chance to commit changes for both parent and + * child * simultaneously making the following commit_metadata a + * noop. */ err2 = nfserrno(commit_metadata(fhp)); if (err2) @@ -1426,7 +1428,8 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, err = nfsd_create_setattr(rqstp, resfhp, iap); /* - * nfsd_setattr already committed the child (and possibly also the parent). + * nfsd_create_setattr already committed the child + * (and possibly also the parent). */ if (!err) err = nfserrno(commit_metadata(fhp));