Whamcloud - gitweb
LU-17261 lov: unlink can handle bogus striping 44/54544/12
authorAlex Zhuravlev <bzzz@whamcloud.com>
Sat, 23 Mar 2024 17:13:32 +0000 (20:13 +0300)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Apr 2024 15:37:57 +0000 (15:37 +0000)
Allow removing a file which has uninitialized OST objects in the
layout, possibly because LFSCK reconnected an orphan object back
into a mirrored file after the mirror had been deleted.

Don't wait and retry to access the bogus OST or MDT index in this
case, because the target will never appear, so waiting is futile.

Test-Parameters: testlist=sanity-flr,sanity-flr,sanity-flr,sanity-flr
Fixes: 94a4663db9 ("LU-17334 lmv: handle object created on newly added MDT")
Fixes: f35f897ec8 ("LU-17334 lov: handle object created on newly added OST")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I90b97c0e2d560d71b2a4c32a47fcfd7ae4e5535d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54544
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/lmv/lmv_obd.c
lustre/lov/lov_ea.c
lustre/tests/sanity-flr.sh

index 74b5bc4..ab1d9e3 100644 (file)
@@ -159,6 +159,10 @@ retry:
                     "%s: MDT index %u/%u not configured\n" :
                     "%s: MDT index %u more than MDT count %u\n",
                     obd->obd_name, index, lmv->lmv_mdt_count);
+
+       if (index >= LOV_V1_INSANE_STRIPE_COUNT)
+               return NULL;
+
        if (now > next_print) {
                LCONSOLE_INFO("%s: wait %ds while client connects to new MDT\n",
                              obd->obd_name, (int)(retry_limit - now));
index c9dfe73..a1ccd9d 100644 (file)
@@ -276,7 +276,7 @@ lsme_unpack(struct lov_obd *lov, struct lov_mds_md *lmm, size_t buf_size,
                        continue;
 
 retry_new_ost:
-               if (unlikely(loi->loi_ost_idx >= lov->desc.ld_tgt_count ||
+               if (unlikely((u32)loi->loi_ost_idx >= lov->desc.ld_tgt_count ||
                             !(ltd = lov->lov_tgts[loi->loi_ost_idx]))) {
                        time64_t now = ktime_get_seconds();
 
@@ -292,11 +292,15 @@ retry_new_ost:
 
                        /* log debug every loop, just to see it is trying */
                        CDEBUG_LIMIT(level,
-                               loi->loi_ost_idx < lov->desc.ld_tgt_count ?
+                               (u32)loi->loi_ost_idx < lov->desc.ld_tgt_count ?
                                "%s: FID "DOSTID" OST index %d/%u missing\n" :
                                "%s: FID "DOSTID" OST index %d more than OST count %u\n",
                                lov->desc.ld_uuid.uuid, POSTID(&loi->loi_oi),
                                loi->loi_ost_idx, lov->desc.ld_tgt_count);
+
+                       if ((u32)loi->loi_ost_idx >= LOV_V1_INSANE_STRIPE_COUNT)
+                               GOTO(out_lsme, rc = -EINVAL);
+
                        if (now > next_print) {
                                LCONSOLE_INFO("%s: wait %ds while client connects to new OST\n",
                                              lov->desc.ld_uuid.uuid,
index 26285ca..9c6c2cb 100644 (file)
@@ -4454,6 +4454,42 @@ test_210a() {
 }
 run_test 210a "handle broken mirrored lovea"
 
+test_210b() {
+       local tf=$DIR/$tfile
+       local after
+       local mirrorred
+       local before
+
+       [ "$FSTYPE" != "zfs" ] || skip "ZFS file number is not accurate"
+
+       stack_trap "rm -f $tf"
+
+       # XXX: how to avoid precreate
+       wait_delete_completed
+       $LFS df -i | grep OST
+       before=$($LFS df -i|grep OST|awk '{sum=sum+$3}END{print sum}')
+       echo "before file creation: $before"
+       $LFS setstripe -c 2 $tf || error "can't create file"
+       dd if=/dev/zero of=$tf bs=1M count=1 || error "can't dd"
+
+#define OBD_FAIL_LOV_INVALID_OSTIDX                0x1428
+       do_facet mds1 "$LCTL set_param fail_loc=0x1428"
+       $LFS mirror extend -N $tf || error "can't mirror"
+       $LFS df -i | grep OST
+       mirrored=$($LFS df -i|grep OST|awk '{sum=sum+$3}END{print sum}')
+       echo "after mirror: $mirrored"
+
+       rm $tf || error "can't remove"
+       [[ -f $tf ]] && error "rm failed"
+       wait_delete_completed
+
+       $LFS df -i | grep OST
+       after=$($LFS df -i|grep OST|awk '{sum=sum+$3}END{print sum}')
+       echo "after rm: $after"
+       (( after < before )) || error "something went wrong with unlink"
+}
+run_test 210b "handle broken mirrored lovea (unlink)"
+
 complete_test $SECONDS
 check_and_cleanup_lustre
 exit_status