From patchwork Tue May 29 14:45:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435919 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 BD9D960327 for ; Tue, 29 May 2018 15:03:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F2A9286BE for ; Tue, 29 May 2018 15:03:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C171287E9; Tue, 29 May 2018 15:03: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=unavailable 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 DCFE0286BE for ; Tue, 29 May 2018 15:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935214AbeE2PCo (ORCPT ); Tue, 29 May 2018 11:02:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36670 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935483AbeE2OqU (ORCPT ); Tue, 29 May 2018 10:46:20 -0400 Received: by mail-wm0-f68.google.com with SMTP id v131-v6so22153451wma.1 for ; Tue, 29 May 2018 07:46:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f8D4Xq6UXXeL7YuDKkjCf2o6j8CF+Y3JW48arhZvFX4=; b=CYZg1WW5gEOnHoMgXMnp4UDUqRq+9UMkYk1IAqaigYrIv4ZwMCVI+bqB7tQRz/hL+3 /Jk37/ooZu+ilh2DWW+NC7m3SppYd2iI9kqX30vmYa+5H1B9s3ENGJ9EYjmDuciTMVL1 /8goU7TXTSSfnMrKgFYGA8swSx6sH6J3Nkh2dZ38WeXsl+McS9jLrtlAnmjo9X86cL4W Nkfab+waZAFqMAV32f8MHrCmlhL5bLAF1XdARXY5bi6tEf+019VTDTmcd+QRlQAtiyxR JzgqyOlf/SFHVGGlksT3OJ9S0RNaISUVtwawtGhGyreZ1niQKNRMGZTLTiKNdwsvsMOp trEA== X-Gm-Message-State: ALKqPwcSETMBmOmGz44GuCVKteinh1PbRtHH2M02gxAh8V4w21b70EY8 FGYy1nuf3DIfZ4ZmthUsT8r+0g== X-Google-Smtp-Source: ADUXVKJmXG3F9bsc1hr6C/gqsaeNFRr+EyEw1iS+I860jrjDNhsPTDkHUiQofxaYZAYLjNQsSOHefw== X-Received: by 2002:a1c:6503:: with SMTP id z3-v6mr10529631wmb.11.1527605179308; Tue, 29 May 2018 07:46:19 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id n71-v6sm20942227wmi.14.2018.05.29.07.46.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:18 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/28] ovl: During copy up, first copy up metadata and then data Date: Tue, 29 May 2018 16:45:48 +0200 Message-Id: <20180529144612.16675-5-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144612.16675-1-mszeredi@redhat.com> References: <20180529144612.16675-1-mszeredi@redhat.com> 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: Vivek Goyal Just a little re-ordering of code. This helps with next patch where after copying up metadata, we skip data copying step, if needed. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/copy_up.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 91b3b668482b..c072a4c0cf08 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -490,28 +490,10 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) { int err; - if (S_ISREG(c->stat.mode)) { - struct path upperpath; - - ovl_path_upper(c->dentry, &upperpath); - BUG_ON(upperpath.dentry != NULL); - upperpath.dentry = temp; - - err = ovl_copy_up_data(&c->lowerpath, &upperpath, c->stat.size); - if (err) - return err; - } - err = ovl_copy_xattr(c->lowerpath.dentry, temp); if (err) return err; - inode_lock(temp->d_inode); - err = ovl_set_attr(temp, &c->stat); - inode_unlock(temp->d_inode); - if (err) - return err; - /* * Store identifier of lower inode in upper inode xattr to * allow lookup of the copy up origin inode. @@ -525,7 +507,23 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) return err; } - return 0; + if (S_ISREG(c->stat.mode)) { + struct path upperpath; + + ovl_path_upper(c->dentry, &upperpath); + BUG_ON(upperpath.dentry != NULL); + upperpath.dentry = temp; + + err = ovl_copy_up_data(&c->lowerpath, &upperpath, c->stat.size); + if (err) + return err; + } + + inode_lock(temp->d_inode); + err = ovl_set_attr(temp, &c->stat); + inode_unlock(temp->d_inode); + + return err; } static int ovl_copy_up_locked(struct ovl_copy_up_ctx *c)