* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct cl_attr *attr);
};
+static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov);
+
/*****************************************************************************
*
* Lov object layout operations.
parent = subhdr->coh_parent;
oinfo = lov->lo_lsm->lsm_oinfo[idx];
- CDEBUG(D_INODE, DFID"@%p[%d] -> "DFID"@%p: id: "LPU64" seq: "LPU64
- " idx: %d gen: %d\n",
- PFID(&subhdr->coh_lu.loh_fid), subhdr, idx,
- PFID(&hdr->coh_lu.loh_fid), hdr,
- oinfo->loi_id, oinfo->loi_seq,
- oinfo->loi_ost_idx, oinfo->loi_ost_gen);
+ CDEBUG(D_INODE, DFID"@%p[%d] -> "DFID"@%p: ostid: "DOSTID
+ " idx: %d gen: %d\n",
+ PFID(&subhdr->coh_lu.loh_fid), subhdr, idx,
+ PFID(&hdr->coh_lu.loh_fid), hdr, POSTID(&oinfo->loi_oi),
+ oinfo->loi_ost_idx, oinfo->loi_ost_gen);
if (parent == NULL) {
subhdr->coh_parent = hdr;
struct lov_oinfo *oinfo = lsm->lsm_oinfo[i];
int ost_idx = oinfo->loi_ost_idx;
- fid_ostid_unpack(ofid, &oinfo->loi_oi,
- oinfo->loi_ost_idx);
+ result = ostid_to_fid(ofid, &oinfo->loi_oi,
+ oinfo->loi_ost_idx);
+ if (result != 0)
+ GOTO(out, result);
+
subdev = lovsub2cl_dev(dev->ld_target[ost_idx]);
subconf->u.coc_oinfo = oinfo;
LASSERTF(subdev != NULL, "not init ost %d\n", ost_idx);
}
} else
result = -ENOMEM;
+out:
RETURN(result);
}
union lov_layout_state *state)
{
LASSERT(lov->lo_type == LLT_EMPTY);
- if (cfs_atomic_read(&lov->lo_active_ios) > 0)
- RETURN(-EBUSY);
+
+ lov_layout_wait(env, lov);
cl_object_prune(env, &lov->lo_cl);
return 0;
ENTRY;
dump_lsm(D_INODE, lsm);
- if (cfs_atomic_read(&lov->lo_active_ios) > 0)
- RETURN(-EBUSY);
+ lov_layout_wait(env, lov);
if (r0->lo_sub != NULL) {
for (i = 0; i < r0->lo_nr; ++i) {
struct lovsub_object *los = r0->lo_sub[i];
struct l_wait_info lwi = { 0 };
ENTRY;
- if (!lov->lo_layout_invalid)
- RETURN(0);
-
while (cfs_atomic_read(&lov->lo_active_ios) > 0) {
- lov_conf_unlock(lov);
-
CDEBUG(D_INODE, "file:"DFID" wait for active IO, now: %d.\n",
PFID(lu_object_fid(lov2lu(lov))),
cfs_atomic_read(&lov->lo_active_ios));
l_wait_event(lov->lo_waitq,
cfs_atomic_read(&lov->lo_active_ios) == 0, &lwi);
- lov_conf_lock(lov);
}
RETURN(0);
}
}
if (conf->coc_opc == OBJECT_CONF_WAIT) {
- result = lov_layout_wait(env, lov);
+ if (lov->lo_layout_invalid &&
+ cfs_atomic_read(&lov->lo_active_ios) > 0) {
+ lov_conf_unlock(lov);
+ result = lov_layout_wait(env, lov);
+ lov_conf_lock(lov);
+ }
GOTO(out, result);
}
}
/* will change layout - check if there still exists active IO. */
- if (cfs_atomic_read(&lov->lo_active_ios) > 1) {
+ if (cfs_atomic_read(&lov->lo_active_ios) > 0) {
lov->lo_layout_invalid = true;
GOTO(out, result = -EBUSY);
}