X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_hsm.c;h=ab0e851dea66f85d74222119f758f61bac368db7;hp=edf77ea495d57548c7220147c538a65aa51eccfe;hb=62e93ef9a29341091c49d66a1535ea243ea950be;hpb=f625f670afbe954030ff81f0f8522137d6cdd335 diff --git a/lustre/mdt/mdt_hsm.c b/lustre/mdt/mdt_hsm.c index edf77ea..ab0e851 100644 --- a/lustre/mdt/mdt_hsm.c +++ b/lustre/mdt/mdt_hsm.c @@ -22,9 +22,9 @@ /* * Copyright (c) 2011, 2012 Commissariat a l'energie atomique et aux energies * alternatives - * - * Copyright (c) 2012, 2014, Intel Corporation. * Use is subject to license terms. + * + * Copyright (c) 2012, 2015, Intel Corporation. */ /* * lustre/mdt/mdt_hsm.c @@ -214,8 +214,7 @@ int mdt_hsm_state_get(struct tgt_session_info *tsi) lh = &info->mti_lh[MDT_LH_CHILD]; mdt_lock_reg_init(lh, LCK_PR); - rc = mdt_object_lock(info, obj, lh, MDS_INODELOCK_LOOKUP, - MDT_LOCAL_LOCK); + rc = mdt_object_lock(info, obj, lh, MDS_INODELOCK_LOOKUP); if (rc < 0) GOTO(out_ucred, rc); @@ -276,7 +275,7 @@ int mdt_hsm_state_set(struct tgt_session_info *tsi) lh = &info->mti_lh[MDT_LH_CHILD]; mdt_lock_reg_init(lh, LCK_PW); rc = mdt_object_lock(info, obj, lh, MDS_INODELOCK_LOOKUP | - MDS_INODELOCK_XATTR, MDT_LOCAL_LOCK); + MDS_INODELOCK_XATTR); if (rc < 0) GOTO(out_ucred, rc); @@ -461,6 +460,22 @@ out: return rc; } +/* Return true if a FID is present in an action list. */ +static bool is_fid_in_hal(struct hsm_action_list *hal, const lustre_fid *fid) +{ + struct hsm_action_item *hai; + int i; + + for (hai = hai_first(hal), i = 0; + i < hal->hal_count; + i++, hai = hai_next(hai)) { + if (lu_fid_eq(&hai->hai_fid, fid)) + return true; + } + + return false; +} + /** * Process the HSM actions described in a struct hsm_user_request. * @@ -549,9 +564,14 @@ int mdt_hsm_request(struct tgt_session_info *tsi) obd_uuid2fsname(hal->hal_fsname, mdt_obd_name(info->mti_mdt), MTI_NAME_MAXLEN); - hal->hal_count = hr->hr_itemcount; + hal->hal_count = 0; hai = hai_first(hal); for (i = 0; i < hr->hr_itemcount; i++, hai = hai_next(hai)) { + /* Get rid of duplicate entries. Otherwise we get + * duplicated work in the llog. */ + if (is_fid_in_hal(hal, &hui[i].hui_fid)) + continue; + hai->hai_action = action; hai->hai_cookie = 0; hai->hai_gid = 0; @@ -559,6 +579,8 @@ int mdt_hsm_request(struct tgt_session_info *tsi) hai->hai_extent = hui[i].hui_extent; memcpy(hai->hai_data, data, hr->hr_data_len); hai->hai_len = sizeof(*hai) + hr->hr_data_len; + + hal->hal_count++; } rc = mdt_hsm_add_actions(info, hal, &compound_id);