Whamcloud - gitweb
- lmv_getattr_name() recognizes cross-node name and repeats getattr to proper
authoralex <alex>
Mon, 24 May 2004 18:39:04 +0000 (18:39 +0000)
committeralex <alex>
Mon, 24 May 2004 18:39:04 +0000 (18:39 +0000)
  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
lustre/mdc/mdc_request.c
lustre/mds/mds_reint.c
lustre/obdclass/mea.c

index 7ab2c43..99e229e 100644 (file)
@@ -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);
 
index d6b156d..f6fdd32 100644 (file)
@@ -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) {
index 976e87e..8dc5409 100644 (file)
@@ -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);
 
index 56fc149..fa9ce2a 100644 (file)
@@ -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;