From fc4de168e941017bce61765080c15982cb33dd88 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 24 May 2004 18:39:04 +0000 Subject: [PATCH] - lmv_getattr_name() recognizes cross-node name and repeats getattr to proper MDS node with gotten ino/generation couple - warning for cross-node rename in lmv_rename(). it isn't implemented yet. hence, we'd like to know when we hit this path - mdc_getattr_name() accepts empty name in order to support getattr by fid request - mds_get_parent_child_locked() forces MDS_INODELOCK_LOOKUP to be used if found dentry points to another MDS node - mea_name2idx() and raw_name2idx() checks for last not to be zero and warns if it's NOTE: this should fix the cause of the test #5 failure --- lustre/lmv/lmv_obd.c | 38 ++++++++++++++++++++++++++++++++++---- lustre/mdc/mdc_request.c | 9 +++++++-- lustre/mds/mds_reint.c | 3 ++- lustre/obdclass/mea.c | 4 ++++ 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 7ab2c43..99e229e 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -586,21 +586,43 @@ int lmv_getattr_name(struct obd_export *exp, struct ll_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct ll_fid rfid = *fid; int rc, mds = fid->mds; + struct mds_body *body; struct lmv_obj *obj; ENTRY; lmv_connect(obd); - CDEBUG(D_OTHER, "getattr_name for %*s on %lu/%lu/%lu\n", - namelen, filename, (unsigned long) fid->mds, - (unsigned long) fid->id, (unsigned long) fid->generation); obj = lmv_grab_obj(obd, fid, 0); if (obj) { /* directory is splitted. look for right mds for this name */ - mds = raw_name2idx(obj->objcount, filename, namelen); + mds = raw_name2idx(obj->objcount, filename, namelen - 1); rfid = obj->objs[mds].fid; lmv_put_obj(obj); } + CDEBUG(D_OTHER, "getattr_name for %*s on %lu/%lu/%lu -> %lu/%lu/%lu\n", + namelen, filename, (unsigned long) fid->mds, + (unsigned long) fid->id, (unsigned long) fid->generation, + (unsigned long) rfid.mds, (unsigned long) rfid.id, + (unsigned long) rfid.generation); rc = md_getattr_name(lmv->tgts[mds].exp, &rfid, filename, namelen, valid, ea_size, request); + if (rc == 0) { + /* this could be cross-node reference. in this case all + * we have right now is mds/ino/generation triple. we'd + * like to find other attributes */ + body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body)); + LASSERT(body != NULL); + if (body->valid & OBD_MD_MDS) { + struct ptlrpc_request *req = NULL; + rfid = body->fid1; + CDEBUG(D_OTHER, "request attrs for %lu/%lu/%lu\n", + (unsigned long) rfid.mds, + (unsigned long) rfid.id, + (unsigned long) rfid.generation); + rc = md_getattr_name(lmv->tgts[rfid.mds].exp, &rfid, + NULL, 1, valid, ea_size, &req); + ptlrpc_req_finished(*request); + *request = req; + } + } RETURN(rc); } @@ -661,6 +683,14 @@ int lmv_rename(struct obd_export *exp, struct mdc_op_data *data, newlen, new, (unsigned long) data->fid2.mds, (unsigned long) data->fid2.id, (unsigned long) data->fid2.generation); + if (!fid_equal(&data->fid1, &data->fid2)) + CWARN("cross-node rename %lu/%lu/%lu:%*s to %lu/%lu/%lu:%*s\n", + (unsigned long) data->fid1.mds, + (unsigned long) data->fid1.id, + (unsigned long) data->fid1.generation, oldlen, old, + (unsigned long) data->fid2.mds, + (unsigned long) data->fid2.id, + (unsigned long) data->fid2.generation, newlen, new); lmv_connect(obd); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index d6b156d..f6fdd32 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -196,8 +196,13 @@ int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid, body->eadatasize = ea_size; mdc_pack_req_body(req); - LASSERT (strnlen (filename, namelen) == namelen - 1); - memcpy(lustre_msg_buf(req->rq_reqmsg, 1, namelen), filename, namelen); + if (filename != NULL) { + LASSERT (strnlen (filename, namelen) == namelen - 1); + memcpy(lustre_msg_buf(req->rq_reqmsg, 1, namelen), + filename, namelen); + } else { + LASSERT(namelen == 1); + } rc = mdc_getattr_common(exp, ea_size, req); if (rc != 0) { diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 976e87e..8dc5409 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -1222,6 +1222,7 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds, /* inode lives on another MDS: return * mds/ino/gen * and LOOKUP lock. drop possible UPDATE lock! */ child_policy.l_inodebits.bits &= ~MDS_INODELOCK_UPDATE; + child_policy.l_inodebits.bits |= MDS_INODELOCK_LOOKUP; child_res_id.name[0] = (*dchildp)->d_inum; child_res_id.name[1] = (*dchildp)->d_generation; goto retry_locks; @@ -1452,7 +1453,7 @@ static int mds_reint_unlink_remote(struct mds_update_record *rec, int offset, LASSERT(offset == 0 || offset == 2); - DEBUG_REQ(D_INODE, req, "unlink %*s (remote inode %u/%u/%u)\n", + DEBUG_REQ(D_INODE, req, "unlink %*s (remote inode %u/%u/%u)", rec->ur_namelen - 1, rec->ur_name, (unsigned)dchild->d_mdsnum, (unsigned) dchild->d_inum, (unsigned) dchild->d_generation); diff --git a/lustre/obdclass/mea.c b/lustre/obdclass/mea.c index 56fc149..fa9ce2a 100644 --- a/lustre/obdclass/mea.c +++ b/lustre/obdclass/mea.c @@ -48,6 +48,8 @@ int mea_name2idx(struct mea *mea, char *name, int namelen) /* FIXME: real hash calculation here */ c = name[namelen - 1]; + if (c == 0) + CWARN("looks like wrong len is passed\n"); c = c % mea->mea_count; LASSERT(c < mea->mea_count); @@ -65,6 +67,8 @@ int raw_name2idx(int count, const char *name, int namelen) /* FIXME: real hash calculation here */ c = name[namelen - 1]; + if (c == 0) + CWARN("looks like wrong len is passed\n"); c = c % count; return c; -- 1.8.3.1