diff --git a/lustre/mdt/mdt_hsm.c b/lustre/mdt/mdt_hsm.c index 0b122b5d55..3c22a6cc0f 100644 --- a/lustre/mdt/mdt_hsm.c +++ b/lustre/mdt/mdt_hsm.c @@ -355,7 +355,7 @@ int mdt_hsm_state_set(struct tgt_session_info *tsi) CDEBUG(D_HSM, "Could not set an archive number for " DFID "if HSM EXISTS flag is not set.\n", PFID(&info->mti_body->mbo_fid1)); - GOTO(out_unlock, rc); + GOTO(out_unlock, rc = -EINVAL); } if (!exp_connect_archive_id_array(exp) && diff --git a/lustre/tests/sanity-hsm.sh b/lustre/tests/sanity-hsm.sh index 69f195208a..31a01d4a7f 100755 --- a/lustre/tests/sanity-hsm.sh +++ b/lustre/tests/sanity-hsm.sh @@ -694,6 +694,14 @@ test_1c() { local f=$DIR/$tdir/$tfile $RUNAS touch $f + # Reject an archive ID when HS_EXISTS is not set (LU-20118). + local rc=0 + + $LFS hsm_set --dirty --archive-id 1 $f || rc=$? + [[ $rc == 22 ]] || + error "expected EINVAL (22), got $rc" + check_hsm_flags_user $f "0x00000000" + # Test whether we can set the maximum archive number. local LOCAL_HSM_ARCHIVE_NUMBER=32 $LFS hsm_set --exists --archive-id $LOCAL_HSM_ARCHIVE_NUMBER $f ||