From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <miklos@szeredi.hu>, <amir73il@gmail.com>
Cc: <linux-unionfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chengzhihao1@huawei.com>, <yukuai3@huawei.com>
Subject: [PATCH] ovl: nfs_export: Parse index inode's nlink when 'd_inode(lowerdentry)->i_nlink == 1'
Date: Fri, 6 Aug 2021 17:53:54 +0800 [thread overview]
Message-ID: <20210806095354.2336263-1-chengzhihao1@huawei.com> (raw)
For overlayfs mounted by "nfs_export=on", all files/directories will be
indexed regardless of whether 'nlink > 1' satisfies. Following process
may cause breaking hard links on copy up:
mkdir low upper work merge
touch low/file
mount -t overlay over
-oupperdir=upper,lowerdir=low,workdir=work,nfs_export=on merge
chmod +x merge/file
# Now nlink of upper/file's correspoding index file equals to 2,
and we have xattr "trusted.overlay.nlink=U-1" on upper/file
echo 3 > /proc/sys/vm/drop_caches
# merge/file's nlink changes to 2
For nfs_export enabled overlayfs, don't ignore parsing index inode's nlink
when 'd_inode(lowerdentry)->i_nlink == 1'.
Fixes: f168f1098dd9038 ("ovl: add support for "nfs_export" configuration")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
fs/overlayfs/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 5e828a1c98a8..75a61243371c 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -832,7 +832,8 @@ unsigned int ovl_get_nlink(struct ovl_fs *ofs, struct dentry *lowerdentry,
char buf[13];
int err;
- if (!lowerdentry || !upperdentry || d_inode(lowerdentry)->i_nlink == 1)
+ if (!lowerdentry || !upperdentry ||
+ (!ofs->config.nfs_export && d_inode(lowerdentry)->i_nlink == 1))
return fallback;
err = ovl_do_getxattr(ofs, upperdentry, OVL_XATTR_NLINK,
--
2.31.1
reply other threads:[~2021-08-06 9:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210806095354.2336263-1-chengzhihao1@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=amir73il@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.