#endif
/* Return pointer to first hai in action list */
-static inline struct hsm_action_item * hai_zero(struct hsm_action_list *hal)
+static inline struct hsm_action_item *hai_first(struct hsm_action_list *hal)
{
return (struct hsm_action_item *)(hal->hal_fsname +
cfs_size_round(strlen(hal-> \
struct hsm_action_item *hai;
sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname));
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0 ; i < hal->hal_count ; i++, hai = hai_next(hai))
sz += cfs_size_round(hai->hai_len);
__swab32s(&h->hal_count);
__swab32s(&h->hal_archive_id);
__swab64s(&h->hal_flags);
- hai = hai_zero(h);
+ hai = hai_first(h);
for (i = 0; i < h->hal_count; i++, hai = hai_next(hai))
lustre_swab_hai(hai);
}
* \param mti [IN] context
* \param fid [IN] object fid
* \param hsm [OUT] HSM meta data
- * \retval obj
+ * \retval obj or error (-ENOENT if not found)
*/
struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti,
const struct lu_fid *fid,
prefix, hal->hal_version, hal->hal_count,
hal->hal_compound_id, hal->hal_archive_id, hal->hal_flags);
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++) {
sz = hai->hai_len - sizeof(*hai);
CDEBUG(level, "%s %d: fid="DFID" dfid="DFID
continue;
}
}
- if ((found == -1) && (empty_slot == -1))
+ if (found == -1 && empty_slot == -1)
/* unknown request and no more room for new request,
* continue scan for to find other entries for
* already found request
hsd->request[empty_slot].hal = hal;
hsd->request_cnt++;
found = empty_slot;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
} else {
/* request is known */
/* we check if record archive num is the same as the
hsd->request[found].hal = hal_buffer;
hsd->request[found].hal_sz = sz;
}
- hai = hai_zero(hsd->request[found].hal);
+ hai = hai_first(hsd->request[found].hal);
for (i = 0; i < hsd->request[found].hal->hal_count;
i++)
hai = hai_next(hai);
CDEBUG(D_HSM, "coordinator resumes\n");
- if ((cdt->cdt_thread.t_flags & SVC_STOPPING) ||
- (cdt->cdt_state == CDT_STOPPING)) {
+ if (cdt->cdt_thread.t_flags & SVC_STOPPING ||
+ cdt->cdt_state == CDT_STOPPING) {
cdt->cdt_thread.t_flags &= ~SVC_STOPPING;
rc = 0;
break;
kuc_free(hal, hsd.request[i].hal_used_sz);
continue;
}
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (j = 0; j < hsd.request[i].hal->hal_count; j++) {
cookies[j] = hai->hai_cookie;
hai = hai_next(hai);
larr = (struct llog_agent_req_rec *)hdr;
hai = &larr->arr_hai;
- if ((hai->hai_action != HSMA_RESTORE) ||
- agent_req_in_final_state(larr->arr_status))
+ if (hai->hai_action != HSMA_RESTORE ||
+ agent_req_in_final_state(larr->arr_status))
RETURN(0);
/* restore request not in a final state */
int rc;
void *ptr;
struct mdt_thread_info *cdt_mti;
- cfs_task_t *task;
+ struct task_struct *task;
ENTRY;
/* functions defined but not yet used
cdt->cdt_policy = CDT_DEFAULT_POLICY;
cdt->cdt_state = CDT_INIT;
- cfs_atomic_set(&cdt->cdt_compound_id, cfs_time_current_sec());
+ atomic_set(&cdt->cdt_compound_id, cfs_time_current_sec());
/* just need to be larger than previous one */
/* cdt_last_cookie is protected by cdt_llog_lock */
cdt->cdt_last_cookie = cfs_time_current_sec();
ENTRY;
/* register request in memory list */
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
struct cdt_agent_req *car;
*status = ARS_SUCCEED;
break;
default:
- *status = (((cdt->cdt_policy &
- CDT_NORETRY_ACTION) ||
- !(pgs->hpk_flags & HP_FLAG_RETRY)) ?
+ *status = (cdt->cdt_policy & CDT_NORETRY_ACTION ||
+ !(pgs->hpk_flags & HP_FLAG_RETRY) ?
ARS_FAILED : ARS_WAITING);
break;
}
* a crasy CT no need to manage DIRTY
*/
if (rc == 0)
- hsm_set_cl_flags(&cl_flags, ((mh.mh_flags & HS_DIRTY) ?
- CLF_HSM_DIRTY : 0));
+ hsm_set_cl_flags(&cl_flags,
+ mh.mh_flags & HS_DIRTY ? CLF_HSM_DIRTY : 0);
/* unlock is done later, after layout lock management */
if (is_mh_changed)
/* we give back layout lock only if restore was successful or
* if restore was canceled or if policy is to not retry
* in other cases we just unlock the object */
- if ((car->car_hai->hai_action == HSMA_RESTORE) &&
- ((pgs->hpk_errval == 0) || (pgs->hpk_errval == ECANCELED) ||
- (cdt->cdt_policy & CDT_NORETRY_ACTION))) {
+ if (car->car_hai->hai_action == HSMA_RESTORE &&
+ (pgs->hpk_errval == 0 || pgs->hpk_errval == ECANCELED ||
+ cdt->cdt_policy & CDT_NORETRY_ACTION)) {
struct cdt_restore_handle *crh;
/* restore in data FID done, we swap the layouts
GOTO(out, rc);
out:
- if ((obj != NULL) && !IS_ERR(obj)) {
+ if (obj != NULL && !IS_ERR(obj)) {
mo_changelog(env, CL_HSM, cl_flags,
mdt_object_child(obj));
mdt_object_put(mti->mti_env, obj);
" on fid="DFID"\n",
mdt_obd_name(mdt),
pgs->hpk_cookie, PFID(&pgs->hpk_fid));
+ if (car == NULL)
+ RETURN(-ENOENT);
RETURN(PTR_ERR(car));
}
/* progress is done on FID or data FID depending of the action and
* of the copy progress */
/* for restore progress is used to send back the data FID to cdt */
- if ((car->car_hai->hai_action == HSMA_RESTORE) &&
- (lu_fid_eq(&car->car_hai->hai_fid, &car->car_hai->hai_dfid)))
+ if (car->car_hai->hai_action == HSMA_RESTORE &&
+ lu_fid_eq(&car->car_hai->hai_fid, &car->car_hai->hai_dfid))
car->car_hai->hai_dfid = pgs->hpk_fid;
- if (((car->car_hai->hai_action == HSMA_RESTORE) ||
- (car->car_hai->hai_action == HSMA_ARCHIVE)) &&
+ if ((car->car_hai->hai_action == HSMA_RESTORE ||
+ car->car_hai->hai_action == HSMA_ARCHIVE) &&
(!lu_fid_eq(&pgs->hpk_fid, &car->car_hai->hai_dfid) &&
!lu_fid_eq(&pgs->hpk_fid, &car->car_hai->hai_fid))) {
CERROR("%s: Progress on "DFID" for cookie "LPX64
larr = (struct llog_agent_req_rec *)hdr;
hcad = data;
- if ((larr->arr_status == ARS_WAITING) ||
- (larr->arr_status == ARS_STARTED)) {
+ if (larr->arr_status == ARS_WAITING ||
+ larr->arr_status == ARS_STARTED) {
larr->arr_status = ARS_CANCELED;
larr->arr_req_change = cfs_time_current_sec();
rc = mdt_agent_llog_update_rec(env, hcad->mdt, llh, larr);
hal_len = sizeof(*hal) + cfs_size_round(MTI_NAME_MAXLEN + 1) +
cfs_size_round(car->car_hai->hai_len);
- if ((hal_len > hal_sz) && (hal_sz > 0)) {
+ if (hal_len > hal_sz && hal_sz > 0) {
/* not enough room, free old buffer */
OBD_FREE(hal, hal_sz);
hal = NULL;
hal->hal_flags = car->car_flags;
hal->hal_count = 0;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
memcpy(hai, car->car_hai, car->car_hai->hai_len);
hai->hai_action = HSMA_CANCEL;
hal->hal_count = 1;
switch (hai->hai_action) {
case HSMA_ARCHIVE:
if (!(hsm_flags & HS_NOARCHIVE) &&
- ((hsm_flags & HS_DIRTY) || !(hsm_flags & HS_ARCHIVED)))
+ (hsm_flags & HS_DIRTY || !(hsm_flags & HS_ARCHIVED)))
is_compat = true;
break;
case HSMA_RESTORE:
if (!(hsm_flags & HS_DIRTY) && (hsm_flags & HS_RELEASED) &&
- (hsm_flags & HS_ARCHIVED) && !(hsm_flags & HS_LOST))
+ hsm_flags & HS_ARCHIVED && !(hsm_flags & HS_LOST))
is_compat = true;
break;
case HSMA_REMOVE:
b->blocks = 0;
/* if no object is allocated on osts, the size on mds is valid. b=22272 */
b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
- } else if ((ma->ma_valid & MA_LOV) && ma->ma_lmm &&
- (ma->ma_lmm->lmm_pattern & LOV_PATTERN_F_RELEASED)) {
+ } else if ((ma->ma_valid & MA_LOV) && ma->ma_lmm != NULL &&
+ ma->ma_lmm->lmm_pattern & LOV_PATTERN_F_RELEASED) {
/* A released file stores its size on MDS. */
b->blocks = 0;
b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
/* the Lustre protocol supposes to return default striping
* on the user-visible root if explicitly requested */
if ((ma->ma_valid & MA_LOV) == 0 && S_ISDIR(la->la_mode) &&
- (ma->ma_need & MA_LOV_DEF && is_root) && (ma->ma_need & MA_LOV)) {
+ (ma->ma_need & MA_LOV_DEF && is_root) && ma->ma_need & MA_LOV) {
struct lu_fid rootfid;
struct mdt_object *root;
struct mdt_device *mdt = info->mti_mdt;
LASSERT(mdt_object_remote(o));
- LASSERT((ibits & MDS_INODELOCK_UPDATE));
+ LASSERT(ibits & MDS_INODELOCK_UPDATE);
memset(einfo, 0, sizeof(*einfo));
einfo->ei_type = LDLM_IBITS;
linkea_entry_unpack(lee, &reclen, tmpname, tmpfid);
/* If set, use link #linkno for path lookup, otherwise use
link #0. Only do this for the final path element. */
- if ((pli->pli_fidcount == 0) &&
- (pli->pli_linkno < leh->leh_reccount)) {
+ if (pli->pli_fidcount == 0 &&
+ pli->pli_linkno < leh->leh_reccount) {
int count;
for (count = 0; count < pli->pli_linkno; count++) {
lee = (struct link_ea_entry *)
* LOST without ARCHIVED: cannot lost a non-archived file.
*/
flags = ma->ma_hsm.mh_flags;
- if (((flags & HS_DIRTY) && !(flags & HS_EXISTS)) ||
- ((flags & HS_RELEASED) && (flags & HS_DIRTY)) ||
- ((flags & HS_RELEASED) && !(flags & HS_ARCHIVED)) ||
- ((flags & HS_LOST) && !(flags & HS_ARCHIVED))) {
+ if ((flags & HS_DIRTY && !(flags & HS_EXISTS)) ||
+ (flags & HS_RELEASED && flags & HS_DIRTY) ||
+ (flags & HS_RELEASED && !(flags & HS_ARCHIVED)) ||
+ (flags & HS_LOST && !(flags & HS_ARCHIVED))) {
CDEBUG(D_HSM, "Incompatible flag change on "DFID
"flags="LPX64"\n",
PFID(&info->mti_body->fid1), flags);
obd_uuid2fsname(hal->hal_fsname, mdt_obd_name(info->mti_mdt),
MTI_NAME_MAXLEN);
hal->hal_count = 1;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
hai->hai_action = HSMA_NONE;
hai->hai_cookie = 0;
hai->hai_gid = 0;
MTI_NAME_MAXLEN);
hal->hal_count = hr->hr_itemcount;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hr->hr_itemcount; i++, hai = hai_next(hai)) {
hai->hai_action = action;
hai->hai_cookie = 0;
ENTRY;
lctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
- if ((lctxt == NULL) || (lctxt->loc_handle == NULL))
+ if (lctxt == NULL || lctxt->loc_handle == NULL)
RETURN(-ENOENT);
mutex_lock(&cdt->cdt_llog_lock);
memcpy(&larr->arr_hai, hai, hai->hai_len);
lctxt = llog_get_context(obd, LLOG_AGENT_ORIG_CTXT);
- if ((lctxt == NULL) || (lctxt->loc_handle == NULL))
+ if (lctxt == NULL || lctxt->loc_handle == NULL)
GOTO(free, rc = -ENOENT);
mutex_lock(&cdt->cdt_llog_lock);
* 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)))
+ (larr->arr_hai.hai_action == HSMA_CANCEL &&
+ ducb->status == ARS_CANCELED))
RETURN(0);
rc = 0;
aai->aai_magic);
aai->aai_ctxt = llog_get_context(aai->aai_obd, LLOG_AGENT_ORIG_CTXT);
- if ((aai->aai_ctxt == NULL) || (aai->aai_ctxt->loc_handle == NULL)) {
+ if (aai->aai_ctxt == NULL || aai->aai_ctxt->loc_handle == NULL) {
CERROR("llog_get_context() failed\n");
RETURN(ERR_PTR(-ENOENT));
}
const struct obd_uuid *uuid)
{
struct hsm_agent *ha;
- cfs_list_t *pos;
- cfs_list_for_each(pos, &cdt->cdt_agents) {
- ha = cfs_list_entry(pos, struct hsm_agent, ha_list);
+ list_for_each_entry(ha, &cdt->cdt_agents, ha_list) {
if (obd_uuid_equals(&ha->ha_uuid, uuid))
return ha;
}
GOTO(out_free, rc = -EEXIST);
}
- cfs_list_add_tail(&ha->ha_list, &cdt->cdt_agents);
+ list_add_tail(&ha->ha_list, &cdt->cdt_agents);
if (ha->ha_archive_cnt == 0)
CDEBUG(D_HSM, "agent %s registered for all archives\n",
out_free:
- if ((ha != NULL) && (ha->ha_archive_id != NULL))
+ if (ha != NULL && ha->ha_archive_id != NULL)
OBD_FREE(ha->ha_archive_id,
ha->ha_archive_cnt * sizeof(*ha->ha_archive_id));
if (ha != NULL)
ha = mdt_hsm_agent_lookup(cdt, uuid);
if (ha != NULL)
- cfs_list_del_init(&ha->ha_list);
+ list_del_init(&ha->ha_list);
up_write(&cdt->cdt_agent_lock);
int succ_rq, int fail_rq, int new_rq,
const struct obd_uuid *uuid)
{
- struct hsm_agent *ha, *tmp;
+ struct hsm_agent *ha;
int rc;
ENTRY;
down_read(&cdt->cdt_agent_lock);
- cfs_list_for_each_entry_safe(ha, tmp, &cdt->cdt_agents, ha_list) {
+ list_for_each_entry(ha, &cdt->cdt_agents, ha_list) {
if (obd_uuid_equals(&ha->ha_uuid, uuid)) {
- if ((succ_rq == 0) && (fail_rq == 0) && (new_rq == 0)) {
+ if (succ_rq == 0 && fail_rq == 0 && new_rq == 0) {
atomic_set(&ha->ha_success, 0);
atomic_set(&ha->ha_failure, 0);
atomic_set(&ha->ha_requests, 0);
struct obd_uuid *uuid)
{
int rc = -EAGAIN, i, load = -1;
- struct hsm_agent *ha, *tmp;
+ struct hsm_agent *ha;
ENTRY;
/* Choose an export to send a copytool req to */
down_read(&cdt->cdt_agent_lock);
- cfs_list_for_each_entry_safe(ha, tmp, &cdt->cdt_agents, ha_list) {
+ list_for_each_entry(ha, &cdt->cdt_agents, ha_list) {
for (i = 0; (i < ha->ha_archive_cnt) &&
(ha->ha_archive_id[i] != archive); i++) {
/* nothing to do, just skip unmatching records */
}
/* archive count == 0 means copy tool serves any backend */
- if ((ha->ha_archive_cnt != 0) && (i == ha->ha_archive_cnt))
+ if (ha->ha_archive_cnt != 0 && i == ha->ha_archive_cnt)
continue;
- if ((load == -1) ||
- (load > atomic_read(&ha->ha_requests))) {
+ if (load == -1 || load > atomic_read(&ha->ha_requests)) {
load = atomic_read(&ha->ha_requests);
*uuid = ha->ha_uuid;
rc = 0;
/* Check if request is still valid (cf file hsm flags) */
fail_request = false;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
if (hai->hai_action != HSMA_CANCEL) {
struct mdt_object *obj;
struct md_hsm hsm;
obj = mdt_hsm_get_md_hsm(mti, &hai->hai_fid, &hsm);
- if (!IS_ERR(obj)) {
+ if (!IS_ERR(obj) && obj != NULL) {
mdt_object_put(mti->mti_env, obj);
} else {
if (hai->hai_action == HSMA_REMOVE)
continue;
- if (PTR_ERR(obj) == -ENOENT) {
+ if (obj == NULL) {
fail_request = true;
rc = mdt_agent_record_update(
mti->mti_env, mdt,
if (rc) {
CERROR(
"%s: mdt_agent_record_update() "
- "failed, rc=%d, cannot update "
+ "failed, cannot update "
"status to %s for cookie "
LPX64": rc = %d\n",
- mdt_obd_name(mdt), rc,
+ mdt_obd_name(mdt),
agent_req_status2name(ARS_FAILED),
hai->hai_cookie, rc);
GOTO(out_buf, rc);
GOTO(out_buf, rc = PTR_ERR(obj));
}
-
if (!mdt_hsm_is_action_compat(hai, hal->hal_archive_id,
hal->hal_flags, &hsm)) {
/* incompatible request, we abort the request */
1, ARS_FAILED);
if (rc) {
CERROR("%s: mdt_agent_record_update() "
- "failed, rc=%d, cannot update "
+ "failed, cannot update "
"status to %s for cookie "
LPX64": rc = %d\n",
- mdt_obd_name(mdt), rc,
+ mdt_obd_name(mdt),
agent_req_status2name(ARS_FAILED),
hai->hai_cookie, rc);
GOTO(out_buf, rc);
* from a server (MDT) to a client (MDC), backwards of normal comms.
*/
exp = cfs_hash_lookup(mdt2obd_dev(mdt)->obd_uuid_hash, &uuid);
- if ((exp == NULL) || (exp->exp_disconnected)) {
+ if (exp == NULL || exp->exp_disconnected) {
/* This should clean up agents on evicted exports */
rc = -ENOENT;
CERROR("%s: agent uuid (%s) not found, unregistering:"
out:
if (rc != 0 && is_registered) {
/* in case of error, we have to unregister requests */
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
if (hai->hai_action == HSMA_CANCEL)
continue;
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
- cfs_list_t *pos;
+ struct list_head *pos;
loff_t i;
ENTRY;
down_read(&cdt->cdt_agent_lock);
- if (cfs_list_empty(&cdt->cdt_agents))
+ if (list_empty(&cdt->cdt_agents))
RETURN(NULL);
if (*off == 0)
RETURN(SEQ_START_TOKEN);
i = 0;
- cfs_list_for_each(pos, &cdt->cdt_agents) {
+ list_for_each(pos, &cdt->cdt_agents) {
i++;
if (i >= *off)
RETURN(pos);
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
- cfs_list_t *pos = v;
+ struct list_head *pos = v;
ENTRY;
if (pos == SEQ_START_TOKEN)
*/
static int mdt_hsm_agent_proc_show(struct seq_file *s, void *v)
{
- cfs_list_t *pos = v;
+ struct list_head *pos = v;
struct hsm_agent *ha;
int i;
ENTRY;
if (pos == SEQ_START_TOKEN)
RETURN(0);
- ha = cfs_list_entry(pos, struct hsm_agent, ha_list);
+ ha = list_entry(pos, struct hsm_agent, ha_list);
seq_printf(s, "uuid=%s archive#=%d (", ha->ha_uuid.uuid,
ha->ha_archive_cnt);
if (ha->ha_archive_cnt == 0)
hcdcb = data;
/* a compatible request must be WAITING or STARTED
* and not a cancel */
- if (((larr->arr_status != ARS_WAITING) &&
- (larr->arr_status != ARS_STARTED)) ||
- (larr->arr_hai.hai_action == HSMA_CANCEL))
+ if ((larr->arr_status != ARS_WAITING &&
+ larr->arr_status != ARS_STARTED) ||
+ larr->arr_hai.hai_action == HSMA_CANCEL)
RETURN(0);
- hai = hai_zero(hcdcb->hal);
+ hai = hai_first(hcdcb->hal);
for (i = 0; i < hcdcb->hal->hal_count; i++, hai = hai_next(hai)) {
/* if request is a CANCEL:
* if cookie set in the request, there is no need to find a
* if the caller sets the cookie, we assume he also sets the
* arr_archive_id
*/
- if ((hai->hai_action == HSMA_CANCEL) && (hai->hai_cookie != 0))
+ if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie != 0)
continue;
if (!lu_fid_eq(&hai->hai_fid, &larr->arr_hai.hai_fid))
*/
hai->hai_cookie = larr->arr_hai.hai_cookie;
/* we read the archive number from the request we cancel */
- if ((hai->hai_action == HSMA_CANCEL) &&
- (hcdcb->hal->hal_archive_id == 0))
+ if (hai->hai_action == HSMA_CANCEL &&
+ hcdcb->hal->hal_archive_id == 0)
hcdcb->hal->hal_archive_id = larr->arr_archive_id;
}
RETURN(0);
ENTRY;
ok_cnt = 0;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
/* 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
*/
- if ((hai->hai_action == HSMA_CANCEL) && (hai->hai_cookie != 0))
+ if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie != 0)
ok_cnt++;
else
hai->hai_cookie = 0;
hsm_flags = hsm->mh_flags;
switch (hai->hai_action) {
case HSMA_ARCHIVE:
- if ((hsm_flags & HS_DIRTY) || !(hsm_flags & HS_ARCHIVED))
+ if (hsm_flags & HS_DIRTY || !(hsm_flags & HS_ARCHIVED))
is_needed = true;
break;
case HSMA_RESTORE:
if (hal->hal_count == 0)
RETURN(false);
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
if (!fid_is_sane(&hai->hai_fid))
RETURN(false);
if (!hal_is_sane(hal))
RETURN(-EINVAL);
- *compound_id = cfs_atomic_inc_return(&cdt->cdt_compound_id);
+ *compound_id = atomic_inc_return(&cdt->cdt_compound_id);
/* search for compatible request, if found hai_cookie is set
* to the request cookie
if (rc)
GOTO(out, rc);
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
int archive_id;
__u64 flags;
* do not record
*/
/* redundant case */
- if ((hai->hai_action != HSMA_CANCEL) && (hai->hai_cookie != 0))
+ if (hai->hai_action != HSMA_CANCEL && hai->hai_cookie != 0)
continue;
/* cancel nothing case */
- if ((hai->hai_action == HSMA_CANCEL) && (hai->hai_cookie == 0))
+ if (hai->hai_action == HSMA_CANCEL && hai->hai_cookie == 0)
continue;
/* new request or cancel request
/* get HSM attributes */
obj = mdt_hsm_get_md_hsm(mti, &hai->hai_fid, &mh);
- if (IS_ERR(obj)) {
+ if (IS_ERR(obj) || obj == NULL) {
/* in case of archive remove, Lustre file
* is not mandatory */
if (hai->hai_action == HSMA_REMOVE)
goto record;
+ if (obj == NULL)
+ GOTO(out, rc = -ENOENT);
GOTO(out, rc = PTR_ERR(obj));
}
mdt_object_put(mti->mti_env, obj);
* warranty an agent can serve any combinaison of archive
* backend
*/
- if ((hai->hai_action != HSMA_CANCEL) &&
- (archive_id == 0))
+ if (hai->hai_action != HSMA_CANCEL && archive_id == 0)
archive_id = mh.mh_arch_id;
/* if restore, take an exclusive lock on layout */
mdt_object_put(mti->mti_env, child);
mutex_lock(&cdt->cdt_restore_lock);
- cfs_list_add_tail(&crh->crh_list,
- &cdt->cdt_restore_hdl);
+ list_add_tail(&crh->crh_list, &cdt->cdt_restore_hdl);
mutex_unlock(&cdt->cdt_restore_lock);
}
record:
GOTO(out, rc);
out:
/* if work has been added, wake up coordinator */
- if ((rc == 0) || (rc == -ENODATA))
+ if (rc == 0 || rc == -ENODATA)
mdt_hsm_cdt_wakeup(mdt);
return rc;
int i;
ENTRY;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
struct cdt_agent_req *car;
{
struct mdt_device *mdt = mti->mti_mdt;
struct coordinator *cdt = &mdt->mdt_coordinator;
- cfs_list_t *pos, *tmp;
struct cdt_restore_handle *crh;
bool rc = false;
ENTRY;
RETURN(rc);
mutex_lock(&cdt->cdt_restore_lock);
- cfs_list_for_each_safe(pos, tmp, &cdt->cdt_restore_hdl) {
- crh = cfs_list_entry(pos, struct cdt_restore_handle, crh_list);
+ list_for_each_entry(crh, &cdt->cdt_restore_hdl, crh_list) {
if (lu_fid_eq(&crh->crh_fid, fid)) {
rc = true;
break;
int i, rc;
ENTRY;
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
hai->hai_action = HSMA_NONE;
if (!fid_is_sane(&hai->hai_fid))
* we may want do give back dynamic informations on the
* running request
*/
- hai = hai_zero(hal);
+ hai = hai_first(hal);
for (i = 0; i < hal->hal_count; i++, hai = hai_next(hai)) {
struct cdt_agent_req *car;
*/
void dump_requests(char *prefix, struct coordinator *cdt)
{
- cfs_list_t *pos;
struct cdt_agent_req *car;
down_read(&cdt->cdt_request_lock);
- cfs_list_for_each(pos, &cdt->cdt_requests) {
- car = cfs_list_entry(pos, struct cdt_agent_req,
- car_request_list);
+ list_for_each_entry(car, &cdt->cdt_requests, car_request_list) {
CDEBUG(D_HSM, "%s fid="DFID" dfid="DFID
" compound/cookie="LPX64"/"LPX64
" action=%s archive#=%d flags="LPX64
car->car_hai->hai_extent.offset,
car->car_hai->hai_extent.length,
car->car_hai->hai_gid,
- cfs_atomic_read(&car->car_refcount),
+ atomic_read(&car->car_refcount),
car->car_canceled);
}
up_read(&cdt->cdt_request_lock);
if (car == NULL)
RETURN(ERR_PTR(-ENOMEM));
- cfs_atomic_set(&car->car_refcount, 1);
+ atomic_set(&car->car_refcount, 1);
car->car_compound_id = compound_id;
car->car_archive_id = archive_id;
car->car_flags = flags;
*/
void mdt_cdt_get_request(struct cdt_agent_req *car)
{
- cfs_atomic_inc(&car->car_refcount);
+ atomic_inc(&car->car_refcount);
}
/**
*/
void mdt_cdt_put_request(struct cdt_agent_req *car)
{
- LASSERT(cfs_atomic_read(&car->car_refcount) > 0);
- if (cfs_atomic_dec_and_test(&car->car_refcount))
+ LASSERT(atomic_read(&car->car_refcount) > 0);
+ if (atomic_dec_and_test(&car->car_refcount))
mdt_cdt_free_request(car);
}
* \param cdt [IN] coordinator
* \param cookie [IN] request cookie
* \param fid [IN] fid
- * \retval request pointer
+ * \retval request pointer or NULL if not found
*/
static struct cdt_agent_req *cdt_find_request_nolock(struct coordinator *cdt,
__u64 cookie,
struct cdt_agent_req *found = NULL;
ENTRY;
- cfs_list_for_each_entry(car, &cdt->cdt_requests, car_request_list) {
- if ((car->car_hai->hai_cookie == cookie) ||
- ((fid != NULL) && lu_fid_eq(fid, &car->car_hai->hai_fid))) {
+ list_for_each_entry(car, &cdt->cdt_requests, car_request_list) {
+ if (car->car_hai->hai_cookie == cookie ||
+ (fid != NULL && lu_fid_eq(fid, &car->car_hai->hai_fid))) {
mdt_cdt_get_request(car);
found = car;
break;
RETURN(-EEXIST);
}
- cfs_list_add_tail(&new_car->car_request_list, &cdt->cdt_requests);
+ list_add_tail(&new_car->car_request_list, &cdt->cdt_requests);
up_write(&cdt->cdt_request_lock);
mdt_hsm_agent_update_statistics(cdt, 0, 0, 1, &new_car->car_uuid);
* \param cdt [IN] coordinator
* \param cookie [IN] request cookie
* \param fid [IN] fid
- * \retval request pointer
+ * \retval request pointer or NULL if not found
*/
struct cdt_agent_req *mdt_cdt_find_request(struct coordinator *cdt,
const __u64 cookie,
down_write(&cdt->cdt_request_lock);
car = cdt_find_request_nolock(cdt, cookie, NULL);
if (car != NULL) {
- cfs_list_del(&car->car_request_list);
+ list_del(&car->car_request_list);
up_write(&cdt->cdt_request_lock);
/* reference from cdt_requests list */
/* reference from cdt_find_request_nolock() */
mdt_cdt_put_request(car);
- LASSERT(atomic_read(&cdt->cdt_request_count) > 0);
+ LASSERT(atomic_read(&cdt->cdt_request_count) >= 1);
atomic_dec(&cdt->cdt_request_count);
RETURN(0);
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
- cfs_list_t *pos;
+ struct list_head *pos;
loff_t i;
ENTRY;
down_read(&cdt->cdt_request_lock);
- if (cfs_list_empty(&cdt->cdt_requests))
+ if (list_empty(&cdt->cdt_requests))
RETURN(NULL);
if (*p == 0)
RETURN(SEQ_START_TOKEN);
i = 0;
- cfs_list_for_each(pos, &cdt->cdt_requests) {
+ list_for_each(pos, &cdt->cdt_requests) {
i++;
if (i >= *p)
RETURN(pos);
{
struct mdt_device *mdt = s->private;
struct coordinator *cdt = &mdt->mdt_coordinator;
- cfs_list_t *pos = v;
+ struct list_head *pos = v;
ENTRY;
if (pos == SEQ_START_TOKEN)
*/
static int mdt_hsm_request_proc_show(struct seq_file *s, void *v)
{
- cfs_list_t *pos = v;
+ struct list_head *pos = v;
struct cdt_agent_req *car;
char buf[12];
__u64 data_moved;
if (pos == SEQ_START_TOKEN)
RETURN(0);
- car = cfs_list_entry(pos, struct cdt_agent_req, car_request_list);
+ car = list_entry(pos, struct cdt_agent_req, car_request_list);
mdt_cdt_get_work_done(car, &data_moved);
seq_printf(s, "fid="DFID" dfid="DFID
* requests */
atomic_t cdt_request_count; /**< current count of
* started requests */
- cfs_list_t cdt_requests; /**< list of started
+ struct list_head cdt_requests; /**< list of started
* requests */
- cfs_list_t cdt_agents; /**< list of register
+ struct list_head cdt_agents; /**< list of register
* agents */
- cfs_list_t cdt_restore_hdl; /**< list of restore lock
+ struct list_head cdt_restore_hdl; /**< list of restore lock
* handles */
};
struct cdt_agent_req {
cfs_list_t car_request_list; /**< to chain all the req. */
- cfs_atomic_t car_refcount; /**< reference counter */
+ atomic_t car_refcount; /**< reference counter */
__u64 car_compound_id; /**< compound id */
__u64 car_flags; /**< request original flags */
struct obd_uuid car_uuid; /**< agent doing the req. */
__u32 *ha_archive_id; /**< archive id */
int ha_archive_cnt; /**< number of archive entries
* 0 means any archive */
- cfs_atomic_t ha_requests; /**< current request count */
- cfs_atomic_t ha_success; /**< number of successful
+ atomic_t ha_requests; /**< current request count */
+ atomic_t ha_success; /**< number of successful
* actions */
- cfs_atomic_t ha_failure; /**< number of failed actions */
+ atomic_t ha_failure; /**< number of failed actions */
};
struct cdt_restore_handle {
continue;
}
- hai = hai_zero(hal);
+ hai = hai_first(hal);
while (++i <= hal->hal_count) {
if ((char *)hai - (char *)hal > msgsize) {
CT_ERROR("'%s' item %d past end of message!\n",