[LU-9744] HS_DIRTY/CLF_HSM_DIRTY can be wrongly reported upon HSM action error Created: 07/Jul/17  Updated: 18/Mar/19  Resolved: 05/Aug/17

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.10.1, Lustre 2.11.0

Type: Bug Priority: Minor
Reporter: Bruno Faccini (Inactive) Assignee: Bruno Faccini (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
is related to LU-10043 sanity-hsm test_222c: Changelog flag ... Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

In hsm_cdt_request_completed() and upon error being returned from mdt_hsm_get_md_hsm(), where "struct md_hsm mh" has not been populated, HS_DIRTY can be wrongly detected and thus CLF_HSM_DIRTY flag will be reported by error :

/**
 * get obj and HSM attributes on a fid
 * \param mti [IN] context
 * \param fid [IN] object fid
 * \param hsm [OUT] HSM meta data
 * \retval obj or error (-ENOENT if not found)
 */
struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti,
                                      const struct lu_fid *fid,
                                      struct md_hsm *hsm)
{
        struct md_attr          *ma;
        struct mdt_object       *obj;
        int                      rc;
        ENTRY;

        ma = &mti->mti_attr;
        ma->ma_need = MA_HSM;
        ma->ma_valid = 0;

        /* find object by FID */
        obj = mdt_object_find(mti->mti_env, mti->mti_mdt, fid);
        if (IS_ERR(obj))
                RETURN(obj);

        if (!mdt_object_exists(obj)) {
                /* no more object */
                mdt_object_put(mti->mti_env, obj);
                RETURN(ERR_PTR(-ENOENT));
        }

        rc = mdt_attr_get_complex(mti, obj, ma);
        if (rc) {
                mdt_object_put(mti->mti_env, obj);
                RETURN(ERR_PTR(rc));
        }

        if (ma->ma_valid & MA_HSM)
                *hsm = ma->ma_hsm;
        else
                memset(hsm, 0, sizeof(*hsm));
        ma->ma_valid = 0;
        RETURN(obj);
}

...................

/**
 * update status of a completed request
 * \param mti [IN] context
 * \param pgs [IN] progress of the copy tool
 * \param update_record [IN] update llog record
 * \retval 0 success
 * \retval -ve failure
 */
static int hsm_cdt_request_completed(struct mdt_thread_info *mti,
                                     struct hsm_progress_kernel *pgs,
                                     const struct cdt_agent_req *car,
                                     enum agent_req_status *status)
{
        const struct lu_env     *env = mti->mti_env;
        struct mdt_device       *mdt = mti->mti_mdt;
        struct coordinator      *cdt = &mdt->mdt_coordinator;
        struct mdt_object       *obj = NULL;
        int                      cl_flags = 0, rc = 0;
        struct md_hsm            mh;
        bool                     is_mh_changed;
        bool                     need_changelog = true;
        ENTRY;

        /* default is to retry */
        *status = ARS_WAITING;

        /* find object by FID, mdt_hsm_get_md_hsm() returns obj or err
         * if error/removed continue anyway to get correct reporting done */
        obj = mdt_hsm_get_md_hsm(mti, &car->car_hai->hai_fid, &mh);
......................
        /* rc != 0 means error when analysing action, it may come from
         * a crasy CT no need to manage DIRTY
         */
        if (rc == 0)
                hsm_set_cl_flags(&cl_flags,
                                 mh.mh_flags & HS_DIRTY ? CLF_HSM_DIRTY : 0);
.......................

!IS_ERR(obj) should also be tested before adding CLF_HSM_DIRTY in cl_flags.

This can be the cause of errors in associated sanity-hsm sub-tests test_220a, test_222c, test_222d, tests_224a, when analyzing ChangeLog flags.



 Comments   
Comment by Gerrit Updater [ 07/Jul/17 ]

Faccini Bruno (bruno.faccini@intel.com) uploaded a new patch: https://review.whamcloud.com/27962
Subject: LU-9744 mdt: avoid wrong CLF_HSM_DIRTY report in ChangeLog
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 04e9d7094e4e2c0e18e2d25877583639d416e248

Comment by Gerrit Updater [ 05/Aug/17 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/27962/
Subject: LU-9744 mdt: avoid wrong CLF_HSM_DIRTY report in ChangeLog
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 1b6af5006d0a36615f059030b005d55d3c7bb45e

Comment by Peter Jones [ 05/Aug/17 ]

Landed for 2.11

Comment by Gerrit Updater [ 07/Aug/17 ]

Minh Diep (minh.diep@intel.com) uploaded a new patch: https://review.whamcloud.com/28403
Subject: LU-9744 mdt: avoid wrong CLF_HSM_DIRTY report in ChangeLog
Project: fs/lustre-release
Branch: b2_10
Current Patch Set: 1
Commit: 46ee173c54d38bcec540fe46213414adcd9bb735

Comment by Gerrit Updater [ 10/Aug/17 ]

John L. Hammond (john.hammond@intel.com) merged in patch https://review.whamcloud.com/28403/
Subject: LU-9744 mdt: avoid wrong CLF_HSM_DIRTY report in ChangeLog
Project: fs/lustre-release
Branch: b2_10
Current Patch Set:
Commit: 86421e70c1583f5691e516b7c216efdd9b241e99

Generated at Sat Feb 10 02:28:51 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.