From patchwork Tue May 29 14:46:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435779 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 A7D4F602BF for ; Tue, 29 May 2018 14:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D7A9286DD for ; Tue, 29 May 2018 14:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B33E2878F; Tue, 29 May 2018 14:50:40 +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 5FD5828773 for ; Tue, 29 May 2018 14:50:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935495AbeE2Ouf (ORCPT ); Tue, 29 May 2018 10:50:35 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:35769 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936643AbeE2Oqm (ORCPT ); Tue, 29 May 2018 10:46:42 -0400 Received: by mail-wm0-f50.google.com with SMTP id o78-v6so41498434wmg.0 for ; Tue, 29 May 2018 07:46:41 -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=qAcMfB8axqtMPyfvE/mHGgT2K12GWLuk3/aVO2RHtQM=; b=D2uqt5wO8aAeMNGE0Tbsu5+lJGHOzD4A0Lft9//h3BcXHm0k/ZiKwZF3Hu53+JeNn4 OZ4mec65jm4dkjEiF244kv1wdxSXyWxqVJWvSsPt9sn3rIQBEIbCc4Fi2R04mqNYe3yN cVrey/5zhARNzbuIXQEvIvg91+e3+Z4Y6wLTIH7jg1f0/uUcDKSOMekHftvbaRoLRvN3 Qd2MHFtIktxbM0xgHNV4xkZAVsm48xDDLuNou8JXN6B46DidM2f+JUStvhrDOzr16f+s tDtCS8ndrDePYCUtN4Raw3VZiUqYMl1qi1CsHqHwlBtZa0OkkqHOGgN740zDdkAeW1Ww wz2Q== X-Gm-Message-State: ALKqPwcGDSCR94f+xZbtSA5NGrOXyfc3Wo/HagdIycpNIIbDbuFiMamZ aC3hRbf1DhfQ2cMy6hDm7hcrOEWifdQ= X-Google-Smtp-Source: ADUXVKIc5vRa4GSRs4tbzMx2GdWTP2+S3dh/ckEr0aamz/tL7pB3tV2tGUWiLcgYjadjiuwb1I6W7Q== X-Received: by 2002:a1c:d106:: with SMTP id i6-v6mr6520753wmg.1.1527605200980; Tue, 29 May 2018 07:46:40 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:40 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/28] ovl: Do not set dentry type ORIGIN for broken hardlinks Date: Tue, 29 May 2018 16:46:05 +0200 Message-Id: <20180529144612.16675-22-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 If a dentry has copy up origin, we set flag OVL_PATH_ORIGIN. So far this decision was easy that we had to check only for oe->numlower and if it is non-zero, we knew there is copy up origin. (For non-dir we installed origin dentry in lowerstack[0]). But we don't create ORGIN xattr for broken hardlinks (index=off). And with metacopy feature it is possible that we will install lowerstack[0] but ORIGIN xattr is not there. It is data dentry of upper metacopy dentry which has been found using regular name based lookup or using REDIRECT. So with addition of this new case, just presence of oe->numlower is not sufficient to guarantee that ORIGIN xattr is present. So to differentiate between two cases, look at OVL_CONST_INO flag. If this flag is set and upperdentry is there, that means it can be marked as type ORIGIN. OVL_CONST_INO is not set if lower hardlink is broken or will be broken over copy up. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 61ace2de3019..1aa9e0c5a327 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -133,7 +133,8 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry) * Non-dir dentry can hold lower dentry of its copy up origin. */ if (oe->numlower) { - type |= __OVL_PATH_ORIGIN; + if (ovl_test_flag(OVL_CONST_INO, d_inode(dentry))) + type |= __OVL_PATH_ORIGIN; if (d_is_dir(dentry) || !ovl_has_upperdata(d_inode(dentry))) type |= __OVL_PATH_MERGE;