if (obj) {
/* directory is already splitted, so we have to forward
* request to the right MDS */
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)name, len);
CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n",
mds, PFID3(&rpid));
- rpid = obj->objs[mds].lo_fid;
+ rpid = obj->lo_objs[mds].li_fid;
lmv_put_obj(obj);
}
/* in fact, we need not this with current intent_lock(),
* but it may change some day */
if (!lu_fid_eq(pid, cid)){
- rpid = obj->objs[mds].lo_fid;
+ rpid = obj->lo_objs[mds].li_fid;
mds = lmv_fld_lookup(obd, &rpid);
}
lmv_put_obj(obj);
obj = lmv_grab_obj(obd, pid);
if (obj && len) {
/* directory is already splitted. calculate mds */
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)name, len);
- rpid = obj->objs[mds].lo_fid;
+ rpid = obj->lo_objs[mds].li_fid;
mds = lmv_fld_lookup(obd, &rpid);
lmv_put_obj(obj);
void lmv_update_body_from_obj(struct mdt_body *body, struct lmv_inode *obj)
{
/* update size */
- body->size += obj->size;
+ body->size += obj->lo_size;
}
int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp)
lmv_lock_obj(obj);
- for (i = 0; i < obj->objcount; i++) {
- struct lu_fid fid = obj->objs[i].lo_fid;
+ for (i = 0; i < obj->lo_objcount; i++) {
+ struct lu_fid fid = obj->lo_objs[i].li_fid;
struct ptlrpc_request *req = NULL;
struct lookup_intent it;
int mds;
/* skip master obj */
continue;
- CDEBUG(D_OTHER, "lookup slave "DFID3"\n", PFID3(&id));
+ CDEBUG(D_OTHER, "lookup slave "DFID3"\n", PFID3(&fid));
/* is obj valid? */
memset(&it, 0, sizeof(it));
GOTO(cleanup, rc = -ENOMEM);
mds = lmv_fld_lookup(obd, &fid);
- rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &id,
- NULL, 0, NULL, 0, &id, &it, 0, &req,
+ rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &fid,
+ NULL, 0, NULL, 0, &fid, &it, 0, &req,
lmv_dirobj_blocking_ast);
lockh = (struct lustre_handle *)&LUSTRE_IT(&it)->it_lock_handle;
body2 = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*body2));
LASSERT(body2);
- obj->objs[i].size = body2->size;
+ obj->lo_objs[i].li_size = body2->size;
CDEBUG(D_OTHER, "fresh: %lu\n",
- (unsigned long)obj->objs[i].size);
+ (unsigned long)obj->lo_objs[i].li_size);
LDLM_LOCK_PUT(lock);
if (req)
ptlrpc_req_finished(req);
release_lock:
- lmv_update_body_from_obj(body, obj->objs + i);
+ lmv_update_body_from_obj(body, obj->lo_objs + i);
if (LUSTRE_IT(&it)->it_lock_mode)
ldlm_lock_decref(lockh, LUSTRE_IT(&it)->it_lock_mode);
ENTRY;
/*
- * IT_LOOKUP is intended to produce name -> id resolving (let's call
+ * IT_LOOKUP is intended to produce name -> fid resolving (let's call
* this lookup below) or to confirm requested resolving is still valid
* (let's call this revalidation) cid != NULL specifies revalidation.
*/
if (cid) {
/*
* this is revalidation: we have to check is LOOKUP lock still
- * valid for given id. Very important part is that we have to
+ * valid for given fid. Very important part is that we have to
* choose right mds because namespace is per mds.
*/
rpid = *pid;
obj = lmv_grab_obj(obd, pid);
if (obj) {
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)name, len);
- rpid = obj->objs[mds].lo_fid;
+ rpid = obj->lo_objs[mds].li_fid;
lmv_put_obj(obj);
}
mds = lmv_fld_lookup(obd, &rpid);
if (obj) {
if (len) {
/* directory is already splitted. calculate mds */
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)name, len);
- rpid = obj->objs[mds].lo_fid;
+ rpid = obj->lo_objs[mds].li_fid;
mds = lmv_fld_lookup(obd, &rpid);
}
lmv_put_obj(obj);
lmv_lock_obj(obj);
- for (i = 0; i < obj->objcount; i++) {
- struct lu_fid fid = obj->objs[i].lo_fid;
+ for (i = 0; i < obj->lo_objcount; i++) {
+ struct lu_fid fid = obj->lo_objs[i].li_fid;
struct lustre_handle *lockh = NULL;
struct ptlrpc_request *req = NULL;
ldlm_blocking_callback cb;
int master = 0;
CDEBUG(D_OTHER, "revalidate subobj "DFID3"\n",
- PFID3(&id));
+ PFID3(&fid));
memset(&it, 0, sizeof(it));
it.it_op = IT_GETATTR;
/* is obj valid? */
mds = lmv_fld_lookup(obd, &fid);
rc = md_intent_lock(lmv->tgts[mds].ltd_exp,
- &id, NULL, 0, NULL, 0, &id, &it, 0,
+ &fid, NULL, 0, NULL, 0, &fid, &it, 0,
&req, cb);
lockh = (struct lustre_handle *) &LUSTRE_IT(&it)->it_lock_handle;
if (rc > 0 && req == NULL) {
LASSERT(body);
update:
- obj->objs[i].size = body->size;
+ obj->lo_objs[i].li_size = body->size;
CDEBUG(D_OTHER, "fresh: %lu\n",
- (unsigned long)obj->objs[i].size);
+ (unsigned long)obj->lo_objs[i].li_size);
if (req)
ptlrpc_req_finished(req);
release_lock:
- size += obj->objs[i].size;
+ size += obj->lo_objs[i].li_size;
if (LUSTRE_IT(&it)->it_lock_mode)
ldlm_lock_decref(lockh, LUSTRE_IT(&it)->it_lock_mode);
lmv_lock_obj(struct lmv_obj *obj)
{
LASSERT(obj);
- down(&obj->guard);
+ down(&obj->lo_guard);
}
static inline void
lmv_unlock_obj(struct lmv_obj *obj)
{
LASSERT(obj);
- up(&obj->guard);
+ up(&obj->lo_guard);
}
void lmv_add_obj(struct lmv_obj *obj);
lmv_lock_obj(obj);
- for (i = 0; i < obj->objcount; i++) {
+ for (i = 0; i < obj->lo_objcount; i++) {
if (lmv->tgts[i].ltd_exp == NULL) {
CWARN("%s: NULL export for %d\n",
}
/* skip master obj. */
- if (lu_fid_eq(&obj->lo_fid, &obj->objs[i].lo_fid))
+ if (lu_fid_eq(&obj->lo_fid, &obj->lo_objs[i].li_fid))
continue;
- body->size += obj->objs[i].size;
+ body->size += obj->lo_objs[i].li_size;
}
lmv_unlock_obj(obj);
obj = lmv_grab_obj(obd, pid);
if (obj) {
/* directory is splitted. look for right mds for this name. */
- mds = raw_name2idx(obj->hashtype, obj->objcount, name, len);
- rcid = obj->objs[mds].lo_fid;
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, name, len);
+ rcid = obj->lo_objs[mds].li_fid;
mds = lmv_fld_lookup(obd, &rcid);
lmv_put_obj(obj);
}
valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA;
- /* time to update mea of parent id */
+ /* time to update mea of parent fid */
i = lmv_fld_lookup(obd, fid);
- rc = md_getattr(lmv->tgts[i].ltd_exp,
- id, valid, NULL, NULL, 0, mealen, NULL, &req);
+ rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid, NULL,
+ NULL, 0, mealen, NULL, &req);
if (rc) {
CERROR("md_getattr() failed, error %d\n", rc);
GOTO(cleanup, rc);
LASSERT(++loop <= 2);
obj = lmv_grab_obj(obd, &op_data->fid1);
if (obj) {
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
op_data->name, op_data->namelen);
- op_data->fid1 = obj->objs[mds].lo_fid;
+ op_data->fid1 = obj->lo_objs[mds].li_fid;
lmv_put_obj(obj);
}
if (obj) {
/* directory is splitted. look for right mds for this
* name */
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)data->name, data->namelen);
- data->fid1 = obj->objs[mds].lo_fid;
+ data->fid1 = obj->lo_objs[mds].li_fid;
lmv_put_obj(obj);
}
}
obj = lmv_grab_obj(obd, fid);
if (obj) {
/* directory is splitted. look for right mds for this name */
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
filename, namelen - 1);
- rid = obj->objs[mds].lo_fid;
+ rid = obj->lo_objs[mds].li_fid;
lmv_put_obj(obj);
}
valid == OBD_MD_FLID ? valid : valid | OBD_MD_FID,
ea_size, request);
if (rc == 0) {
- /*
- * this could be cross-node reference. in this case all we have
- * right now is lustre_id triple. we'd like to find other
- * attributes.
- */
body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body));
LASSERT(body != NULL);
LASSERT((body->valid & OBD_MD_FID) != 0
}
/*
- * llite passes id of an target inode in data->fid1 and id of directory in
+ * llite passes fid of an target inode in data->fid1 and id of directory in
* data->fid2
*/
static int lmv_link(struct obd_export *exp, struct mdc_op_data *data,
/* usual link request */
obj = lmv_grab_obj(obd, &data->fid2);
if (obj) {
- rc = raw_name2idx(obj->hashtype, obj->objcount,
+ rc = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
data->name, data->namelen);
- data->fid2 = obj->objs[rc].lo_fid;
+ data->fid2 = obj->lo_objs[rc].li_fid;
lmv_put_obj(obj);
}
PFID3(&data->fid2), data->namelen, data->name,
PFID3(&data->fid1));
} else {
- mds = id_group(&data->fid1);
+ mds = lmv_fld_lookup(obd, &data->fid1);
- /* request from MDS to acquire i_links for inode by id1 */
+ /* request from MDS to acquire i_links for inode by fid1 */
CDEBUG(D_OTHER, "inc i_nlinks for "DFID3"\n",
PFID3(&data->fid1));
}
*/
obj = lmv_grab_obj(obd, &data->fid2);
if (obj) {
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)new, newlen);
- data->fid2 = obj->objs[mds].lo_fid;
+ data->fid2 = obj->lo_objs[mds].li_fid;
CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds,
PFID3(&data->fid2));
lmv_put_obj(obj);
* directory is already splitted, so we have to forward request
* to the right MDS.
*/
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)old, oldlen);
- data->fid1 = obj->objs[mds].lo_fid;
+ data->fid1 = obj->lo_objs[mds].li_fid;
CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds,
PFID3(&data->fid1));
lmv_put_obj(obj);
* directory is already splitted, so we have to forward request
* to the right MDS.
*/
- mds = raw_name2idx(obj->hashtype, obj->objcount,
+ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
(char *)new, newlen);
- data->fid2 = obj->objs[mds].lo_fid;
+ data->fid2 = obj->lo_objs[mds].li_fid;
CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds,
PFID3(&data->fid2));
lmv_put_obj(obj);
PFID3(&data->fid1), iattr->ia_valid, obj ? ", splitted" : "");
if (obj) {
- for (i = 0; i < obj->objcount; i++) {
- data->fid1 = obj->objs[i].lo_fid;
+ for (i = 0; i < obj->lo_objcount; i++) {
+ data->fid1 = obj->lo_objs[i].li_fid;
mds = lmv_fld_lookup(obd, &data->fid1);
rc = md_setattr(lmv->tgts[mds].ltd_exp,
data, iattr, ea, ealen, ea2, ea2len,
ea3, ea3len, &req);
- if (lu_fid_eq(&obj->lo_fid, &obj->objs[i].lo_fid)) {
+ if (lu_fid_eq(&obj->lo_fid, &obj->lo_objs[i].li_fid)) {
/*
* this is master object and this request should
* be returned back to llite.
lmv_lock_obj(obj);
/* find dirobj containing page with requested offset. */
- for (i = 0; i < obj->objcount; i++) {
- if (offset < obj->objs[i].size)
+ for (i = 0; i < obj->lo_objcount; i++) {
+ if (offset < obj->lo_objs[i].li_size)
break;
- offset -= obj->objs[i].size;
+ offset -= obj->lo_objs[i].li_size;
}
- rid = obj->objs[i].lo_fid;
+ rid = obj->lo_objs[i].li_fid;
lmv_unlock_obj(obj);
lmv_put_obj(obj);
LASSERT(exp && fid);
if (lmv_delete_obj(exp, fid)) {
CDEBUG(D_OTHER, "lmv object "DFID3" is destroyed.\n",
- PFID3(id));
+ PFID3(fid));
}
RETURN(0);
}
obj = lmv_grab_obj(obd, &data->fid1);
if (obj) {
- i = raw_name2idx(obj->hashtype, obj->objcount,
+ i = raw_name2idx(obj->lo_hashtype, obj->lo_objcount,
data->name, data->namelen);
- data->fid1 = obj->objs[i].lo_fid;
+ data->fid1 = obj->lo_objs[i].li_fid;
lmv_put_obj(obj);
}
CDEBUG(D_OTHER, "unlink '%*s' in "DFID3" -> %u\n",
LASSERT(oa->o_id != 0);
LASSERT(oa->o_fid != 0);
- /* save "master" object id */
+ /* save "master" object fid */
obdo2id(&mid, oa);
mea = (struct mea *)*ea;
static LIST_HEAD(obj_list);
static spinlock_t obj_list_lock = SPIN_LOCK_UNLOCKED;
-/* creates new obj on passed @id and @mea. */
+/* creates new obj on passed @fid and @mea. */
struct lmv_obj *
lmv_alloc_obj(struct obd_device *obd,
struct lu_fid *fid,
atomic_inc(&obj_cache_count);
obj->lo_fid = *fid;
- obj->obd = obd;
- obj->state = 0;
- obj->hashtype = mea->mea_magic;
+ obj->lo_obd = obd;
+ obj->lo_state = 0;
+ obj->lo_hashtype = mea->mea_magic;
- init_MUTEX(&obj->guard);
- atomic_set(&obj->count, 0);
- obj->objcount = mea->mea_count;
+ init_MUTEX(&obj->lo_guard);
+ atomic_set(&obj->lo_count, 0);
+ obj->lo_objcount = mea->mea_count;
obj_size = sizeof(struct lmv_inode) *
lmv->desc.ld_tgt_count;
- OBD_ALLOC(obj->objs, obj_size);
- if (!obj->objs)
+ OBD_ALLOC(obj->lo_objs, obj_size);
+ if (!obj->lo_objs)
goto err_obj;
- memset(obj->objs, 0, obj_size);
+ memset(obj->lo_objs, 0, obj_size);
/* put all ids in */
for (i = 0; i < mea->mea_count; i++) {
CDEBUG(D_OTHER, "subobj "DFID3"\n",
PFID3(&mea->mea_ids[i]));
- obj->objs[i].id = mea->mea_ids[i];
- LASSERT(fid_num(&obj->objs[i].lo_fid));
+ obj->lo_objs[i].li_fid = mea->mea_ids[i];
+ LASSERT(fid_num(&obj->lo_objs[i].li_fid));
}
return obj;
void
lmv_free_obj(struct lmv_obj *obj)
{
+ struct lmv_obd *lmv = &obj->lo_obd->u.lmv;
unsigned int obj_size;
- struct lmv_obd *lmv = &obj->obd->u.lmv;
- LASSERT(!atomic_read(&obj->count));
+ LASSERT(!atomic_read(&obj->lo_count));
obj_size = sizeof(struct lmv_inode) *
lmv->desc.ld_tgt_count;
- OBD_FREE(obj->objs, obj_size);
+ OBD_FREE(obj->lo_objs, obj_size);
OBD_SLAB_FREE(obj, obj_cache, sizeof(*obj));
atomic_dec(&obj_cache_count);
}
static void
__add_obj(struct lmv_obj *obj)
{
- atomic_inc(&obj->count);
- list_add(&obj->list, &obj_list);
+ atomic_inc(&obj->lo_count);
+ list_add(&obj->lo_list, &obj_list);
}
void
static void
__del_obj(struct lmv_obj *obj)
{
- list_del(&obj->list);
+ list_del(&obj->lo_list);
lmv_free_obj(obj);
}
__get_obj(struct lmv_obj *obj)
{
LASSERT(obj != NULL);
- atomic_inc(&obj->count);
+ atomic_inc(&obj->lo_count);
return obj;
}
{
LASSERT(obj);
- if (atomic_dec_and_test(&obj->count)) {
+ if (atomic_dec_and_test(&obj->lo_count)) {
struct lu_fid *fid = &obj->lo_fid;
CDEBUG(D_OTHER, "last reference to "DFID3" - "
- "destroying\n", PFID3(id));
+ "destroying\n", PFID3(fid));
__del_obj(obj);
}
}
struct list_head *cur;
list_for_each(cur, &obj_list) {
- obj = list_entry(cur, struct lmv_obj, list);
+ obj = list_entry(cur, struct lmv_obj, lo_list);
/* check if object is in progress of destroying. If so - skip
* it. */
- if (obj->state & O_FREEING)
+ if (obj->lo_state & O_FREEING)
continue;
/*
* and mds runs on the same host. May be it is good idea to have
* objects list assosiated with obd.
*/
- if (obj->obd != obd)
+ if (obj->lo_obd != obd)
continue;
/* check if this is what we're looking for. */
RETURN(obj);
}
-/* looks in objects list for an object that matches passed @id. If it is not
+/* looks in objects list for an object that matches passed @fid. If it is not
* found -- creates it using passed @mea and puts onto list. */
static struct lmv_obj *
__create_obj(struct obd_device *obd, struct lu_fid *fid, struct mea *mea)
struct lmv_obj *new, *obj;
ENTRY;
- obj = lmv_grab_obj(obd, id);
+ obj = lmv_grab_obj(obd, fid);
if (obj)
RETURN(obj);
/* no such object yet, allocate and initialize it. */
- new = lmv_alloc_obj(obd, id, mea);
+ new = lmv_alloc_obj(obd, fid, mea);
if (!new)
RETURN(NULL);
/* check if someone create it already while we were dealing with
* allocating @obj. */
spin_lock(&obj_list_lock);
- obj = __grab_obj(obd, id);
+ obj = __grab_obj(obd, fid);
if (obj) {
/* someone created it already - put @obj and getting out. */
lmv_free_obj(new);
spin_unlock(&obj_list_lock);
CDEBUG(D_OTHER, "new obj in lmv cache: "DFID3"\n",
- PFID3(id));
+ PFID3(fid));
RETURN(new);
}
-/* creates object from passed @id and @mea. If @mea is NULL, it will be
+/* creates object from passed @fid and @mea. If @mea is NULL, it will be
* obtained from correct MDT and used for constructing the object. */
struct lmv_obj *
lmv_create_obj(struct obd_export *exp, struct lu_fid *fid, struct mea *mea)
ENTRY;
CDEBUG(D_OTHER, "get mea for "DFID3" and create lmv obj\n",
- PFID3(id));
+ PFID3(fid));
md.mea = NULL;
CDEBUG(D_OTHER, "mea isn't passed in, get it now\n");
mealen = MEA_SIZE_LMV(lmv);
- /* time to update mea of parent id */
+ /* time to update mea of parent fid */
md.mea = NULL;
valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA;
}
/* got mea, now create obj for it. */
- obj = __create_obj(obd, id, mea);
+ obj = __create_obj(obd, fid, mea);
if (!obj) {
CERROR("Can't create new object "DFID3"\n",
- PFID3(id));
+ PFID3(fid));
GOTO(cleanup, obj = ERR_PTR(-ENOMEM));
}
}
/*
- * looks for object with @id and orders to destroy it. It is possible the object
+ * looks for object with @fid and orders to destroy it. It is possible the object
* will not be destroyed right now, because it is still using by someone. In
* this case it will be marked as "freeing" and will not be accessible anymore
* for subsequent callers of lmv_grab_obj().
ENTRY;
spin_lock(&obj_list_lock);
- obj = __grab_obj(obd, id);
+ obj = __grab_obj(obd, fid);
if (obj) {
- obj->state |= O_FREEING;
+ obj->lo_state |= O_FREEING;
__put_obj(obj);
__put_obj(obj);
rc = 1;
spin_lock(&obj_list_lock);
list_for_each_safe(cur, tmp, &obj_list) {
- obj = list_entry(cur, struct lmv_obj, list);
+ obj = list_entry(cur, struct lmv_obj, lo_list);
- if (obj->obd != obd)
+ if (obj->lo_obd != obd)
continue;
- obj->state |= O_FREEING;
- if (atomic_read(&obj->count) > 1) {
+ obj->lo_state |= O_FREEING;
+ if (atomic_read(&obj->lo_count) > 1) {
CERROR("obj "DFID3" has count > 1 (%d)\n",
- PFID3(&obj->lo_fid), atomic_read(&obj->count));
+ PFID3(&obj->lo_fid), atomic_read(&obj->lo_count));
}
__put_obj(obj);
}