X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_hsm_cdt_actions.c;h=93c4a056cd892582eda066485e2fc7d7d6512933;hb=c456938942b5683f7532c793fd927ea719482b10;hp=abb3e6a4aaccc12440b2b7dccbe26787dab7a80b;hpb=65effa6dcb5e34ec9e91c86e35c52bc85562cf8b;p=fs%2Flustre-release.git diff --git a/lustre/mdt/mdt_hsm_cdt_actions.c b/lustre/mdt/mdt_hsm_cdt_actions.c index abb3e6a..93c4a05 100644 --- a/lustre/mdt/mdt_hsm_cdt_actions.c +++ b/lustre/mdt/mdt_hsm_cdt_actions.c @@ -23,7 +23,7 @@ * (C) Copyright 2012 Commissariat a l'energie atomique et aux energies * alternatives * - * Copyright (c) 2013, 2016, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. */ /* * lustre/mdt/mdt_hsm_cdt_actions.c @@ -175,7 +175,7 @@ void dump_llog_agent_req_rec(const char *prefix, sz = larr->arr_hai.hai_len - sizeof(larr->arr_hai); CDEBUG(D_HSM, "%slrh=[type=%X len=%d idx=%d] fid="DFID " dfid="DFID - " compound/cookie=%#llx/%#llx" + " cookie=%#llx" " status=%s action=%s archive#=%d flags=%#llx" " create=%llu change=%llu" " extent=%#llx-%#llx gid=%#llx datalen=%d" @@ -185,7 +185,7 @@ void dump_llog_agent_req_rec(const char *prefix, larr->arr_hdr.lrh_len, larr->arr_hdr.lrh_index, PFID(&larr->arr_hai.hai_fid), PFID(&larr->arr_hai.hai_dfid), - larr->arr_compound_id, larr->arr_hai.hai_cookie, + larr->arr_hai.hai_cookie, agent_req_status2name(larr->arr_status), hsm_copytool_action2name(larr->arr_hai.hai_action), larr->arr_archive_id, @@ -250,16 +250,14 @@ int cdt_llog_process(const struct lu_env *env, struct mdt_device *mdt, * add an entry in agent llog * \param env [IN] environment * \param mdt [IN] PDT device - * \param compound_id [IN] global id associated with the record * \param archive_id [IN] backend archive number * \param hai [IN] record to register * \retval 0 success * \retval -ve failure */ -int mdt_agent_record_add(const struct lu_env *env, - struct mdt_device *mdt, - __u64 compound_id, __u32 archive_id, - __u64 flags, struct hsm_action_item *hai) +int mdt_agent_record_add(const struct lu_env *env, struct mdt_device *mdt, + __u32 archive_id, __u64 flags, + struct hsm_action_item *hai) { struct obd_device *obd = mdt2obd_dev(mdt); struct coordinator *cdt = &mdt->mdt_coordinator; @@ -276,10 +274,9 @@ int mdt_agent_record_add(const struct lu_env *env, larr->arr_hdr.lrh_len = sz; larr->arr_hdr.lrh_type = HSM_AGENT_REC; larr->arr_status = ARS_WAITING; - larr->arr_compound_id = compound_id; larr->arr_archive_id = archive_id; larr->arr_flags = flags; - larr->arr_req_create = cfs_time_current_sec(); + larr->arr_req_create = ktime_get_real_seconds(); larr->arr_req_change = larr->arr_req_create; memcpy(&larr->arr_hai, hai, hai->hai_len); @@ -318,11 +315,10 @@ free: */ struct data_update_cb { struct mdt_device *mdt; - __u64 *cookies; - int cookies_count; - int cookies_done; - enum agent_req_status status; - cfs_time_t change_time; + struct hsm_record_update *updates; + unsigned int updates_count; + unsigned int updates_done; + time64_t change_time; }; /** @@ -348,32 +344,38 @@ static int mdt_agent_record_update_cb(const struct lu_env *env, ducb = data; /* check if all done */ - if (ducb->cookies_count == ducb->cookies_done) + if (ducb->updates_count == ducb->updates_done) RETURN(LLOG_PROC_BREAK); /* if record is in final state, never change */ - /* if record is a cancel request, it cannot be canceled - * this is to manage the following case: - * when a request is canceled, we have 2 records with the - * the same cookie : the one to cancel and the cancel request - * the 1st has to be set to ARS_CANCELED and the 2nd to ARS_SUCCEED - */ - if (agent_req_in_final_state(larr->arr_status) || - (larr->arr_hai.hai_action == HSMA_CANCEL && - ducb->status == ARS_CANCELED)) + if (agent_req_in_final_state(larr->arr_status)) RETURN(0); rc = 0; - for (i = 0 ; i < ducb->cookies_count ; i++) { + for (i = 0 ; i < ducb->updates_count ; i++) { + struct hsm_record_update *update = &ducb->updates[i]; + CDEBUG(D_HSM, "%s: search %#llx, found %#llx\n", - mdt_obd_name(ducb->mdt), ducb->cookies[i], + mdt_obd_name(ducb->mdt), update->cookie, larr->arr_hai.hai_cookie); - if (larr->arr_hai.hai_cookie == ducb->cookies[i]) { - - larr->arr_status = ducb->status; + if (larr->arr_hai.hai_cookie == update->cookie) { + + /* If record is a cancel request, it cannot be + * canceled. This is to manage the following + * case: when a request is canceled, we have 2 + * records with the the same cookie: the one + * to cancel and the cancel request the 1st + * has to be set to ARS_CANCELED and the 2nd + * to ARS_SUCCEED + */ + if (larr->arr_hai.hai_action == HSMA_CANCEL && + update->status == ARS_CANCELED) + RETURN(0); + + larr->arr_status = update->status; larr->arr_req_change = ducb->change_time; rc = llog_write(env, llh, hdr, hdr->lrh_index); - ducb->cookies_done++; + ducb->updates_done++; break; } } @@ -387,17 +389,18 @@ static int mdt_agent_record_update_cb(const struct lu_env *env, /** * update an entry in agent llog + * * \param env [IN] environment * \param mdt [IN] MDT device - * \param cookie [IN] entries to update - * log cookie are returned by register - * \param status [IN] new status of the request - * \retval 0 success - * \retval -ve failure + * \param updates [IN] array of entries to update + * \param updates_count [IN] number of entries in updates + * + * \retval 0 on success + * \retval negative on failure */ int mdt_agent_record_update(const struct lu_env *env, struct mdt_device *mdt, - __u64 *cookies, int cookies_count, - enum agent_req_status status) + struct hsm_record_update *updates, + unsigned int updates_count) { struct data_update_cb ducb; u32 start_cat_idx = -1; @@ -410,13 +413,14 @@ int mdt_agent_record_update(const struct lu_env *env, struct mdt_device *mdt, /* Find the first location (start_cat_idx, start_rec_idx) * among the records corresponding to cookies. */ - for (i = 0; i < cookies_count; i++) { + for (i = 0; i < updates_count; i++) { /* If we cannot find a cached location for a cookie * (perhaps because the MDT was restart then we must * start from the beginning. In this case * mdt_agent_record_hash_get() sets both of cat_idx and * rec_idx to 0. */ - cdt_agent_record_hash_lookup(&mdt->mdt_coordinator, cookies[i], + cdt_agent_record_hash_lookup(&mdt->mdt_coordinator, + updates[i].cookie, &cat_idx, &rec_idx); if (cat_idx < start_cat_idx) { start_cat_idx = cat_idx; @@ -432,20 +436,18 @@ int mdt_agent_record_update(const struct lu_env *env, struct mdt_device *mdt, start_rec_idx -= 1; ducb.mdt = mdt; - ducb.cookies = cookies; - ducb.cookies_count = cookies_count; - ducb.cookies_done = 0; - ducb.status = status; - ducb.change_time = cfs_time_current_sec(); + ducb.updates = updates; + ducb.updates_count = updates_count; + ducb.updates_done = 0; + ducb.change_time = ktime_get_real_seconds(); rc = cdt_llog_process(env, mdt, mdt_agent_record_update_cb, &ducb, start_cat_idx, start_rec_idx, WRITE); if (rc < 0) CERROR("%s: cdt_llog_process() failed, rc=%d, cannot update " - "status to %s for %d cookies, done %d\n", + "status for %u cookies, done %u\n", mdt_obd_name(mdt), rc, - agent_req_status2name(status), - cookies_count, ducb.cookies_done); + updates_count, ducb.updates_done); RETURN(rc); } @@ -554,7 +556,7 @@ static int hsm_actions_show_cb(const struct lu_env *env, llh->lgh_hdr->llh_cat_idx, hdr->lrh_index, PFID(&larr->arr_hai.hai_fid), PFID(&larr->arr_hai.hai_dfid), - larr->arr_compound_id, larr->arr_hai.hai_cookie, + 0ULL /* compound_id */, larr->arr_hai.hai_cookie, hsm_copytool_action2name(larr->arr_hai.hai_action), larr->arr_archive_id, larr->arr_flags, @@ -694,4 +696,3 @@ const struct file_operations mdt_hsm_actions_fops = { .llseek = seq_lseek, .release = lprocfs_release_hsm_actions, }; -