X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_hsm_cdt_client.c;h=4e837d6a3b7fd152c13b7da7871b8167528dc62c;hb=4e41ef7e1632e2223d4b8cb7ee3f02d424d713ff;hp=b0c01c90830a6de8310b27d0041dfe62d98785a6;hpb=9bc0d837eb0cfc7e1d9ce702057761560d66434c;p=fs%2Flustre-release.git diff --git a/lustre/mdt/mdt_hsm_cdt_client.c b/lustre/mdt/mdt_hsm_cdt_client.c index b0c01c9..4e837d6 100644 --- a/lustre/mdt/mdt_hsm_cdt_client.c +++ b/lustre/mdt/mdt_hsm_cdt_client.c @@ -111,32 +111,30 @@ static int hsm_find_compatible(const struct lu_env *env, struct mdt_device *mdt, struct hsm_action_list *hal) { struct hsm_action_item *hai; - int rc, i, ok_cnt; + int rc = 0, i; + bool check = false; ENTRY; - ok_cnt = 0; hai = hai_first(hal); for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) { /* We only support ARCHIVE, RESTORE, REMOVE and CANCEL here. */ if (hai->hai_action == HSMA_NONE) RETURN(-EINVAL); - /* in a cancel request hai_cookie may be set by caller to - * show the request to be canceled - * if not we need to search by FID + /* In a cancel request hai_cookie may be set by caller to show + * the request to be canceled. If there is at least one cancel + * request that does not have a cookie set we need to search by + * FID; we can skip checking in all other cases */ - if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie != 0) - ok_cnt++; - else - hai->hai_cookie = 0; + if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie == 0) { + check = true; + break; + } } - /* if all requests are cancel with cookie, no need to find compatible */ - if (ok_cnt == hal->hal_count) - RETURN(0); - - rc = cdt_llog_process(env, mdt, hsm_find_compatible_cb, hal, 0, 0, - READ); + if (check) + rc = cdt_llog_process(env, mdt, hsm_find_compatible_cb, hal, 0, + 0, READ); RETURN(rc); } @@ -241,7 +239,7 @@ hsm_action_permission(struct mdt_thread_info *mti, if (hsma != HSMA_RESTORE && mdt_rdonly(mti->mti_exp)) RETURN(-EROFS); - if (md_capable(uc, CFS_CAP_SYS_ADMIN)) + if (cap_raised(uc->uc_cap, CAP_SYS_ADMIN)) RETURN(0); ma->ma_need = MA_INODE; @@ -315,7 +313,7 @@ static int mdt_hsm_register_hal(struct mdt_thread_info *mti, /* In case of REMOVE and CANCEL a Lustre file * is not mandatory, but restrict this * exception to admins. */ - if (md_capable(mdt_ucred(mti), CFS_CAP_SYS_ADMIN) && + if (cap_raised(mdt_ucred(mti)->uc_cap, CAP_SYS_ADMIN) && (hai->hai_action == HSMA_REMOVE || hai->hai_action == HSMA_CANCEL)) goto record; @@ -367,8 +365,16 @@ static int mdt_hsm_register_hal(struct mdt_thread_info *mti, if (hai->hai_extent.offset != 0) GOTO(out, rc = -EPROTO); + /* LU-15132 */ + OBD_RACE(OBD_FAIL_MDS_HSM_RESTORE_RACE); + rc = cdt_restore_handle_add(mti, cdt, &hai->hai_fid, &hai->hai_extent); + if (rc == 1) { + rc = 0; + continue; + } + if (rc < 0) GOTO(out, rc); } @@ -420,7 +426,7 @@ int mdt_hsm_add_actions(struct mdt_thread_info *mti, ENTRY; /* no coordinator started, so we cannot serve requests */ - if (cdt->cdt_state == CDT_STOPPED) + if (cdt->cdt_state == CDT_STOPPED || cdt->cdt_state == CDT_INIT) RETURN(-EAGAIN); if (!hal_is_sane(hal)) @@ -535,15 +541,12 @@ int mdt_hsm_get_action(struct mdt_thread_info *mti, RETURN(0); car = mdt_cdt_find_request(cdt, hgad.hgad_hai.hai_cookie); - if (car != NULL) { - __u64 data_moved; - - mdt_cdt_get_work_done(car, &data_moved); - /* this is just to give the volume of data moved - * it means data_moved data have been moved from the - * original request but we do not know which one + if (car) { + /* This is just to give the volume of data moved. + * It means 'car_progress' data have been moved from the + * original request but we do not know which one. */ - extent->length = data_moved; + extent->length = car->car_progress.crp_total; mdt_cdt_put_request(car); }