Whamcloud - gitweb
LU-18810 misc: filename encoding for remaining files 35/58435/3
authorEmoly Liu <emoly@whamcloud.com>
Mon, 17 Mar 2025 04:21:24 +0000 (12:21 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Mar 2025 04:05:54 +0000 (04:05 +0000)
Apply filename encoding feature to the remaining files.
Also, sanity.sh test_170b is added to verify this feature.

This is a port of
Lustre-change: https://review.whamcloud.com/58125
Lustre-commit: TBD (from a9aac92b92ce9b7bb115da6b3d5bc513240972c8)
EX-bug-id: EX-11415

Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Change-Id: I8b7a007844e068bd0db7ee9c2bc0309ccd5c656a
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58435
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_obd.c
lustre/mdc/mdc_locks.c
lustre/obdclass/linkea.c
lustre/target/out_handler.c
lustre/target/out_lib.c
lustre/tests/sanity.sh

index bc0174b..331e9a4 100644 (file)
@@ -353,8 +353,9 @@ retry:
        }
 
        CDEBUG(D_INODE, "OPEN_INTENT with fid1="DFID", fid2="DFID","
-              " name='%s' -> mds #%u\n", PFID(&op_data->op_fid1),
-              PFID(&op_data->op_fid2), op_data->op_name, tgt->ltd_index);
+              " name='"DNAME"' -> mds #%u\n", PFID(&op_data->op_fid1),
+              PFID(&op_data->op_fid2), encode_fn_opdata(op_data),
+              tgt->ltd_index);
 
        rc = md_intent_lock(tgt->ltd_exp, op_data, it, reqp, cb_blocking,
                            extra_lock_flags);
@@ -468,8 +469,9 @@ retry:
        CDEBUG(D_INODE, "LOOKUP_INTENT with fid1="DFID", fid2="DFID
               ", name='%s' -> mds #%u\n",
               PFID(&op_data->op_fid1), PFID(&op_data->op_fid2),
-              op_data->op_name ? op_data->op_name : "<NULL>",
-              tgt->ltd_index);
+              op_data->op_name ?
+              encode_fn_len(op_data->op_name, op_data->op_namelen) :
+              "<NULL>", tgt->ltd_index);
 
        op_data->op_bias &= ~MDS_CROSS_REF;
 
@@ -538,10 +540,9 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
        LASSERT(it != NULL);
        LASSERT(fid_is_sane(&op_data->op_fid1));
 
