From eb421b77271d99f737680c31a963e837dc8fe6bf Mon Sep 17 00:00:00 2001 From: tl Date: Sun, 22 Sep 2024 09:20:07 +0800 Subject: [PATCH] sharefs lookup and fixup Signed-off-by: tl --- fs/sharefs/lookup.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/fs/sharefs/lookup.c b/fs/sharefs/lookup.c index 0b0c30ef46f1..718b0c6bb79c 100644 --- a/fs/sharefs/lookup.c +++ b/fs/sharefs/lookup.c @@ -6,9 +6,10 @@ * Copyright (c) 2009 Shrikar Archak * Copyright (c) 2003-2022 Stony Brook University * Copyright (c) 2003-2022 The Research Foundation of SUNY - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. */ +#include #include "sharefs.h" #include "authentication.h" @@ -207,7 +208,6 @@ static struct dentry *__sharefs_lookup(struct dentry *dentry, struct dentry *lower_dentry; const char *name; struct path lower_path; - struct qstr this; struct dentry *ret_dentry = NULL; /* must initialize dentry operations */ @@ -244,29 +244,15 @@ static struct dentry *__sharefs_lookup(struct dentry *dentry, if (err && err != -ENOENT) goto out; - /* instantiate a new negative dentry */ - this.name = name; - this.len = strlen(name); - this.hash = full_name_hash(lower_dir_dentry, this.name, this.len); - lower_dentry = d_lookup(lower_dir_dentry, &this); - if (lower_dentry) - goto setup_lower; - - lower_dentry = d_alloc(lower_dir_dentry, &this); - if (!lower_dentry) { - err = -ENOMEM; + lower_dentry = lookup_one_len_unlocked(name, lower_parent_path->dentry, + dentry->d_name.len); + if(IS_ERR(lower_dentry)) { + err = PTR_ERR(lower_dentry); + sharefs_err("lookup_one_len_unlocked error:%d", err); + ret_dentry = lower_dentry; goto out; } - /* - * Calling ->lookup instead of d_add will give the lower fs a chance - * to allocate the d_fsdata field but will still instantiate and hash the - * lower_dentry. Without this, sharefs could not stack on top of itself. - */ - d_inode(lower_dir_dentry)->i_op->lookup(d_inode(lower_dir_dentry), - lower_dentry, flags); - -setup_lower: lower_path.dentry = lower_dentry; lower_path.mnt = mntget(lower_dir_mnt); sharefs_set_lower_path(dentry, &lower_path); @@ -291,6 +277,7 @@ struct dentry *sharefs_lookup(struct inode *dir, struct dentry *dentry, int err; struct dentry *ret, *parent; struct path lower_parent_path; + struct super_block *sb = dentry->d_sb; #ifdef CONFIG_SHAREFS_SUPPORT_OVERRIDE const struct cred *saved_cred = NULL; __u16 permission; @@ -326,6 +313,9 @@ struct dentry *sharefs_lookup(struct inode *dir, struct dentry *dentry, /* update parent directory's atime */ fsstack_copy_attr_atime(d_inode(parent), sharefs_lower_inode(d_inode(parent))); + if((SHAREFS_SB(sb)->override) || (SHAREFS_SB(sb)->override_support_delete)) { + goto out; + } fixup_perm_from_level(d_inode(parent), dentry); out: #ifdef CONFIG_SHAREFS_SUPPORT_OVERRIDE -- Gitee