Whamcloud - gitweb
LU-17923 lod: update layout ver for mirror merge/split 88/55388/16
authorBobi Jam <bobijam@whamcloud.com>
Tue, 11 Jun 2024 09:17:02 +0000 (17:17 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 2 Jan 2025 20:40:20 +0000 (20:40 +0000)
In mirror extend/split, mdd_xattr_merge() and mdd_xattr_split() will
call mdd_object_pfid_replace() to update filter_fid for OST objects,
so we can update its layout version there.

This patch adds filter_fid::ff_layout_version in
lod_obj_stripe_replace_parent_fid_cb().

This patch adds ost_fid2_objpath() in test framework to derive OST
object path from its fid.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I68aca0e1f29c8e2800a28cfd3d630721ef869082
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55388
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/lod/lod_object.c
lustre/tests/sanity-flr.sh
lustre/tests/sanity-sec.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 95b8b55..edf893b 100644 (file)
@@ -2632,6 +2632,7 @@ lod_obj_stripe_replace_parent_fid_cb(const struct lu_env *env,
        ff->ff_layout.ol_comp_id = comp->llc_id;
        ff->ff_layout.ol_comp_start = comp->llc_extent.e_start;
        ff->ff_layout.ol_comp_end = comp->llc_extent.e_end;
+       ff->ff_layout_version = lo->ldo_layout_gen;
        filter_fid_cpu_to_le(ff, ff, sizeof(*ff));
 
        if (data->locd_declare)
@@ -3370,7 +3371,6 @@ static int lod_declare_layout_merge(const struct lu_env *env,
                                    struct thandle *th)
 {
        struct lod_thread_info *info = lod_env_info(env);
-       struct lu_attr *layout_attr = &info->lti_layout_attr;
        struct lu_buf *buf = &info->lti_buf;
        struct lod_object *lo = lod_dt_obj(dt);
        struct lov_comp_md_v1 *lcm;
@@ -3517,20 +3517,6 @@ static int lod_declare_layout_merge(const struct lu_env *env,
        lod_obj_inc_layout_gen(lo);
        lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen);
 
-       /* transfer layout version to OST objects. */
-       if (lo->ldo_mirror_count > 1) {
-               struct lod_obj_stripe_cb_data data = { {0} };
-
-               layout_attr->la_valid = LA_LAYOUT_VERSION;
-               layout_attr->la_layout_version = 0;
-               data.locd_attr = layout_attr;
-               data.locd_declare = true;
-               data.locd_stripe_cb = lod_obj_stripe_attr_set_cb;
-               rc = lod_obj_for_each_stripe(env, lo, th, &data);
-               if (rc)
-                       GOTO(out, rc);
-       }
-
        rc = lod_sub_declare_xattr_set(env, dt_object_child(dt), buf,
                                       XATTR_NAME_LOV, LU_XATTR_REPLACE, th);
 
@@ -3546,8 +3532,6 @@ static int lod_declare_layout_split(const struct lu_env *env,
                struct dt_object *dt, const struct lu_buf *mbuf,
                struct thandle *th)
 {
-       struct lod_thread_info *info = lod_env_info(env);
-       struct lu_attr *layout_attr = &info->lti_layout_attr;
        struct lod_object *lo = lod_dt_obj(dt);
        struct lov_comp_md_v1 *lcm = mbuf->lb_buf;
        int rc;
@@ -3561,20 +3545,6 @@ static int lod_declare_layout_split(const struct lu_env *env,
        /* fix on-disk layout gen */
        lcm->lcm_layout_gen = cpu_to_le32(lo->ldo_layout_gen);
 
-       /* transfer layout version to OST objects. */
-       if (lo->ldo_mirror_count > 1) {
-               struct lod_obj_stripe_cb_data data = { {0} };
-
-               layout_attr->la_valid = LA_LAYOUT_VERSION;
-               layout_attr->la_layout_version = 0;
-               data.locd_attr = layout_attr;
-               data.locd_declare = true;
-               data.locd_stripe_cb = lod_obj_stripe_attr_set_cb;
-               rc = lod_obj_for_each_stripe(env, lo, th, &data);
-               if (rc)
-                       RETURN(rc);
-       }
-
        rc = lod_sub_declare_xattr_set(env, dt_object_child(dt), mbuf,
                                       XATTR_NAME_LOV, LU_XATTR_REPLACE, th);
        RETURN(rc);
@@ -5086,9 +5056,7 @@ static int lod_xattr_set(const struct lu_env *env,
 {
        struct lod_thread_info *info = lod_env_info(env);
        struct dt_object *next = dt_object_child(dt);
-       struct lu_attr *layout_attr = &info->lti_layout_attr;
        struct lod_object *lo = lod_dt_obj(dt);
-       struct lod_obj_stripe_cb_data data = { {0} };
        int rc = 0;
 
        ENTRY;
@@ -5152,21 +5120,6 @@ static int lod_xattr_set(const struct lu_env *env,
                        rc = lod_striping_reload(env, lo, buf, LVF_ALL_STALE);
                        if (rc)
                                RETURN(rc);
-
-                       if (lo->ldo_mirror_count > 1 &&
-                           layout_attr->la_valid & LA_LAYOUT_VERSION) {
-                               /* mirror split */
-                               layout_attr->la_layout_version =
-                                               lo->ldo_layout_gen;
-                               data.locd_attr = layout_attr;
-                               data.locd_declare = false;
-                               data.locd_stripe_cb =
-                                               lod_obj_stripe_attr_set_cb;
-                               rc = lod_obj_for_each_stripe(env, lo, th,
-                                                            &data);
-                               if (rc)
-                                       RETURN(rc);
-                       }
                } else if (fl & LU_XATTR_PURGE) {
                        rc = lod_layout_purge(env, dt, buf, th);
                } else if (dt_object_remote(dt)) {
@@ -5200,21 +5153,6 @@ static int lod_xattr_set(const struct lu_env *env,
                        rc = lod_striped_create(env, dt, NULL, NULL, th);
                        if (rc)
                                RETURN(rc);
-
-                       if (fl & LU_XATTR_MERGE && lo->ldo_mirror_count > 1 &&
-                           layout_attr->la_valid & LA_LAYOUT_VERSION) {
-                               /* mirror merge exec phase */
-                               layout_attr->la_layout_version =
-                                               lo->ldo_layout_gen;
-                               data.locd_attr = layout_attr;
-                               data.locd_declare = false;
-                               data.locd_stripe_cb =
-                                               lod_obj_stripe_attr_set_cb;
-                               rc = lod_obj_for_each_stripe(env, lo, th,
-                                                            &data);
-                               if (rc)
-                                       RETURN(rc);
-                       }
                }
                RETURN(rc);
        } else if (strcmp(name, XATTR_NAME_FID) == 0) {
index 3296999..cd37816 100644 (file)
@@ -3366,6 +3366,56 @@ test_70a() {
 }
 run_test 70a "flr mode fsx test"
 
+test_71() {
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [[ "$ost1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
+
+       local tf=$DIR/$tdir/$tfile
+
+       test_mkdir $DIR/$tdir
+       $LFS setstripe -c1 -i1 $tf|| error "setstripe $tf failed"
+       $LFS mirror extend -N -c1 -i0 $tf || error "mirror extend $tf failed"
+
+       local id=$($LFS getstripe -I $tf)
+       local ost=$($LFS getstripe -v -I$id $tf | awk '/l_ost_idx/ {print $5}')
+       local fid=$($LFS getstripe -v -I$id $tf | awk '/l_fid/ {print $7}')
+       local pfid=$($LFS getstripe -v -I$id $tf | awk '/lmm_fid/ {print $2}')
+
+       ost=$(echo $ost | sed -e "s/,$//g")
+       ost=$((ost + 1))
+
+       local dev=$(ostdevname $ost)
+       local obj_file=$(ost_fid2_objpath ost$ost $fid)
+
+       ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' $dev \
+                       2>/dev/null" | grep "parent=")
+       if [ -z "$ff" ]; then
+               stop ost$ost
+               mount_fstype ost$ost
+               ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
+                               $(facet_mntpt ost$ost)/$obj_file)
+               unmount_fstype ost$ost
+               start ost$ost $dev $OST_MOUNT_OPTS
+               clients_up
+       fi
+
+       local pseq=$(echo $ff | awk -F '[:= ]' '/parent/ { print $4 }')
+       local poid=$(echo $ff | awk -F '[:= ]' '/parent/ { print $5 }')
+       local pver=$(echo $ff | awk -F '[:= ]' '/parent/ { print $6 }')
+       local parent="$pseq:$poid:$pver"
+
+       log " ** lfs fid2path $MOUNT $parent"
+       $LFS fid2path $MOUNT "$parent" || {
+               $LFS getstripe $tf
+               error "cannot find parent $parent of OST object $fid"
+       }
+       [ "$parent" == "$pfid" ] || {
+               $LFS getstripe $tf
+               error "parent $parent of OST object $fid is not $pfid"
+       }
+}
+run_test 71 "check mirror extend parent fid"
+
 write_file_200() {
        local tf=$1
 
@@ -4506,16 +4556,9 @@ test_210b() {
        dd if=/dev/zero of=$tf bs=1M count=1 || error "can't dd"
 
        local ostdev=$(ostdevname 1)
-       local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
-       local seq=${fid[3]#0x}
-       local oid=${fid[1]}
-       local oid_hex
-       if [ $seq == 0 ]; then
-               oid_hex=${fid[1]}
-       else
-               oid_hex=${fid[2]#0x}
-       fi
-       local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
+       local fids=($($LFS getstripe $DIR/$tfile | grep 0x))
+       local fid="${fids[3]}:${fids[2]}:0"
+       local objpath=$(ost_fid2_objpath ost1 $fid)
        local cmd="$DEBUGFS -c -R \\\"stat $objpath\\\" $ostdev"
 
        local ino=$(do_facet ost1 $cmd | grep Inode:)
index 01177a8..b5c3092 100755 (executable)
@@ -3295,18 +3295,11 @@ test_37() {
        do_facet ost1 "sync; sync"
 
        # check that content on ost is encrypted
-       local fid=($($LFS getstripe $testfile | grep 0x))
-       local seq=${fid[3]#0x}
-       local oid=${fid[1]}
-       local oid_hex
+       local fids=($($LFS getstripe $testfile | grep 0x))
+       local fid="${fids[3]}:${fids[2]}:0"
+       local objpath=$(ost_fid2_objpath ost1 $fid)
 
-       if [ $seq == 0 ]; then
-               oid_hex=${fid[1]}
-       else
-               oid_hex=${fid[2]#0x}
-       fi
-       do_facet ost1 "$DEBUGFS -c -R 'cat O/$seq/d$(($oid % 32))/$oid_hex' \
-                $(ostdevname 1)" > $objdump
+       do_facet ost1 "$DEBUGFS -c -R 'cat $objpath' $(ostdevname 1)" > $objdump
        cmp -s $objdump $tmpfile &&
                error "file $testfile is not encrypted on ost"
 
index 54f6aaf..0696b91 100755 (executable)
@@ -2243,114 +2243,6 @@ test_27y() {
 }
 run_test 27y "create files while OST0 is degraded and the rest inactive"
 
-check_seq_oid()
-{
-       log "check file $1"
-
-       lmm_count=$($LFS getstripe -c $1)
-       lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
-       lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
-
-       local old_ifs="$IFS"
-       IFS=$'[:]'
-       fid=($($LFS path2fid $1))
-       IFS="$old_ifs"
-
-       log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
-       log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
-
-       # compare lmm_seq and lu_fid->f_seq
-       [ $lmm_seq = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
-       # compare lmm_object_id and lu_fid->oid
-       [ $lmm_oid = ${fid[2]} ] || { error "OID mismatch"; return 2; }
-
-       # check the trusted.fid attribute of the OST objects of the file
-       local have_obdidx=false
-       local stripe_nr=0
-       $LFS getstripe $1 | while read obdidx oid hex seq; do
-               # skip lines up to and including "obdidx"
-               [ -z "$obdidx" ] && break
-               [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
-               $have_obdidx || continue
-
-               local ost=$((obdidx + 1))
-               local dev=$(ostdevname $ost)
-               local oid_hex
-
-               log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
-
-               seq=$(echo $seq | sed -e "s/^0x//g")
-               if [ $seq == 0 ] || [ $(facet_fstype ost$ost) == zfs ]; then
-                       oid_hex=$(echo $oid)
-               else
-                       oid_hex=$(echo $hex | sed -e "s/^0x//g")
-               fi
-               local obj_file="O/$seq/d$((oid %32))/$oid_hex"
-
-               local ff=""
-               #
-               # Don't unmount/remount the OSTs if we don't need to do that.
-               # LU-2577 changes filter_fid to be smaller, so debugfs needs
-               # update too, until that use mount/ll_decode_filter_fid/mount.
-               # Re-enable when debugfs will understand new filter_fid.
-               #
-               if [ $(facet_fstype ost$ost) == ldiskfs ]; then
-                       ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
-                               $dev 2>/dev/null" | grep "parent=")
-               fi
-               if [ -z "$ff" ]; then
-                       stop ost$ost
-                       mount_fstype ost$ost
-                       ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
-                               $(facet_mntpt ost$ost)/$obj_file)
-                       unmount_fstype ost$ost
-                       start ost$ost $dev $OST_MOUNT_OPTS
-                       clients_up
-               fi
-
-               [ -z "$ff" ] && error "$obj_file: no filter_fid info"
-
-               echo "$ff" | sed -e 's#.*objid=#got: objid=#'
-
-               # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
-               # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
-               #
-               # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
-               #       stripe_size=1048576 component_id=1 component_start=0 \
-               #       component_end=33554432
-               local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
-               local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
-               local ff_poid=$(cut -d: -f2 <<<$ff_parent)
-               local ff_pstripe
-               if grep -q 'stripe=' <<<$ff; then
-                       ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
-               else
-                       # $LL_DECODE_FILTER_FID does not print "stripe="; look
-                       # into f_ver in this case.  See comment on ff_parent.
-                       ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
-               fi
-
-               # compare lmm_seq and filter_fid->ff_parent.f_seq
-               [ $ff_pseq = $lmm_seq ] ||
-                       error "FF parent SEQ $ff_pseq != $lmm_seq"
-               # compare lmm_object_id and filter_fid->ff_parent.f_oid
-               [ $ff_poid = $lmm_oid ] ||
-                       error "FF parent OID $ff_poid != $lmm_oid"
-               (($ff_pstripe == $stripe_nr)) ||
-                       error "FF stripe $ff_pstripe != $stripe_nr"
-
-               stripe_nr=$((stripe_nr + 1))
-               [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
-                       continue
-               if grep -q 'stripe_count=' <<<$ff; then
-                       local ff_scnt=$(sed -e 's/.*stripe_count=//' \
-                                           -e 's/ .*//' <<<$ff)
-                       [ $lmm_count = $ff_scnt ] ||
-                               error "FF stripe count $lmm_count != $ff_scnt"
-               fi
-       done
-}
-
 test_27z() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
        remote_ost_nodsh && skip "remote OST with nodsh"
@@ -5469,17 +5361,9 @@ test_39r() {
        echo "client atime: $atime_cli"
 
        local ostdev=$(ostdevname 1)
-       local fid=($($LFS getstripe $DIR/$tfile | grep 0x))
-       local seq=${fid[3]#0x}
-       local oid=${fid[1]}
-       local oid_hex
-
-       if [ $seq == 0 ]; then
-               oid_hex=${fid[1]}
-       else
-               oid_hex=${fid[2]#0x}
-       fi
-       local objpath="O/$seq/d$(($oid % 32))/$oid_hex"
+       local fids=($($LFS getstripe $DIR/$tfile | grep 0x))
+       local fid="${fids[3]}:${fids[2]}:0"
+       local objpath=$(ost_fid2_objpath ost1 $fid)
        local cmd="debugfs -c -R \\\"stat $objpath\\\" $ostdev"
 
        # allow atime update to be written to device
@@ -9974,7 +9858,7 @@ test_60a() {
 
                case $fstype in
                        ldiskfs )
-                               obj_file=$mntpt/O/$seq/d$((oid%32))/$oid ;;
+                               obj_file=$mntpt/$(ost_fid2_objpath mgs $fid) ;;
                        zfs )
                                obj_file=$mntpt/oi.$(($((16#$seq))&127))/$fid ;;
                esac
index 66156d1..3ce61f0 100755 (executable)
@@ -12482,3 +12482,122 @@ zfs_or_rotational() {
                return 1
        fi
 }
+
+ost_fid2_objpath() {
+       local facet=$1
+       local fid=$2
+
+       fid=$(echo $fid | tr -d '[]')
+
+       seq=$(echo $fid | awk -F ':' '{ print $1 }' | sed -e "s/^0x//g")
+       oidhex=$(echo $fid | awk -F ':' '{ print $2 }')
+
+       if [ $seq == 0 ] || [ $(facet_fstype $facet) == zfs ]; then
+               oid=$((16#${oidhex#0x}))
+       else
+               oid=${oidhex#0x}
+       fi
+
+       echo "O/$seq/d$((oidhex%32))/$oid"
+}
+
+check_seq_oid()
+{
+       log "check file $1"
+
+       lmm_count=$($LFS getstripe -c $1)
+       lmm_seq=$($LFS getstripe -v $1 | awk '/lmm_seq/ { print $2 }')
+       lmm_oid=$($LFS getstripe -v $1 | awk '/lmm_object_id/ { print $2 }')
+
+       local old_ifs="$IFS"
+       IFS=$'[:]'
+       fid=($($LFS path2fid $1))
+       IFS="$old_ifs"
+
+       log "FID seq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}"
+       log "LOV seq $lmm_seq, oid $lmm_oid, count: $lmm_count"
+
+       # compare lmm_seq and lu_fid->f_seq
+       [ $lmm_seq = ${fid[1]} ] || error "SEQ mismatch"
+       # compare lmm_object_id and lu_fid->oid
+       [ $lmm_oid = ${fid[2]} ] || error "OID mismatch"
+
+       # check the trusted.fid attribute of the OST objects of the file
+       local have_obdidx=false
+       local stripe_nr=0
+       $LFS getstripe $1 | while read obdidx oid hex seq; do
+               # skip lines up to and including "obdidx"
+               [ -z "$obdidx" ] && break
+               [ "$obdidx" = "obdidx" ] && have_obdidx=true && continue
+               $have_obdidx || continue
+
+               local ost=$((obdidx + 1))
+               local dev=$(ostdevname $ost)
+
+               log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq"
+
+               local obj_file=$(ost_fid2_objpath ost$ost "$seq:$hex:0")
+
+               local ff=""
+               #
+               # Don't unmount/remount the OSTs if we don't need to do that.
+               # LU-2577 changes filter_fid to be smaller, so debugfs needs
+               # update too, until that use mount/ll_decode_filter_fid/mount.
+               # Re-enable when debugfs will understand new filter_fid.
+               #
+               if [ $(facet_fstype ost$ost) == ldiskfs ]; then
+                       ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \
+                               $dev 2>/dev/null" | grep "parent=")
+               fi
+               if [ -z "$ff" ]; then
+                       stop ost$ost
+                       mount_fstype ost$ost
+                       ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID \
+                               $(facet_mntpt ost$ost)/$obj_file)
+                       unmount_fstype ost$ost
+                       start ost$ost $dev $OST_MOUNT_OPTS
+                       clients_up
+               fi
+
+               [ -z "$ff" ] && error "$obj_file: no filter_fid info"
+
+               echo "$ff" | sed -e 's#.*objid=#got: objid=#'
+
+               # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1]
+               # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1
+               #
+               # fid: parent=[0x200000400:0x1e:0x0] stripe=1 stripe_count=2 \
+               #       stripe_size=1048576 component_id=1 component_start=0 \
+               #       component_end=33554432
+               local ff_parent=$(sed -e 's/.*parent=.//' <<<$ff)
+               local ff_pseq=$(cut -d: -f1 <<<$ff_parent)
+               local ff_poid=$(cut -d: -f2 <<<$ff_parent)
+               local ff_pstripe
+               if grep -q 'stripe=' <<<$ff; then
+                       ff_pstripe=$(sed -e 's/.*stripe=//' -e 's/ .*//' <<<$ff)
+               else
+                       # $LL_DECODE_FILTER_FID does not print "stripe="; look
+                       # into f_ver in this case.  See comment on ff_parent.
+                       ff_pstripe=$(cut -d: -f3 <<<$ff_parent | sed -e 's/]//')
+               fi
+
+               # compare lmm_seq and filter_fid->ff_parent.f_seq
+               [ $ff_pseq = $lmm_seq ] ||
+                       error "FF parent SEQ $ff_pseq != $lmm_seq"
+               # compare lmm_object_id and filter_fid->ff_parent.f_oid
+               [ $ff_poid = $lmm_oid ] ||
+                       error "FF parent OID $ff_poid != $lmm_oid"
+               (($ff_pstripe == $stripe_nr)) ||
+                       error "FF stripe $ff_pstripe != $stripe_nr"
+
+               stripe_nr=$((stripe_nr + 1))
+               [ $CLIENT_VERSION -lt $(version_code 2.9.55) ] &&
+                       continue
+               if grep -q 'stripe_count=' <<<$ff; then
+                       local ff_scnt=$(sed -e 's/.*stripe_count=//' \
+                                           -e 's/ .*//' <<<$ff)
+                       [ $lmm_count = $ff_scnt ] ||
+                               error "FF stripe count $lmm_count != $ff_scnt"
+               fi
+       done
+}