Whamcloud - gitweb
LU-11466 mdt: Skip SOM xattr update for DoM-only files 31/33331/11
authorQian Yingjin <qian@ddn.com>
Wed, 10 Oct 2018 07:55:54 +0000 (15:55 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 27 Nov 2018 04:56:31 +0000 (04:56 +0000)
When scan the MDT image, DoM-only file can be specialized handled,
the size and blocks can be got directly from the inode on MDT, no
need SOM xattr anymore.
Thus, there is no need to store the SOM xattr for DoM-only files.

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I0f871cde38fc846460dd1b6f92509dee9ea90bfc
Reviewed-on: https://review.whamcloud.com/33331
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_som.c
lustre/tests/sanity.sh
lustre/utils/lfs.c

index 8636c61..3eebe03 100644 (file)
@@ -196,23 +196,30 @@ int mdt_lsom_update(struct mdt_thread_info *info,
        if (rc)
                GOTO(out_lock, rc);
 
        if (rc)
                GOTO(out_lock, rc);
 
-       rc = mo_xattr_get(info->mti_env, mdt_object_child(o), &LU_BUF_NULL,
-                         XATTR_NAME_LOV);
-       if (rc < 0 && rc != -ENODATA)
-               GOTO(out_lock, rc);
-       else if (rc > 0) /* has LOV EA*/
-               tmp_ma->ma_valid |= MA_LOV;
+       /**
+        * If mti_big_lmm_used is set, it indicates that mti_big_lmm
+        * should contain valid LOV EA data, and can be used directly.
+        */
+       if (!info->mti_big_lmm_used) {
+               rc = mdt_big_xattr_get(info, o, XATTR_NAME_LOV);
+               if (rc < 0 && rc != -ENODATA)
+                       GOTO(out_lock, rc);
+
+               /* No LOV EA */
+               if (rc == -ENODATA)
+                       GOTO(out_lock, rc = 0);
+
+               rc = 0;
+       }
 
 
-       rc = 0;
        /**
         * Check if a Lazy Size-on-MDS update is needed. Skip the
        /**
         * Check if a Lazy Size-on-MDS update is needed. Skip the
-        * file with no LOV EA or unlink files.
+        * file with no LOV EA, unlink files or DoM-only file.
         * MDS only updates LSOM of the file if the size or block
         * size is being increased or the file is being truncated.
         */
         * MDS only updates LSOM of the file if the size or block
         * size is being increased or the file is being truncated.
         */
-       if ((tmp_ma->ma_valid & MA_LOV) &&
-           !(tmp_ma->ma_valid & MA_INODE &&
-             tmp_ma->ma_attr.la_nlink == 0)) {
+       if (mdt_lmm_dom_entry(info->mti_big_lmm) != LMM_DOM_ONLY &&
+           !(tmp_ma->ma_valid & MA_INODE && tmp_ma->ma_attr.la_nlink == 0)) {
                __u64 size;
                __u64 blocks;
                bool changed = false;
                __u64 size;
                __u64 blocks;
                bool changed = false;
index 7e9c572..3c7e54e 100755 (executable)
@@ -19994,6 +19994,33 @@ test_808() {
 }
 run_test 808 "Check trusted.som xattr not logged in Changelogs"
 
 }
 run_test 808 "Check trusted.som xattr not logged in Changelogs"
 
+check_som_nodata()
+{
+       $LFS getsom $1
+       [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
+}
+
+test_809() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
+               skip "Need MDS version at least 2.11.56" && return
+
+       $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
+               error "failed to create DoM-only file $DIR/$tfile"
+       touch $DIR/$tfile || error "touch $tfile failed"
+       check_som_nodata $DIR/$tfile
+
+       dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
+               error "write $tfile failed"
+       check_som_nodata $DIR/$tfile
+
+       $TRUNCATE $DIR/$tfile 1234
+       check_som_nodata $DIR/$tfile
+
+       $TRUNCATE $DIR/$tfile 4097
+       check_som_nodata $DIR/$file
+}
+run_test 809 "Verify no SOM xattr store for DoM-only files"
+
 #
 # tests that do cleanup/setup should be run at the end
 #
 #
 # tests that do cleanup/setup should be run at the end
 #
index 885c9b7..57bc998 100644 (file)
@@ -9447,8 +9447,9 @@ static int lfs_getsom(int argc, char **argv)
        attrs = (void *)buf;
        rc = lgetxattr(path, "trusted.som", attrs, sizeof(buf));
        if (rc < 0) {
        attrs = (void *)buf;
        rc = lgetxattr(path, "trusted.som", attrs, sizeof(buf));
        if (rc < 0) {
-               fprintf(stderr, "%s failed to get som xattr: %s\n", argv[0],
-                       strerror(-rc));
+               rc = -errno;
+               fprintf(stderr, "%s failed to get som xattr: %s (%d)\n",
+                       argv[0], strerror(errno), errno);
                return rc;
        }
 
                return rc;
        }