Whamcloud - gitweb
LU-15381 hsm: update size upon completion of data version 35/45935/4
authorQian Yingjin <qian@ddn.com>
Fri, 17 Dec 2021 08:53:37 +0000 (16:53 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Jan 2022 05:16:26 +0000 (05:16 +0000)
We found a HSM retore followed by a HSM release will set the
file size with 0 wrongly during the tests.
The reason is that the file size and blocks information is
incorrect obtained via @ll_merger_attr().
The data version operation will flush dirty pages from all
clients, the size and blocks information returns from the Lustre
OST is correct.
In this patch, we update the size and block attributes for a file
upon the completion of the data version operation accordingly.
By this way, HSM release will set the size and blocks information
correctly after data version ioctl operation.

Add sanity-hsm test_261.

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: Ifdbf6b58ecd00dc9677a2328438ef68529b72882
Reviewed-on: https://review.whamcloud.com/45935
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/file.c
lustre/osc/osc_io.c
lustre/tests/sanity-hsm.sh

index aefead0..8f746ec 100644 (file)
@@ -2162,6 +2162,7 @@ struct ioc_data_version {
 enum ioc_data_version_flags {
        LL_DV_RD_FLUSH  = (1 << 0), /* Flush dirty pages from clients */
        LL_DV_WR_FLUSH  = (1 << 1), /* Flush all caching pages from clients */
+       LL_DV_SZ_UPDATE = (1 << 2), /* Update the file size on the client */
 };
 
 #ifndef offsetof
index 4b19afb..c06583f 100644 (file)
@@ -2895,8 +2895,9 @@ int ll_hsm_release(struct inode *inode)
        struct lu_env *env;
        struct obd_client_handle *och = NULL;
        __u64 data_version = 0;
-       int rc;
        __u16 refcheck;
+       int rc;
+
        ENTRY;
 
        CDEBUG(D_INODE, "%s: Releasing file "DFID".\n",
@@ -2908,7 +2909,8 @@ int ll_hsm_release(struct inode *inode)
                GOTO(out, rc = PTR_ERR(och));
 
        /* Grab latest data_version and [am]time values */
-       rc = ll_data_version(inode, &data_version, LL_DV_WR_FLUSH);
+       rc = ll_data_version(inode, &data_version,
+                            LL_DV_WR_FLUSH | LL_DV_SZ_UPDATE);
        if (rc != 0)
                GOTO(out, rc);
 
index f74bd3f..e4bd273 100644 (file)
@@ -842,8 +842,12 @@ static void osc_io_data_version_end(const struct lu_env *env,
                                    const struct cl_io_slice *slice)
 {
        struct cl_data_version_io *dv = &slice->cis_io->u.ci_data_version;
-       struct osc_io           *oio    = cl2osc_io(env, slice);
+       struct osc_io *oio = cl2osc_io(env, slice);
+       struct cl_object *obj = slice->cis_obj;
        struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
+       struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+       struct obdo *oa = &oio->oi_oa;
+       unsigned int cl_valid = 0;
 
        ENTRY;
        wait_for_completion(&cbargs->opc_sync);
@@ -852,14 +856,30 @@ static void osc_io_data_version_end(const struct lu_env *env,
                slice->cis_io->ci_result = cbargs->opc_rc;
        } else {
                slice->cis_io->ci_result = 0;
-               if (!(oio->oi_oa.o_valid &
+               if (!(oa->o_valid &
                      (OBD_MD_LAYOUT_VERSION | OBD_MD_FLDATAVERSION)))
                        slice->cis_io->ci_result = -ENOTSUPP;
 
-               if (oio->oi_oa.o_valid & OBD_MD_LAYOUT_VERSION)
-                       dv->dv_layout_version = oio->oi_oa.o_layout_version;
-               if (oio->oi_oa.o_valid & OBD_MD_FLDATAVERSION)
-                       dv->dv_data_version = oio->oi_oa.o_data_version;
+               if (oa->o_valid & OBD_MD_LAYOUT_VERSION)
+                       dv->dv_layout_version = oa->o_layout_version;
+               if (oa->o_valid & OBD_MD_FLDATAVERSION)
+                       dv->dv_data_version = oa->o_data_version;
+
+               if (dv->dv_flags & LL_DV_SZ_UPDATE) {
+                       if (oa->o_valid & OBD_MD_FLSIZE) {
+                               attr->cat_size = oa->o_size;
+                               cl_valid |= CAT_SIZE;
+                       }
+
+                       if (oa->o_valid & OBD_MD_FLBLOCKS) {
+                               attr->cat_blocks = oa->o_blocks;
+                               cl_valid |= CAT_BLOCKS;
+                       }
+
+                       cl_object_attr_lock(obj);
+                       cl_object_attr_update(env, obj, attr, cl_valid);
+                       cl_object_attr_unlock(obj);
+               }
        }
 
        EXIT;
index d30bb2c..482956b 100755 (executable)
@@ -4885,6 +4885,36 @@ test_260c()
 }
 run_test 260c "Requests are not reordered on the 'hot' path of the coordinator"
 
+test_261() {
+       local file=$DIR/$tdir/$tfile
+       local size
+       local fid
+
+       copytool setup
+       mkdir_on_mdt0 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+
+       dd if=/dev/zero of=$file bs=4k count=2 || error "Write $file failed"
+       fid=$(path2fid $file)
+       $LFS hsm_archive --archive $HSM_ARCHIVE_NUMBER $file
+       wait_request_state $fid ARCHIVE SUCCEED
+
+       $LFS hsm_state $file
+       $LFS hsm_release $file
+       $LFS hsm_restore $file
+       wait_request_state $fid RESTORE SUCCEED
+       $LFS hsm_release $file
+       size=$(stat -c %s $file)
+       [[ $size == 8192 ]] || error "Size after HSM release: $size"
+
+       $LFS hsm_release $file
+       $LFS hsm_restore $file
+       $LFS hsm_release $file
+       size=$(stat -c %s $file)
+       [[ $size == 8192 ]] || error "Size after HSM release: $size"
+       $LFS hsm_state $file
+}
+run_test 261 "Report 0 bytes size after HSM release"
+
 test_300() {
        [ "$CLIENTONLY" ] && skip "CLIENTONLY mode" && return