From: Andreas Dilger Date: Sat, 1 Sep 2018 07:51:29 +0000 (-0600) Subject: LU-10030 hsm: make changelog flag argument an enum X-Git-Tag: 2.12.0-RC1~58 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=2496089a0017f5b0ff94a7a7994f4c62c8f30d94 LU-10030 hsm: make changelog flag argument an enum Since the changelog record flag is being stored on disk, pass it around as an enum instead of a signed int. Also make it clear at the caller that only the low 12 bits of the flag are normally being stored in the changelog records, since this isn't obvious to the reader. For open and close records, the bottom 32 bits of open flags are recorded. Test-Parameters: trivial testlist=sanity-hsm Signed-off-by: Andreas Dilger Change-Id: Ie676fb6bfd3661645dde845fd9ca8bad283ebbe5 Reviewed-on: https://review.whamcloud.com/32112 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Sebastien Buisson Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 718be0c..fb8c67f 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -230,7 +230,8 @@ struct md_object_operations { struct lu_buf *buf); int (*moo_changelog)(const struct lu_env *env, - enum changelog_rec_type type, int flags, + enum changelog_rec_type type, + enum changelog_rec_flags clf_flags, struct md_device *m, const struct lu_fid *fid); int (*moo_open)(const struct lu_env *env, @@ -413,8 +414,8 @@ static inline int mo_readlink(const struct lu_env *env, static inline int mo_changelog(const struct lu_env *env, enum changelog_rec_type type, - int flags, struct md_device *m, - const struct lu_fid *fid) + enum changelog_rec_flags clf_flags, + struct md_device *m, const struct lu_fid *fid) { struct lu_fid rootfid; struct md_object *root; @@ -429,7 +430,7 @@ static inline int mo_changelog(const struct lu_env *env, RETURN(PTR_ERR(root)); LASSERT(root->mo_ops->moo_changelog); - rc = root->mo_ops->moo_changelog(env, type, flags, m, fid); + rc = root->mo_ops->moo_changelog(env, type, clf_flags, m, fid); lu_object_put(env, &root->mo_lu); diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index e273457..1c56911 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -1140,16 +1140,17 @@ static inline const char *changelog_type2str(int type) { return NULL; } -/* per-record flags */ +/* 12 bits of per-record data can be stored in the bottom of the flags */ #define CLF_FLAGSHIFT 12 -#define CLF_FLAGMASK ((1U << CLF_FLAGSHIFT) - 1) -#define CLF_VERMASK (~CLF_FLAGMASK) enum changelog_rec_flags { CLF_VERSION = 0x1000, CLF_RENAME = 0x2000, CLF_JOBID = 0x4000, CLF_EXTRA_FLAGS = 0x8000, - CLF_SUPPORTED = CLF_VERSION | CLF_RENAME | CLF_JOBID | CLF_EXTRA_FLAGS + CLF_SUPPORTED = CLF_VERSION | CLF_RENAME | CLF_JOBID | + CLF_EXTRA_FLAGS, + CLF_FLAGMASK = (1U << CLF_FLAGSHIFT) - 1, + CLF_VERMASK = ~CLF_FLAGMASK, }; @@ -1209,29 +1210,32 @@ static inline enum hsm_event hsm_get_cl_event(__u16 flags) CLF_HSM_EVENT_L); } -static inline void hsm_set_cl_event(int *flags, enum hsm_event he) +static inline void hsm_set_cl_event(enum changelog_rec_flags *clf_flags, + enum hsm_event he) { - *flags |= (he << CLF_HSM_EVENT_L); + *clf_flags |= (he << CLF_HSM_EVENT_L); } -static inline __u16 hsm_get_cl_flags(int flags) +static inline __u16 hsm_get_cl_flags(enum changelog_rec_flags clf_flags) { - return CLF_GET_BITS(flags, CLF_HSM_FLAG_H, CLF_HSM_FLAG_L); + return CLF_GET_BITS(clf_flags, CLF_HSM_FLAG_H, CLF_HSM_FLAG_L); } -static inline void hsm_set_cl_flags(int *flags, int bits) +static inline void hsm_set_cl_flags(enum changelog_rec_flags *clf_flags, + unsigned int bits) { - *flags |= (bits << CLF_HSM_FLAG_L); + *clf_flags |= (bits << CLF_HSM_FLAG_L); } -static inline int hsm_get_cl_error(int flags) +static inline int hsm_get_cl_error(enum changelog_rec_flags clf_flags) { - return CLF_GET_BITS(flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L); + return CLF_GET_BITS(clf_flags, CLF_HSM_ERR_H, CLF_HSM_ERR_L); } -static inline void hsm_set_cl_error(int *flags, int error) +static inline void hsm_set_cl_error(enum changelog_rec_flags *clf_flags, + unsigned int error) { - *flags |= (error << CLF_HSM_ERR_L); + *clf_flags |= (error << CLF_HSM_ERR_L); } enum changelog_rec_extra_flags { @@ -1326,7 +1330,7 @@ struct changelog_ext_nid { __u32 padding; }; -/* Changelog extra extension to include OPEN mode. */ +/* Changelog extra extension to include low 32 bits of MDS_OPEN_* flags. */ struct changelog_ext_openmode { __u32 cr_openflags; }; diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 4ecd99c..a2ecd51 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -718,17 +718,17 @@ static int mdd_llog_record_calc_size(const struct lu_env *env, const struct lu_name *sname) { const struct lu_ucred *uc = lu_ucred(env); - enum changelog_rec_flags crf = CLF_EXTRA_FLAGS; + enum changelog_rec_flags clf_flags = CLF_EXTRA_FLAGS; enum changelog_rec_extra_flags crfe = CLFE_UIDGID | CLFE_NID; if (sname != NULL) - crf |= CLF_RENAME; + clf_flags |= CLF_RENAME; if (uc != NULL && uc->uc_jobid[0] != '\0') - crf |= CLF_JOBID; + clf_flags |= CLF_JOBID; return llog_data_len(LLOG_CHANGELOG_HDR_SZ + - changelog_rec_offset(crf, crfe) + + changelog_rec_offset(clf_flags, crfe) + (tname != NULL ? tname->ln_namelen : 0) + (sname != NULL ? 1 + sname->ln_namelen : 0)); } @@ -911,17 +911,17 @@ void mdd_changelog_rec_extra_nid(struct changelog_rec *rec, clnid->cr_nid = nid; } -void mdd_changelog_rec_extra_omode(struct changelog_rec *rec, int flags) +void mdd_changelog_rec_extra_omode(struct changelog_rec *rec, u32 flags) { struct changelog_ext_openmode *omd = changelog_rec_openmode(rec); - omd->cr_openflags = (__u32)flags; + omd->cr_openflags = flags; } void mdd_changelog_rec_extra_xattr(struct changelog_rec *rec, const char *xattr_name) { - struct changelog_ext_xattr *xattr = changelog_rec_xattr(rec); + struct changelog_ext_xattr *xattr = changelog_rec_xattr(rec); strlcpy(xattr->cr_xattr, xattr_name, sizeof(xattr->cr_xattr)); } @@ -940,7 +940,7 @@ void mdd_changelog_rec_extra_xattr(struct changelog_rec *rec, int mdd_changelog_ns_store(const struct lu_env *env, struct mdd_device *mdd, enum changelog_rec_type type, - enum changelog_rec_flags crf, + enum changelog_rec_flags clf_flags, struct mdd_object *target, const struct lu_fid *tpfid, const struct lu_fid *sfid, @@ -970,24 +970,24 @@ int mdd_changelog_ns_store(const struct lu_env *env, RETURN(-ENOMEM); rec = buf->lb_buf; - crf &= CLF_FLAGMASK; - crf |= CLF_EXTRA_FLAGS; + clf_flags &= CLF_FLAGMASK; + clf_flags |= CLF_EXTRA_FLAGS; if (uc) { if (uc->uc_jobid[0] != '\0') - crf |= CLF_JOBID; + clf_flags |= CLF_JOBID; xflags |= CLFE_UIDGID; xflags |= CLFE_NID; } if (sname != NULL) - crf |= CLF_RENAME; + clf_flags |= CLF_RENAME; else - crf |= CLF_VERSION; + clf_flags |= CLF_VERSION; - rec->cr.cr_flags = crf; + rec->cr.cr_flags = clf_flags; - if (crf & CLF_EXTRA_FLAGS) { + if (clf_flags & CLF_EXTRA_FLAGS) { mdd_changelog_rec_ext_extra_flags(&rec->cr, xflags); if (xflags & CLFE_UIDGID) mdd_changelog_rec_extra_uidgid(&rec->cr, @@ -1001,10 +1001,10 @@ int mdd_changelog_ns_store(const struct lu_env *env, rec->cr.cr_namelen = tname->ln_namelen; memcpy(changelog_rec_name(&rec->cr), tname->ln_name, tname->ln_namelen); - if (crf & CLF_RENAME) + if (clf_flags & CLF_RENAME) mdd_changelog_rec_ext_rename(&rec->cr, sfid, spfid, sname); - if (crf & CLF_JOBID) + if (clf_flags & CLF_JOBID) mdd_changelog_rec_ext_jobid(&rec->cr, uc->uc_jobid); if (likely(target != NULL)) { diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 1406099..ba43571 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -325,18 +325,19 @@ void mdd_changelog_rec_extra_uidgid(struct changelog_rec *rec, __u64 uid, __u64 gid); void mdd_changelog_rec_extra_nid(struct changelog_rec *rec, lnet_nid_t nid); -void mdd_changelog_rec_extra_omode(struct changelog_rec *rec, int flags); +void mdd_changelog_rec_extra_omode(struct changelog_rec *rec, u32 flags); void mdd_changelog_rec_extra_xattr(struct changelog_rec *rec, const char *xattr_name); int mdd_changelog_store(const struct lu_env *env, struct mdd_device *mdd, struct llog_changelog_rec *rec, struct thandle *th); int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd, - enum changelog_rec_type type, int flags, + enum changelog_rec_type type, + enum changelog_rec_flags clf_flags, struct mdd_object *mdd_obj, struct thandle *handle); int mdd_changelog_ns_store(const struct lu_env *env, struct mdd_device *mdd, enum changelog_rec_type type, - enum changelog_rec_flags crf, + enum changelog_rec_flags clf_flags, struct mdd_object *target, const struct lu_fid *tpfid, const struct lu_fid *sfid, @@ -357,7 +358,8 @@ int mdd_stripe_get(const struct lu_env *env, struct mdd_object *obj, int mdd_changelog_data_store_xattr(const struct lu_env *env, struct mdd_device *mdd, enum changelog_rec_type type, - int flags, struct mdd_object *mdd_obj, + enum changelog_rec_flags clf_flags, + struct mdd_object *mdd_obj, const char *xattr_name, struct thandle *handle); diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 5044a03..c04c685 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -70,7 +70,8 @@ static int mdd_xattr_get(const struct lu_env *env, static int mdd_changelog_data_store_by_fid(const struct lu_env *env, struct mdd_device *mdd, enum changelog_rec_type type, - int flags, const struct lu_fid *fid, + enum changelog_rec_flags clf_flags, + const struct lu_fid *fid, const char *xattr_name, struct thandle *handle); @@ -179,7 +180,6 @@ static int mdd_obj_user_add(struct mdd_object *mdd_obj, __u32 gid = mou->mou_uidgid & ((1UL << 32) - 1); ENTRY; - tmp = mdd_obj_user_find(mdd_obj, uid, gid, mou->mou_open_flags); if (tmp != NULL) RETURN(-EEXIST); @@ -844,22 +844,23 @@ static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj, static int mdd_changelog_data_store_by_fid(const struct lu_env *env, struct mdd_device *mdd, enum changelog_rec_type type, - int flags, const struct lu_fid *fid, + enum changelog_rec_flags clf_flags, + const struct lu_fid *fid, const char *xattr_name, struct thandle *handle) { const struct lu_ucred *uc = lu_ucred(env); + enum changelog_rec_extra_flags xflags = CLFE_INVALID; struct llog_changelog_rec *rec; struct lu_buf *buf; int reclen; - int xflags = CLFE_INVALID; int rc; - flags = (flags & CLF_FLAGMASK) | CLF_VERSION | CLF_EXTRA_FLAGS; + clf_flags = (clf_flags & CLF_FLAGMASK) | CLF_VERSION | CLF_EXTRA_FLAGS; if (uc) { if (uc->uc_jobid[0] != '\0') - flags |= CLF_JOBID; + clf_flags |= CLF_JOBID; xflags |= CLFE_UIDGID; xflags |= CLFE_NID; } @@ -869,7 +870,7 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env, xflags |= CLFE_XATTR; reclen = llog_data_len(LLOG_CHANGELOG_HDR_SZ + - changelog_rec_offset(flags & CLF_SUPPORTED, + changelog_rec_offset(clf_flags & CLF_SUPPORTED, xflags & CLFE_SUPPORTED)); buf = lu_buf_check_and_alloc(&mdd_env_info(env)->mti_big_buf, reclen); if (buf->lb_buf == NULL) @@ -877,15 +878,15 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env, rec = buf->lb_buf; rec->cr_hdr.lrh_len = reclen; - rec->cr.cr_flags = flags; + rec->cr.cr_flags = clf_flags; rec->cr.cr_type = (__u32)type; rec->cr.cr_tfid = *fid; rec->cr.cr_namelen = 0; - if (flags & CLF_JOBID) + if (clf_flags & CLF_JOBID) mdd_changelog_rec_ext_jobid(&rec->cr, uc->uc_jobid); - if (flags & CLF_EXTRA_FLAGS) { + if (clf_flags & CLF_EXTRA_FLAGS) { mdd_changelog_rec_ext_extra_flags(&rec->cr, xflags); if (xflags & CLFE_UIDGID) mdd_changelog_rec_extra_uidgid(&rec->cr, @@ -893,7 +894,7 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env, if (xflags & CLFE_NID) mdd_changelog_rec_extra_nid(&rec->cr, uc->uc_nid); if (xflags & CLFE_OPEN) - mdd_changelog_rec_extra_omode(&rec->cr, flags); + mdd_changelog_rec_extra_omode(&rec->cr, clf_flags); if (xflags & CLFE_XATTR) { if (xattr_name == NULL) RETURN(-EINVAL); @@ -913,7 +914,8 @@ static int mdd_changelog_data_store_by_fid(const struct lu_env *env, * \param handle - transaction handle */ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd, - enum changelog_rec_type type, int flags, + enum changelog_rec_type type, + enum changelog_rec_flags clf_flags, struct mdd_object *mdd_obj, struct thandle *handle) { int rc; @@ -935,7 +937,7 @@ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd, RETURN(0); } - rc = mdd_changelog_data_store_by_fid(env, mdd, type, flags, + rc = mdd_changelog_data_store_by_fid(env, mdd, type, clf_flags, mdo2fid(mdd_obj), NULL, handle); if (rc == 0) mdd_obj->mod_cltime = ktime_get(); @@ -946,11 +948,12 @@ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd, int mdd_changelog_data_store_xattr(const struct lu_env *env, struct mdd_device *mdd, enum changelog_rec_type type, - int flags, struct mdd_object *mdd_obj, + enum changelog_rec_flags clf_flags, + struct mdd_object *mdd_obj, const char *xattr_name, struct thandle *handle) { - int rc; + int rc; LASSERT(mdd_obj != NULL); LASSERT(handle != NULL); @@ -970,7 +973,7 @@ int mdd_changelog_data_store_xattr(const struct lu_env *env, RETURN(0); } - rc = mdd_changelog_data_store_by_fid(env, mdd, type, flags, + rc = mdd_changelog_data_store_by_fid(env, mdd, type, clf_flags, mdo2fid(mdd_obj), xattr_name, handle); if (rc == 0) @@ -979,8 +982,11 @@ int mdd_changelog_data_store_xattr(const struct lu_env *env, RETURN(rc); } +/* only the bottom CLF_FLAGSHIFT bits of @flags are stored in the record, + * except for open flags have a dedicated record to store 32 bits of flags */ static int mdd_changelog(const struct lu_env *env, enum changelog_rec_type type, - int flags, struct md_device *m, const struct lu_fid *fid) + enum changelog_rec_flags clf_flags, + struct md_device *m, const struct lu_fid *fid) { struct thandle *handle; struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev); @@ -1006,7 +1012,7 @@ static int mdd_changelog(const struct lu_env *env, enum changelog_rec_type type, if (rc) GOTO(stop, rc); - rc = mdd_changelog_data_store_by_fid(env, mdd, type, flags, + rc = mdd_changelog_data_store_by_fid(env, mdd, type, clf_flags, fid, NULL, handle); stop: @@ -1047,8 +1053,8 @@ static int mdd_attr_set_changelog(const struct lu_env *env, /* The record type is the lowest non-masked set bit */ type = __ffs(bits); - /* FYI we only store the first CLF_FLAGMASK bits of la_valid */ - return mdd_changelog_data_store(env, mdd, type, (int)valid, + /* XXX: we only store the low CLF_FLAGMASK bits of la_valid */ + return mdd_changelog_data_store(env, mdd, type, valid, md2mdd_obj(obj), handle); } @@ -1373,16 +1379,17 @@ static int mdd_declare_xattr_set(const struct lu_env *env, static int mdd_hsm_update_locked(const struct lu_env *env, struct md_object *obj, const struct lu_buf *buf, - struct thandle *handle, int *cl_flags) + struct thandle *handle, + enum changelog_rec_flags *clf_flags) { struct mdd_thread_info *info = mdd_env_info(env); - struct mdd_object *mdd_obj = md2mdd_obj(obj); - struct lu_buf *current_buf; - struct md_hsm *current_mh; - struct md_hsm *new_mh; - int rc; - ENTRY; + struct mdd_object *mdd_obj = md2mdd_obj(obj); + struct lu_buf *current_buf; + struct md_hsm *current_mh; + struct md_hsm *new_mh; + int rc; + ENTRY; OBD_ALLOC_PTR(current_mh); if (current_mh == NULL) RETURN(-ENOMEM); @@ -1407,9 +1414,9 @@ static int mdd_hsm_update_locked(const struct lu_env *env, /* Flags differ, set flags for the changelog that will be added */ if (current_mh->mh_flags != new_mh->mh_flags) { - hsm_set_cl_event(cl_flags, HE_STATE); + hsm_set_cl_event(clf_flags, HE_STATE); if (new_mh->mh_flags & HS_DIRTY) - hsm_set_cl_flags(cl_flags, CLF_HSM_DIRTY); + hsm_set_cl_flags(clf_flags, CLF_HSM_DIRTY); } OBD_FREE_PTR(new_mh); @@ -1817,13 +1824,13 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj, const struct lu_buf *buf, const char *name, int fl) { - struct mdd_object *mdd_obj = md2mdd_obj(obj); - struct lu_attr *attr = MDD_ENV_VAR(env, cattr); - struct mdd_device *mdd = mdo2mdd(obj); - struct thandle *handle; + struct mdd_object *mdd_obj = md2mdd_obj(obj); + struct lu_attr *attr = MDD_ENV_VAR(env, cattr); + struct mdd_device *mdd = mdo2mdd(obj); + struct thandle *handle; enum changelog_rec_type cl_type; - int cl_flags = 0; - int rc; + enum changelog_rec_flags clf_flags = 0; + int rc; ENTRY; rc = mdd_la_get(env, mdd_obj, attr); @@ -1896,7 +1903,7 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj, mdd_write_lock(env, mdd_obj, MOR_TGT_CHILD); if (strcmp(XATTR_NAME_HSM, name) == 0) { - rc = mdd_hsm_update_locked(env, obj, buf, handle, &cl_flags); + rc = mdd_hsm_update_locked(env, obj, buf, handle, &clf_flags); if (rc) { mdd_write_unlock(env, mdd_obj); GOTO(stop, rc); @@ -1912,7 +1919,7 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj, if (cl_type < 0) GOTO(stop, rc = 0); - rc = mdd_changelog_data_store_xattr(env, mdd, cl_type, cl_flags, + rc = mdd_changelog_data_store_xattr(env, mdd, cl_type, clf_flags, mdd_obj, name, handle); EXIT; @@ -2043,8 +2050,8 @@ static int mdd_xattr_hsm_replace(const struct lu_env *env, struct thandle *handle) { struct hsm_attrs *attrs; - __u32 hsm_flags; - int flags = 0; + enum hsm_states hsm_flags; + enum changelog_rec_flags clf_flags = 0; int rc; ENTRY; @@ -2059,9 +2066,9 @@ static int mdd_xattr_hsm_replace(const struct lu_env *env, RETURN(0); /* Add a changelog record for release. */ - hsm_set_cl_event(&flags, HE_RELEASE); + hsm_set_cl_event(&clf_flags, HE_RELEASE); rc = mdd_changelog_data_store(env, mdo2mdd(&o->mod_obj), CL_HSM, - flags, o, handle); + clf_flags, o, handle); RETURN(rc); } @@ -3089,6 +3096,7 @@ find: } } + /* FYI, only the bottom 32 bits of open_flags are recorded */ mdd_changelog(env, type, open_flags, md_dev, mdo2fid(mdd_obj)); EXIT; @@ -3291,8 +3299,9 @@ out: GOTO(stop, rc); } + /* FYI, only the bottom 32 bits of open_flags are recorded */ mdd_changelog_data_store(env, mdd, CL_CLOSE, open_flags, - mdd_obj, handle); + mdd_obj, handle); } stop: diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index cc5910d..19fd0f5 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -311,7 +311,7 @@ static int mdt_cdt_started_cb(const struct lu_env *env, struct cdt_agent_req *car; time64_t now = ktime_get_real_seconds(); time64_t last; - int cl_flags; + enum changelog_rec_flags clf_flags; int rc; if (!hsd->hsd_housekeeping) @@ -343,30 +343,30 @@ static int mdt_cdt_started_cb(const struct lu_env *env, } /* Emit a changelog record for the failed action.*/ - cl_flags = 0; - hsm_set_cl_error(&cl_flags, ECANCELED); + clf_flags = 0; + hsm_set_cl_error(&clf_flags, ECANCELED); switch (hai->hai_action) { case HSMA_ARCHIVE: - hsm_set_cl_event(&cl_flags, HE_ARCHIVE); + hsm_set_cl_event(&clf_flags, HE_ARCHIVE); break; case HSMA_RESTORE: - hsm_set_cl_event(&cl_flags, HE_RESTORE); + hsm_set_cl_event(&clf_flags, HE_RESTORE); break; case HSMA_REMOVE: - hsm_set_cl_event(&cl_flags, HE_REMOVE); + hsm_set_cl_event(&clf_flags, HE_REMOVE); break; case HSMA_CANCEL: - hsm_set_cl_event(&cl_flags, HE_CANCEL); + hsm_set_cl_event(&clf_flags, HE_CANCEL); break; default: /* Unknown record type, skip changelog. */ - cl_flags = 0; + clf_flags = 0; break; } - if (cl_flags != 0) - mo_changelog(env, CL_HSM, cl_flags, mdt->mdt_child, + if (clf_flags != 0) + mo_changelog(env, CL_HSM, clf_flags, mdt->mdt_child, &hai->hai_fid); if (hai->hai_action == HSMA_RESTORE) @@ -1389,16 +1389,17 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, 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; + 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; + enum changelog_rec_flags clf_flags = 0; + struct md_hsm mh; + bool is_mh_changed; + bool need_changelog = true; + int rc = 0; + ENTRY; /* default is to retry */ *status = ARS_WAITING; @@ -1448,25 +1449,24 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, mdt_obd_name(mdt), pgs->hpk_cookie, PFID(&pgs->hpk_fid), pgs->hpk_errval); - hsm_set_cl_error(&cl_flags, - CLF_HSM_ERROVERFLOW); + hsm_set_cl_error(&clf_flags, CLF_HSM_ERROVERFLOW); rc = -EINVAL; } else { - hsm_set_cl_error(&cl_flags, pgs->hpk_errval); + hsm_set_cl_error(&clf_flags, pgs->hpk_errval); } switch (car->car_hai->hai_action) { case HSMA_ARCHIVE: - hsm_set_cl_event(&cl_flags, HE_ARCHIVE); + hsm_set_cl_event(&clf_flags, HE_ARCHIVE); break; case HSMA_RESTORE: - hsm_set_cl_event(&cl_flags, HE_RESTORE); + hsm_set_cl_event(&clf_flags, HE_RESTORE); break; case HSMA_REMOVE: - hsm_set_cl_event(&cl_flags, HE_REMOVE); + hsm_set_cl_event(&clf_flags, HE_REMOVE); break; case HSMA_CANCEL: - hsm_set_cl_event(&cl_flags, HE_CANCEL); + hsm_set_cl_event(&clf_flags, HE_CANCEL); CERROR("%s: Failed request %#llx on "DFID " cannot be a CANCEL\n", mdt_obd_name(mdt), @@ -1486,7 +1486,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, *status = ARS_SUCCEED; switch (car->car_hai->hai_action) { case HSMA_ARCHIVE: - hsm_set_cl_event(&cl_flags, HE_ARCHIVE); + hsm_set_cl_event(&clf_flags, HE_ARCHIVE); /* set ARCHIVE keep EXIST and clear LOST and * DIRTY */ mh.mh_arch_ver = pgs->hpk_data_version; @@ -1495,7 +1495,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, is_mh_changed = true; break; case HSMA_RESTORE: - hsm_set_cl_event(&cl_flags, HE_RESTORE); + hsm_set_cl_event(&clf_flags, HE_RESTORE); /* do not clear RELEASED and DIRTY here * this will occur in hsm_swap_layouts() @@ -1507,13 +1507,13 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, is_mh_changed = true; break; case HSMA_REMOVE: - hsm_set_cl_event(&cl_flags, HE_REMOVE); + hsm_set_cl_event(&clf_flags, HE_REMOVE); /* clear ARCHIVED EXISTS and LOST */ mh.mh_flags &= ~(HS_ARCHIVED | HS_EXISTS | HS_LOST); is_mh_changed = true; break; case HSMA_CANCEL: - hsm_set_cl_event(&cl_flags, HE_CANCEL); + hsm_set_cl_event(&clf_flags, HE_CANCEL); CERROR("%s: Successful request %#llx on "DFID" cannot be a CANCEL\n", mdt_obd_name(mdt), pgs->hpk_cookie, @@ -1535,7 +1535,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, * filled */ if (rc == 0 && !IS_ERR(obj)) - hsm_set_cl_flags(&cl_flags, + hsm_set_cl_flags(&clf_flags, mh.mh_flags & HS_DIRTY ? CLF_HSM_DIRTY : 0); /* unlock is done later, after layout lock management */ @@ -1564,7 +1564,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, /* restore special case, need to create ChangeLog record * before to give back layout lock to avoid concurrent * file updater to post out of order ChangeLog */ - mo_changelog(env, CL_HSM, cl_flags, mdt->mdt_child, + mo_changelog(env, CL_HSM, clf_flags, mdt->mdt_child, &car->car_hai->hai_fid); need_changelog = false; @@ -1576,7 +1576,7 @@ static int hsm_cdt_request_completed(struct mdt_thread_info *mti, out: /* always add a ChangeLog record */ if (need_changelog) - mo_changelog(env, CL_HSM, cl_flags, mdt->mdt_child, + mo_changelog(env, CL_HSM, clf_flags, mdt->mdt_child, &car->car_hai->hai_fid); if (!IS_ERR(obj))