X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_hsm_cdt_client.c;h=9d0335c2752fc227e928c0dacaf1b4e0f02b791a;hp=aa4f123270820b0a40a68404b3bfc9738d3799fd;hb=ccabce23bd9e366c345c852f565766a799f61238;hpb=37a5157b84bce367e31743cb8648a15618492531 diff --git a/lustre/mdt/mdt_hsm_cdt_client.c b/lustre/mdt/mdt_hsm_cdt_client.c index aa4f123..9d0335c 100644 --- a/lustre/mdt/mdt_hsm_cdt_client.c +++ b/lustre/mdt/mdt_hsm_cdt_client.c @@ -23,7 +23,7 @@ * (C) Copyright 2012 Commissariat a l'energie atomique et aux energies * alternatives * - * Copyright (c) 2013, 2014, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. */ /* * lustre/mdt/mdt_hsm_cdt_client.c @@ -281,48 +281,22 @@ hsm_action_permission(struct mdt_thread_info *mti, RETURN(*mask & (1UL << hsma) ? 0 : -EPERM); } -/* - * Coordinator external API - */ - -/** - * register a list of requests - * \param mti [IN] - * \param hal [IN] list of requests - * \retval 0 success - * \retval -ve failure - * in case of restore, caller must hold layout lock - */ -int mdt_hsm_add_actions(struct mdt_thread_info *mti, - struct hsm_action_list *hal) +/* Process a single HAL. hsm_find_compatible has already been called + * on it. */ +static int mdt_hsm_register_hal(struct mdt_thread_info *mti, + struct mdt_device *mdt, + struct coordinator *cdt, + struct hsm_action_list *hal) { - struct mdt_device *mdt = mti->mti_mdt; - struct coordinator *cdt = &mdt->mdt_coordinator; struct hsm_action_item *hai; struct mdt_object *obj = NULL; - int rc = 0, i; + int rc, i; struct md_hsm mh; bool is_restore = false; __u64 compound_id; - ENTRY; - - /* no coordinator started, so we cannot serve requests */ - if (cdt->cdt_state == CDT_STOPPED) - RETURN(-EAGAIN); - - if (!hal_is_sane(hal)) - RETURN(-EINVAL); compound_id = atomic_inc_return(&cdt->cdt_compound_id); - /* search for compatible request, if found hai_cookie is set - * to the request cookie - * it is also used to set the cookie for cancel request by FID - */ - rc = hsm_find_compatible(mti->mti_env, mdt, hal); - if (rc) - GOTO(out, rc); - hai = hai_first(hal); for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) { int archive_id; @@ -478,6 +452,49 @@ record: rc = 0; GOTO(out, rc); + +out: + return rc; +} + +/* + * Coordinator external API + */ + +/** + * register a list of requests + * \param mti [IN] + * \param hal [IN] list of requests + * \retval 0 success + * \retval -ve failure + * in case of restore, caller must hold layout lock + */ +int mdt_hsm_add_actions(struct mdt_thread_info *mti, + struct hsm_action_list *hal) +{ + struct mdt_device *mdt = mti->mti_mdt; + struct coordinator *cdt = &mdt->mdt_coordinator; + int rc; + ENTRY; + + /* no coordinator started, so we cannot serve requests */ + if (cdt->cdt_state == CDT_STOPPED) + RETURN(-EAGAIN); + + if (!hal_is_sane(hal)) + RETURN(-EINVAL); + + /* search for compatible request, if found hai_cookie is set + * to the request cookie + * it is also used to set the cookie for cancel request by FID + */ + rc = hsm_find_compatible(mti->mti_env, mdt, hal); + if (rc) + GOTO(out, rc); + + rc = mdt_hsm_register_hal(mti, mdt, cdt, hal); + + GOTO(out, rc); out: /* if work has been added, signal the coordinator */ if (rc == 0 || rc == -ENODATA)