From 8a22efa15b46d524577cac79da63cebca8e8307f Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Fri, 9 Mar 2018 15:51:02 +0200 Subject: ovl: do not try to reconnect a disconnected origin dentry On lookup of non directory, we try to decode the origin file handle stored in upper inode. The origin file handle is supposed to be decoded to a disconnected non-dir dentry, which is fine, because we only need the lower inode of a copy up origin. However, if the origin file handle somehow turns out to be a directory we pay the expensive cost of reconnecting the directory dentry, only to get a mismatch file type and drop the dentry. Optimize this case by explicitly opting out of reconnecting the dentry. Opting-out of reconnect is done by passing a NULL acceptable callback to exportfs_decode_fh(). While the case described above is a strange corner case that does not really need to be optimized, the API added for this optimization will be used by a following patch to optimize a more common case of decoding an overlayfs file handle. Signed-off-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/export.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/overlayfs/export.c') diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c index e688cf019460..15411350a7a1 100644 --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -685,7 +685,7 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, if (!ofs->upper_mnt) return ERR_PTR(-EACCES); - upper = ovl_decode_real_fh(fh, ofs->upper_mnt); + upper = ovl_decode_real_fh(fh, ofs->upper_mnt, true); if (IS_ERR_OR_NULL(upper)) return upper; @@ -735,7 +735,7 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, } /* Then lookup origin by fh */ - err = ovl_check_origin_fh(ofs, fh, NULL, &stack); + err = ovl_check_origin_fh(ofs, fh, true, NULL, &stack); if (err) { goto out_err; } else if (index) { -- cgit v1.2.3