Whamcloud - gitweb
LU-16026 llite: always enable remote subdir mount 35/48535/7
authorLai Siyao <lai.siyao@whamcloud.com>
Sun, 28 Aug 2022 19:33:29 +0000 (15:33 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 17 Jan 2023 14:25:27 +0000 (14:25 +0000)
For historical reason, ROOT is revalidated with IT_LOOKUP in
.permission to ensure permission is update to date because ROOT is
never looked up. But ROOT FID and layout is not changeable, it's
PERM lock that should be revalidated, i.e., revalidate with
IT_GETATTR instead of IT_LOOKUP.

Since PERM|UPDATE lock is on the MDT where object is located, client
can cache this lock, therefore remote subdir mount doesn't need to
lookup ROOT in each file access.

Deprecate mdt.*.enable_remote_subdir_mount.

Per http://review.whamcloud.com/19195, replace 'df' with 'lfs df' in
sanity 228b since the former doesn't support transparent recovery.

Add sanity 247h.

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I66f8ee347f6c01a8a154245b10a1d93539ea13b8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48535
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/file.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lproc.c
lustre/tests/sanity.sh

index 4993c04..c09a0b7 100644 (file)
@@ -5634,11 +5634,10 @@ int ll_inode_permission(struct user_namespace *mnt_userns, struct inode *inode,
 
        /*
         * as root inode are NOT getting validated in lookup operation,
-        * need to do it before permission check.
+        * need to revalidate PERM before permission check.
         */
-
        if (is_root_inode(inode)) {
-               rc = ll_inode_revalidate(inode->i_sb->s_root, IT_LOOKUP);
+               rc = ll_inode_revalidate(inode->i_sb->s_root, IT_GETATTR);
                if (rc)
                        RETURN(rc);
        }
index 91a3954..5b83a92 100644 (file)
@@ -313,8 +313,7 @@ static int mdt_lookup_fileset(struct mdt_thread_info *info, const char *fileset,
        struct lu_name *lname = &info->mti_name;
        const char *start = fileset;
        char *filename = info->mti_filename;
-       struct mdt_object *parent;
-       u32 mode;
+       struct mdt_object *obj;
        int rc = 0;
 
        LASSERT(!info->mti_cross_ref);
@@ -348,8 +347,7 @@ static int mdt_lookup_fileset(struct mdt_thread_info *info, const char *fileset,
                }
 
                /* reject .. as a path component */
-               if (lname->ln_namelen == 2 &&
-                   strncmp(s1, "..", 2) == 0) {
+               if (lname->ln_namelen == 2 && strncmp(s1, "..", 2) == 0) {
                        rc = -EINVAL;
                        break;
                }
@@ -358,39 +356,18 @@ static int mdt_lookup_fileset(struct mdt_thread_info *info, const char *fileset,
                filename[lname->ln_namelen] = '\0';
                lname->ln_name = filename;
 
-               parent = mdt_object_find(info->mti_env, mdt, fid);
-               if (IS_ERR(parent)) {
-                       rc = PTR_ERR(parent);
+               obj = mdt_object_find(info->mti_env, mdt, fid);
+               if (IS_ERR(obj)) {
+                       rc = PTR_ERR(obj);
                        break;
                }
                /* Only got the fid of this obj by name */
                fid_zero(fid);
-               rc = mdo_lookup(info->mti_env, mdt_object_child(parent), lname,
+               rc = mdo_lookup(info->mti_env, mdt_object_child(obj), lname,
                                fid, &info->mti_spec);
-               mdt_object_put(info->mti_env, parent);
-       }
-       if (!rc) {
-               parent = mdt_object_find(info->mti_env, mdt, fid);
-               if (IS_ERR(parent))
-                       rc = PTR_ERR(parent);
-               else {
-                       mode = lu_object_attr(&parent->mot_obj);
-                       if (!S_ISDIR(mode)) {
-                               rc = -ENOTDIR;
-                       } else if (mdt_is_remote_object(info, parent, parent)) {
-                               if (!mdt->mdt_enable_remote_subdir_mount) {
-                                       rc = -EREMOTE;
-                                       LCONSOLE_WARN("%s: subdir mount '%s' refused because 'enable_remote_subdir_mount=0': rc = %d\n",
-                                                     mdt_obd_name(mdt),
-                                                     fileset, rc);
-                               } else {
-                                       LCONSOLE_INFO("%s: subdir mount '%s' is remote and may be slow\n",
-                                                     mdt_obd_name(mdt),
-                                                     fileset);
-                               }
-                       }
-                       mdt_object_put(info->mti_env, parent);
-               }
+               if (!rc && !S_ISDIR(lu_object_attr(&obj->mot_obj)))
+                       rc = -ENOTDIR;
+               mdt_object_put(info->mti_env, obj);
        }
 
        return rc;
@@ -6004,7 +5981,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
        m->mdt_enable_remote_dir = 1;
        m->mdt_enable_remote_dir_gid = 0;
        m->mdt_enable_remote_rename = 1;
-       m->mdt_enable_remote_subdir_mount = 1;
        m->mdt_enable_striped_dir = 1;
        m->mdt_dir_restripe_nsonly = 1;
 
index 559138a..fe60e8d 100644 (file)
@@ -306,9 +306,7 @@ struct mdt_device {
                                   mdt_readonly:1,
                                   mdt_skip_lfsck:1,
                                   /* dir restripe migrate dirent only */
-                                  mdt_dir_restripe_nsonly:1,
-                                  /* subdirectory mount of remote dir */
-                                  mdt_enable_remote_subdir_mount:1;
+                                  mdt_dir_restripe_nsonly:1;
 
                                   /* user with gid can create remote/striped
                                    * dir, and set default dir stripe */
index 601a199..6e6cd46 100644 (file)
@@ -1353,12 +1353,7 @@ static ssize_t enable_remote_subdir_mount_show(struct kobject *kobj,
                                               struct attribute *attr,
                                               char *buf)
 {
-       struct obd_device *obd = container_of(kobj, struct obd_device,
-                                             obd_kset.kobj);
-       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-
-       return scnprintf(buf, PAGE_SIZE, "%u\n",
-                        mdt->mdt_enable_remote_subdir_mount);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", 1);
 }
 
 static ssize_t enable_remote_subdir_mount_store(struct kobject *kobj,
@@ -1366,17 +1361,7 @@ static ssize_t enable_remote_subdir_mount_store(struct kobject *kobj,
                                                const char *buffer,
                                                size_t count)
 {
-       struct obd_device *obd = container_of(kobj, struct obd_device,
-                                             obd_kset.kobj);
-       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-       bool val;
-       int rc;
-
-       rc = kstrtobool(buffer, &val);
-       if (rc)
-               return rc;
-
-       mdt->mdt_enable_remote_subdir_mount = val;
+       LCONSOLE_WARN("enable_remote_subdir_mount is deprecated, it's always enabled.\n");
        return count;
 }
 LUSTRE_RW_ATTR(enable_remote_subdir_mount);
index 0cfe944..25762f1 100755 (executable)
@@ -20093,7 +20093,7 @@ test_228b() {
        start $SINGLEMDS $(facet_device $SINGLEMDS) $MDS_MOUNT_OPTS ||
                error "Fail to start MDT."
 
-       df $MOUNT || error "Fail to df."
+       client_up || error "Fail to df."
        # Create new files, idle OI blocks should be reused.
        createmany -o $myDIR/t- 2000
        do_facet $SINGLEMDS sync
@@ -21737,13 +21737,10 @@ test_247e() {
 run_test 247e "mount .. as fileset"
 
 test_247f() {
-       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
-       [ $MDS1_VERSION -lt $(version_code 2.13.52) ] &&
-               skip "Need at least version 2.13.52"
-       [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
-               skip "Need at least version 2.14.50"
-       lctl get_param -n mdc.$FSNAME-MDT0000*.import |
-               grep -q subtree ||
+       (( $MDSCOUNT > 1 )) || skip_env "needs >= 2 MDTs"
+       (( $MDS1_VERSION >= $(version_code 2.14.50.162) )) ||
+               skip "Need at least version 2.14.50.162"
+       lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
                skip "Fileset feature is not supported"
 
        mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
@@ -21761,67 +21758,71 @@ test_247f() {
        stack_trap "rmdir $submount"
 
        local dir
-       local stat
        local fileset=$FILESET
        local mdts=$(comma_list $(mdts_nodes))
 
-       stat=$(do_facet mds1 $LCTL get_param -n \
-               mdt.*MDT0000.enable_remote_subdir_mount)
-       stack_trap "do_nodes $mdts $LCTL set_param \
-               mdt.*.enable_remote_subdir_mount=$stat"
-
-       do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=0"
-       stack_trap "umount_client $submount"
-       FILESET="$fileset/$tdir/remote" mount_client $submount &&
-               error "mount remote dir $dir should fail"
-
-       for dir in $tdir/remote/subdir $tdir/striped $tdir/striped/subdir \
-               $tdir/striped/. ; do
+       do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
+       for dir in $tdir/remote $tdir/remote/subdir $tdir/striped \
+               $tdir/striped/subdir $tdir/striped/.; do
                FILESET="$fileset/$dir" mount_client $submount ||
                        error "mount $dir failed"
                umount_client $submount
        done
-
-       do_nodes $mdts "$LCTL set_param mdt.*.enable_remote_subdir_mount=1"
-       FILESET="$fileset/$tdir/remote" mount_client $submount ||
-               error "mount $tdir/remote failed"
 }
 run_test 247f "mount striped or remote directory as fileset"
 
-test_247g() {
-       [ $MDSCOUNT -lt 4 ] && skip_env "needs >= 4 MDTs"
-       [ $CLIENT_VERSION -lt $(version_code 2.14.50) ] &&
-               skip "Need at least version 2.14.50"
-
-       $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
-               error "mkdir $tdir failed"
-       touch $DIR/$tdir/$tfile || error "touch $tfile failed"
+test_subdir_mount_lock()
+{
+       local testdir=$1
+       local submount=${MOUNT}_$(basename $testdir)
 
-       local submount=${MOUNT}_$tdir
+       touch $DIR/$testdir/$tfile || error "touch $tfile failed"
 
        mkdir -p $submount || error "mkdir $submount failed"
        stack_trap "rmdir $submount"
 
-       FILESET="$fileset/$tdir" mount_client $submount ||
-               error "mount $dir failed"
+       FILESET="$fileset/$testdir" mount_client $submount ||
+               error "mount $FILESET failed"
        stack_trap "umount $submount"
 
        local mdts=$(comma_list $(mdts_nodes))
 
        local nrpcs
 
-       stat $submount > /dev/null
+       stat $submount > /dev/null || error "stat $submount failed"
        cancel_lru_locks $MDC
-       stat $submount > /dev/null
-       stat $submount/$tfile > /dev/null
+       stat $submount > /dev/null || error "stat $submount failed"
+       stat $submount/$tfile > /dev/null || error "stat $tfile failed"
        do_nodes $mdts "$LCTL set_param mdt.*.md_stats=clear > /dev/null"
-       stat $submount/$tfile > /dev/null
+       stat $submount/$tfile > /dev/null || error "stat $tfile failed"
        nrpcs=$(do_nodes $mdts "lctl get_param -n mdt.*.md_stats" |
                awk '/getattr/ {sum += $2} END {print sum}')
 
        [ -z "$nrpcs" ] || error "$nrpcs extra getattr sent"
 }
-run_test 247g "mount striped directory as fileset caches ROOT lookup lock"
+
+test_247g() {
+       (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
+
+       $LFS mkdir -i 0 -c 4 -H fnv_1a_64 $DIR/$tdir ||
+               error "mkdir $tdir failed"
+       test_subdir_mount_lock $tdir
+}
+run_test 247g "striped directory submount revalidate ROOT from cache"
+
+test_247h() {
+       (( $MDSCOUNT > 1 )) || skip_env "needs > 1 MDTs"
+       (( $MDS1_VERSION >= $(version_code 2.15.51) )) ||
+               skip "Need MDS version at least 2.15.51"
+
+       $LFS mkdir -i 1 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
+       test_subdir_mount_lock $tdir
+       mkdir_on_mdt -i 0 $DIR/$tdir/$tdir.0 || error "mkdir $tdir.0 failed"
+       mkdir_on_mdt -i 1 $DIR/$tdir/$tdir.0/$tdir.1 ||
+               error "mkdir $tdir.1 failed"
+       test_subdir_mount_lock $tdir/$tdir.0/$tdir.1
+}
+run_test 247h "remote directory submount revalidate ROOT from cache"
 
 test_248a() {
        local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)