Whamcloud - gitweb
LU-14326 osc: correctly update size/kms for fallocate 72/41272/2
authorBobi Jam <bobijam@whamcloud.com>
Fri, 15 Jan 2021 05:33:17 +0000 (13:33 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 22 Jan 2021 20:31:38 +0000 (20:31 +0000)
* fallocate chose oa->o_size for falloc_offset and o->o_blocks for
  falloc_end, but forgot to change attr->cat_size and attr->cat_kms
  to use sa_attr.lvb_size to update osc's lvb and kms if it expands
  the file's size.

  Other setattr IO uses @size (sa_falloc_offset in fallocate case) to
  update the lvb and kms.

* lock request extent for fallocate should be
  [sa_falloc_offset, sa_falloc_end)

* calculate sa_attr.lvb_size correctly for osc objects
  (lov_io_sub_inherit())

Test-Parameters: testlist=sanityn env=ONLY=16,COUNT=50000,ONLY_REPEAT=10
Test-Parameters: testlist=sanity-benchmark env=ONLY=fsx,COUNT=50000,ONLY_REPEAT=10
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Fixes: 48457868a02a ("LU-3606 fallocate: Implement fallocate preallocate operation")
Change-Id: I7dbed3bc6899a3db53284c8aac3cb9476e7958f5
Reviewed-on: https://review.whamcloud.com/41272
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/vvp_io.c
lustre/lov/lov_io.c
lustre/osc/osc_cache.c
lustre/osc/osc_io.c
lustre/osc/osc_object.c

index fc7872e..cb30a0d 100644 (file)
@@ -661,7 +661,7 @@ static int vvp_io_setattr_lock(const struct lu_env *env,
                        enqflags = CEF_DISCARD_DATA;
        } else if (cl_io_is_fallocate(io)) {
                lock_start = io->u.ci_setattr.sa_falloc_offset;
-               lock_end = lock_start + io->u.ci_setattr.sa_attr.lvb_size;
+               lock_end = io->u.ci_setattr.sa_falloc_end;
        } else {
                unsigned int valid = io->u.ci_setattr.sa_avalid;
 
index 7c52b99..6f561e7 100644 (file)
@@ -688,17 +688,16 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
                                        parent->u.ci_setattr.sa_parent_fid;
                /* For SETATTR(fallocate) pass the subtype to lower IO */
                io->u.ci_setattr.sa_subtype = parent->u.ci_setattr.sa_subtype;
-               if (cl_io_is_trunc(io)) {
+               if (cl_io_is_fallocate(io)) {
+                       io->u.ci_setattr.sa_falloc_offset = start;
+                       io->u.ci_setattr.sa_falloc_end = end;
+               }
+               if (cl_io_is_trunc(io) || cl_io_is_fallocate(io)) {
                        loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
 
                        new_size = lov_size_to_stripe(lsm, index, new_size,
                                                      stripe);
                        io->u.ci_setattr.sa_attr.lvb_size = new_size;
-               } else if (cl_io_is_fallocate(io)) {
-                       io->u.ci_setattr.sa_falloc_offset = start;
-                       io->u.ci_setattr.sa_falloc_end = end;
-                       io->u.ci_setattr.sa_attr.lvb_size =
-                               parent->u.ci_setattr.sa_attr.lvb_size;
                }
                lov_lsm2layout(lsm, lsm->lsm_entries[index],
                               &io->u.ci_setattr.sa_layout);
index 364a71f..7de0073 100644 (file)
@@ -1110,7 +1110,8 @@ static int osc_extent_make_ready(const struct lu_env *env,
         * the size of file. */
        if (!(last->oap_async_flags & ASYNC_COUNT_STABLE)) {
                int last_oap_count = osc_refresh_count(env, last, OBD_BRW_WRITE);
-               LASSERT(last_oap_count > 0);
+               LASSERTF(last_oap_count > 0,
+                        "last_oap_count %d\n", last_oap_count);
                LASSERT(last->oap_page_off + last_oap_count <= PAGE_SIZE);
                last->oap_count = last_oap_count;
                spin_lock(&last->oap_lock);
index 3bddf18..47e56a7 100644 (file)
@@ -574,8 +574,14 @@ static int osc_io_setattr_start(const struct lu_env *env,
                        unsigned int cl_valid = 0;
 
                        if (ia_avalid & ATTR_SIZE) {
-                               attr->cat_size = size;
-                               attr->cat_kms = size;
+                               if (io_is_falloc) {
+                                       attr->cat_size =
+                                             io->u.ci_setattr.sa_attr.lvb_size;
+                                       attr->cat_kms = attr->cat_size;
+                               } else {
+                                       attr->cat_size = size;
+                                       attr->cat_kms = size;
+                               }
                                cl_valid = (CAT_SIZE | CAT_KMS);
                        }
                        if (ia_avalid & ATTR_MTIME_SET) {
@@ -715,22 +721,17 @@ void osc_io_setattr_end(const struct lu_env *env,
        }
 
        if (cl_io_is_fallocate(io)) {
-               cl_object_attr_lock(obj);
-
-               /* update blocks */
-               if (oa->o_valid & OBD_MD_FLBLOCKS) {
-                       attr->cat_blocks = oa->o_blocks;
-                       cl_valid |= CAT_BLOCKS;
-               }
+               if (result == 0) {
+                       cl_object_attr_lock(obj);
+                       /* update blocks */
+                       if (oa->o_valid & OBD_MD_FLBLOCKS) {
+                               attr->cat_blocks = oa->o_blocks;
+                               cl_valid |= CAT_BLOCKS;
+                       }
 
-               /* update size */
-               if (oa->o_valid & OBD_MD_FLSIZE) {
-                       attr->cat_size = oa->o_size;
-                       cl_valid |= CAT_SIZE;
+                       cl_object_attr_update(env, obj, attr, cl_valid);
+                       cl_object_attr_unlock(obj);
                }
-
-               cl_object_attr_update(env, obj, attr, cl_valid);
-               cl_object_attr_unlock(obj);
        }
 }
 EXPORT_SYMBOL(osc_io_setattr_end);
index 27ef908..5c06f6e 100644 (file)
@@ -223,7 +223,9 @@ static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
                           lvb->lvb_atime, oinfo->loi_lvb.lvb_size,
                           oinfo->loi_lvb.lvb_blocks, oinfo->loi_lvb.lvb_ctime,
                           oinfo->loi_lvb.lvb_mtime, oinfo->loi_lvb.lvb_atime);
-               LASSERT(oinfo->loi_lvb.lvb_size >= oinfo->loi_kms);
+               LASSERTF(oinfo->loi_lvb.lvb_size >= oinfo->loi_kms,
+                        "lvb_size %#llx, loi_kms %#llx\n",
+                        oinfo->loi_lvb.lvb_size, oinfo->loi_kms);
 
                cl_object_attr_lock(&osc->oo_cl);
                memcpy(lvb, &oinfo->loi_lvb, sizeof(oinfo->loi_lvb));