-       CDEBUG(D_INODE, "INTENT LOCK '%s' for "DFID" '%.*s' on "DFID"\n",
+       CDEBUG(D_INODE, "INTENT LOCK '%s' for "DFID" '"DNAME"' on "DFID"\n",
                LL_IT2STR(it), PFID(&op_data->op_fid2),
-               (int)op_data->op_namelen, op_data->op_name,
-               PFID(&op_data->op_fid1));
+               encode_fn_opdata(op_data), PFID(&op_data->op_fid1));
 
        if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT | IT_GETXATTR))
                rc = lmv_intent_lookup(exp, op_data, it, reqp, cb_blocking,
index be272ab..a615836 100644 (file)
@@ -2262,10 +2262,9 @@ retry:
        if (rc)
                RETURN(rc);
 
-       CDEBUG(D_INODE, "CREATE name '%.*s' "DFID" on "DFID" -> mds #%x\n",
-               (int)op_data->op_namelen, op_data->op_name,
-               PFID(&op_data->op_fid2), PFID(&op_data->op_fid1),
-               op_data->op_mds);
+       CDEBUG(D_INODE, "CREATE name '"DNAME"' "DFID" on "DFID" -> mds #%x\n",
+               encode_fn_opdata(op_data), PFID(&op_data->op_fid2),
+               PFID(&op_data->op_fid1), op_data->op_mds);
 
        op_data->op_flags |= MF_MDC_CANCEL_FID1;
        rc = md_create(tgt->ltd_exp, op_data, data, datalen, mode, uid, gid,
@@ -2558,8 +2557,8 @@ static int lmv_migrate(struct obd_export *exp, struct md_op_data *op_data,
 
        LASSERT(op_data->op_cli_flags & CLI_MIGRATE);
 
-       CDEBUG(D_INODE, "MIGRATE "DFID"/%.*s\n",
-              PFID(&op_data->op_fid1), (int)namelen, name);
+       CDEBUG(D_INODE, "MIGRATE "DFID"/"DNAME"\n",
+              PFID(&op_data->op_fid1), encode_fn_dname(namelen, name));
 
        op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
        op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
@@ -2841,9 +2840,9 @@ retry:
        }
 
 rename:
-       CDEBUG(D_INODE, "RENAME "DFID"/%.*s to "DFID"/%.*s\n",
-               PFID(&op_data->op_fid1), (int)oldlen, old,
-               PFID(&op_data->op_fid2), (int)newlen, new);
+       CDEBUG(D_INODE, "RENAME "DFID"/"DNAME" to "DFID"/"DNAME"\n",
+               PFID(&op_data->op_fid1), encode_fn_dname(oldlen, old),
+               PFID(&op_data->op_fid2), encode_fn_dname(newlen, new));
 
        rc = md_rename(tgt->ltd_exp, op_data, old, oldlen, new, newlen,
                        request);
index 2f6e0db..6e644a2 100644 (file)
@@ -365,9 +365,8 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
                                     RCL_SERVER,
                                     obd->u.cli.cl_max_mds_easize);
 
-               CDEBUG(D_SEC, "packed '%.*s' as security xattr name\n",
-                      op_data->op_file_secctx_name_size,
-                      op_data->op_file_secctx_name);
+               CDEBUG(D_SEC, "packed '"DNAME"' as security xattr name\n",
+                      encode_fn_opdata(op_data));
 
        } else {
                req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX,
@@ -675,9 +674,8 @@ mdc_intent_getattr_pack(struct obd_export *exp, struct lookup_intent *it,
                req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX,
                                     RCL_SERVER, easize);
 
-               CDEBUG(D_SEC, "packed '%.*s' as security xattr name\n",
-                      op_data->op_file_secctx_name_size,
-                      op_data->op_file_secctx_name);
+               CDEBUG(D_SEC, "packed '"DNAME"' as security xattr name\n",
+                      encode_fn_opdata(op_data));
        } else {
                req_capsule_set_size(&req->rq_pill, &RMF_FILE_SECCTX,
                                     RCL_SERVER, 0);
@@ -1383,9 +1381,9 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
        EXIT;
 out:
        CDEBUG(D_DENTRY,
-              "D_IT dentry=%.*s intent=%s status=%d disp=%x: rc = %d\n",
-               (int)op_data->op_namelen, op_data->op_name,
-               ldlm_it2str(it->it_op), it->it_status, it->it_disposition, rc);
+              "D_IT dentry="DNAME" intent=%s status=%d disp=%x: rc = %d\n",
+              encode_fn_opdata(op_data), ldlm_it2str(it->it_op),
+              it->it_status, it->it_disposition, rc);
 
        return rc;
 }
@@ -1499,11 +1497,11 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
 
        ENTRY;
        LASSERT(it);
-       CDEBUG(D_DLMTRACE, "(name: %.*s,"DFID") in obj "DFID
-               ", intent: %s flags %#lo\n", (int)op_data->op_namelen,
-               op_data->op_name, PFID(&op_data->op_fid2),
-               PFID(&op_data->op_fid1), ldlm_it2str(it->it_op),
-               it->it_open_flags);
+       CDEBUG(D_DLMTRACE,
+              "(name: "DNAME","DFID") in obj "DFID", intent: %s flags %#lo\n",
+              encode_fn_opdata(op_data), PFID(&op_data->op_fid2),
+              PFID(&op_data->op_fid1), ldlm_it2str(it->it_op),
+              it->it_open_flags);
 
        lockh.cookie = 0;
        /* MDS_FID_OP is not a revalidate case */
@@ -1605,10 +1603,9 @@ int mdc_intent_getattr_async(struct obd_export *exp,
 
        ENTRY;
        CDEBUG(D_DLMTRACE,
-              "name: %.*s in inode "DFID", intent: %s flags %#lo\n",
-              (int)op_data->op_namelen, op_data->op_name,
-              PFID(&op_data->op_fid1), ldlm_it2str(it->it_op),
-              it->it_open_flags);
+              "name: "DNAME" in inode "DFID", intent: %s flags %#lo\n",
+              encode_fn_opdata(op_data), PFID(&op_data->op_fid1),
+              ldlm_it2str(it->it_op), it->it_open_flags);
 
        fid_build_reg_res_name(&op_data->op_fid1, &res_id);
        /* If the MDT return -ERANGE because of large ACL, then the sponsor
index 431737e..823648b 100644 (file)
@@ -148,8 +148,8 @@ int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname,
                        leh->leh_overflow_time++;
 
                CDEBUG(D_INODE, "No enough space to hold linkea entry '"
-                      DFID": %.*s' at %u\n", PFID(pfid), lname->ln_namelen,
-                      lname->ln_name, leh->leh_overflow_time);
+                      DFID": "DNAME"' at %u\n", PFID(pfid),
+                      encode_fn_luname(lname), leh->leh_overflow_time);
                return err_on_overflow ? -EOVERFLOW : 0;
        }
 
@@ -170,8 +170,8 @@ int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname,
                       "New link_ea name '"DFID":<encrypted (%d)>' is added\n",
                       PFID(pfid), lname->ln_namelen);
        else
-               CDEBUG(D_INODE, "New link_ea name '"DFID":%.*s' is added\n",
-                      PFID(pfid), lname->ln_namelen, lname->ln_name);
+               CDEBUG(D_INODE, "New link_ea name '"DFID":"DNAME"' is added\n",
+                      PFID(pfid), encode_fn_luname(lname));
        return 0;
 }
 EXPORT_SYMBOL(linkea_add_buf);
@@ -193,8 +193,8 @@ void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname,
                       "Old link_ea name '<encrypted (%d)>' is removed\n",
                       lname->ln_namelen);
        else
-               CDEBUG(D_INODE, "Old link_ea name '%.*s' is removed\n",
-                      lname->ln_namelen, lname->ln_name);
+               CDEBUG(D_INODE, "Old link_ea name '"DNAME"' is removed\n",
+                      encode_fn_luname(lname));
 
        if ((char *)ldata->ld_lee >= ((char *)ldata->ld_leh +
                                      ldata->ld_leh->leh_len))
@@ -258,9 +258,9 @@ int linkea_overflow_shrink(struct linkea_data *ldata)
 
        linkea_entry_unpack(ldata->ld_lee, &ldata->ld_reclen, &tname, &tfid);
        CDEBUG(D_INODE, "No enough space to hold the last linkea entry '"
-              DFID": %.*s', shrink it, left %d linkea entries, size %llu\n",
-              PFID(&tfid), tname.ln_namelen, tname.ln_name,
-              leh->leh_reccount, leh->leh_len);
+              DFID": "DNAME"', shrink it, left %d linkea entries, size %llu\n",
+              PFID(&tfid), encode_fn_luname(&tname), leh->leh_reccount,
+              leh->leh_len);
 
        return leh->leh_len;
 }
@@ -303,8 +303,8 @@ int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname,
        }
 
        if (count == ldata->ld_leh->leh_reccount) {
-               CDEBUG(D_INODE, "Old link_ea name '%.*s' not found\n",
-                      lname->ln_namelen, lname->ln_name);
+               CDEBUG(D_INODE, "Old link_ea name '"DNAME"' not found\n",
+                      encode_fn_luname(lname));
                ldata->ld_lee = NULL;
                ldata->ld_reclen = 0;
                return -ENOENT;
index 02944d0..08ab226 100644 (file)
@@ -358,7 +358,7 @@ out_unlock:
        dt_read_unlock(env, obj);
 
        CDEBUG(D_INFO, "lookup "DFID" %s get "DFID" rc %d\n",
-              PFID(lu_object_fid(&obj->do_lu)), name,
+              PFID(lu_object_fid(&obj->do_lu)), encode_fn(name),
               PFID(&tti->tti_fid1), rc);
 
        CDEBUG(D_INFO, "%s: insert lookup reply %p index %d: rc = %d\n",
@@ -556,7 +556,7 @@ static int out_index_insert(struct tgt_session_info *tsi)
 
        CDEBUG(D_INFO, "%s: "DFID" index insert %s: rc = %d\n",
               tgt_name(tsi->tsi_tgt), PFID(lu_object_fid(&obj->do_lu)),
-              name, rc);
+              encode_fn(name), rc);
 
        RETURN(rc);
 }
index 1a4e914..0d8475c 100644 (file)
@@ -1045,7 +1045,8 @@ static int out_obj_index_insert(const struct lu_env *env,
 
        CDEBUG(D_INFO, "%s: index insert "DFID" name: %s fid "DFID", type %u\n",
               dt_obd_name(th->th_dev), PFID(lu_object_fid(&dt_obj->do_lu)),
-              (char *)key, PFID(((struct dt_insert_rec *)rec)->rec_fid),
+              encode_fn((char *)key),
+              PFID(((struct dt_insert_rec *)rec)->rec_fid),
               ((struct dt_insert_rec *)rec)->rec_type);
 
        if (!dt_try_as_dir(env, dt_obj, true))
index 110c002..4fea3c7 100755 (executable)
@@ -21102,7 +21102,7 @@ test_169() {
 }
 run_test 169 "parallel read and truncate should not deadlock"
 
-test_170() {
+test_170a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        $LCTL clear     # bug 18514
@@ -21155,7 +21155,67 @@ test_170() {
         fi
         true
 }
-run_test 170 "test lctl df to handle corrupted log ====================="
+run_test 170a "test lctl df to handle corrupted log"
+
+test_170b() {
+       # enable filename encoding on one client, ost and mdt respectively
+       declare -a old_fl
+       local param="enable_fname_encoding"
+       local nodes_list=$HOSTNAME
+       local log=$TMP/sanity.$testnum
+       local i=0
+
+       (( $MDS1_VERSION >= $(version_code 2.16.52) )) &&
+               nodes_list="$nodes_list,$(facet_active_host mds1)"
+       (( $OST1_VERSION >= $(version_code 2.16.52) )) &&
+               nodes_list="$nodes_list,$(facet_active_host ost1)"
+
+       old_fl=($(do_nodes $nodes_list $LCTL get_param -n $param))
+
+       # Test with filename encoding on
+       set_params_nodes $nodes_list "$param=on"
+       for node in ${nodes_list//,/ }; do
+               stack_trap "set_params_nodes $node "$param=${old_fl[$i]}""
+               i=$((i+1))
+       done
+       do_nodes $nodes_list "$LCTL get_param -n $param" | grep 0 &&
+               error "Failed to enable filename encoding on all the nodes"
+
+       # Start full debug to collect the logs
+       start_full_debug_logging $nodes_list
+       do_nodes $nodes_list "$LCTL clear"
+
+       # Do some operations on $tfile
+       touch $DIR/$tfile || error "Failed to touch $tfile"
+       cp $DIR/$tfile $DIR/$testnum.cp || error "Failed to cp $tfile"
+       ln -s $DIR/$tfile $DIR/$testnum.ln || error "Failed to ln -s $tfile"
+       $LFS migrate -c $OSTCOUNT $DIR/$tfile ||
+               error "Failed to migrate $tfile"
+       $LFS mirror extend -N $DIR/$tfile ||
+               error "Failed to extend mirrored $tfile"
+       mv $DIR/$tfile $DIR/$testnum.mv || error "Failed to mv $tfile"
+       rm -f $DIR/$tfile $DIR/$testnum.* || error "Failed to rm $tfile"
+
+       # Do some operations on $tdir
+       mkdir -p $DIR/$tdir || error "Failed to mkdir $tdir"
+       cp -r $DIR/$tdir $DIR/$testnum.cp || error "Failed to cp $tdir"
+       ln -s $DIR/$tdir $DIR/$testnum.ln || error "Failed to ln -s $tdir"
+       $LFS migrate -d -m 0 -c $MDSCOUNT $DIR/$tdir ||
+               error "Failed to migrate $tdir"
+       mv $DIR/$tdir $DIR/$testnum.mv || error "Failed to mv $tdir"
+       rm -rf $DIR/$tdir $DIR/$testnum.* || error "Failed to rm $tdir"
+
+       # Stop the full debug
+       do_nodes $nodes_list "$LCTL dk > $log"
+       stack_trap "do_nodes $nodes_list rm -f $log"
+       stop_full_debug_logging
+
+       # Verify if $tfile and $tdir names are encoded in the logs
+       do_nodes $nodes_list "grep -E '$tfile|$tdir' $log" &&
+               error "Still found '$tfile' and '$tdir' in the logs"
+       return 0
+}
+run_test 170b "check filename encoding"
 
 test_171() { # bug20592
        [ $PARALLEL == "yes" ] && skip "skip parallel run"