Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Tue, 10 Oct 2006 15:11:52 +0000 (15:11 +0000)
committerwangdi <wangdi>
Tue, 10 Oct 2006 15:11:52 +0000 (15:11 +0000)
2 fixes of split
1)reset hash_segment until we do not get -E2BIG
2)do not create . and .. for slave obj

lustre/lmv/lmv_obd.c
lustre/mdd/mdd_handler.c

index 31f1bf7..ba3a517 100644 (file)
@@ -1941,6 +1941,8 @@ static int lmv_reset_hash_seg_end (struct lmv_obd *lmv, struct lmv_obj *obj,
         if (!page)
                 GOTO(cleanup, rc = -ENOMEM);
 
+        CDEBUG(D_INFO,"readpage %lu:%x for reset split"DFID" \n",
+               seg_end, seg_end, PFID(&rid));
         rc = md_readpage(tgt_exp, &rid, NULL, seg_end, page, &tmp_req);
         if (rc) {
                 /* E2BIG means it already reached the end of the dir,
@@ -2018,14 +2020,20 @@ static int lmv_readpage(struct obd_export *exp, const struct lu_fid *fid,
                 kmap(page);
                 dp = cfs_page_address(page);
                 end = le32_to_cpu(dp->ldp_hash_end);
-                if (end == ~0ul)
-                        rc = lmv_reset_hash_seg_end(lmv, obj, fid,
-                                                    i + 1, dp);
+                CDEBUG(D_INFO, "get "DFID" with end %lu i %d\n",
+                       PFID(&rid), (unsigned long)end, i);
+                if (end == ~0ul) {
+                        do {
+                                rc = lmv_reset_hash_seg_end(lmv, obj, fid,
+                                                            ++i, dp);
+                                if (i >= obj->lo_objcount - 1)
+                                        break;
+                                /* if there are no entries in this segment 
+                                 * and it is not the last hash segment */
+                        } while (rc != -E2BIG);
+                }
                 kunmap(page);
-        } else
-                if (rc == -ERANGE)
-                        rc = -EIO;
-
+        }
         /*
          * Here we could remove "." and ".." from all pages which at not from
          * master. But MDS has only "." and ".." for master dir.
index a3a4576..d14d5fc 100644 (file)
@@ -372,7 +372,7 @@ static struct lu_object *mdd_object_alloc(const struct lu_env *env,
         OBD_ALLOC_PTR(mdd_obj);
         if (mdd_obj != NULL) {
                 struct lu_object *o;
-               
+
                 o = mdd2lu_obj(mdd_obj);
                 lu_object_init(o, NULL, d);
                 mdd_obj->mod_obj.mo_ops = &mdd_obj_ops;
@@ -2574,22 +2574,29 @@ static int mdd_object_create(const struct lu_env *env,
 
         mdd_write_lock(env, mdd_obj);
         rc = __mdd_object_create(env, mdd_obj, ma, handle);
-        if (rc == 0 && spec->sp_cr_flags & MDS_CREATE_SLAVE_OBJ) {
+        if (rc)
+                GOTO (unlock, rc);
+
+        if (spec->sp_cr_flags & MDS_CREATE_SLAVE_OBJ) {
                 /* if creating the slave object, set slave EA here */
+                int lmv_size = spec->u.sp_ea.eadatalen;
+                struct lmv_stripe_md *lmv;
+
+                lmv = (struct lmv_stripe_md *)spec->u.sp_ea.eadata;
+                LASSERT(lmv != NULL && lmv_size > 0);
                 rc = __mdd_xattr_set(env, mdd_obj,
-                                     mdd_buf_get_const(env,
-                                                       spec->u.sp_ea.eadata,
-                                                       spec->u.sp_ea.eadatalen),
+                                     mdd_buf_get_const(env, lmv, lmv_size),
                                      MDS_LMV_MD_NAME, 0, handle);
+                if (rc)
+                        GOTO(unlock, rc);
                 pfid = spec->u.sp_ea.fid;
-                CWARN("set slave ea "DFID" eadatalen %d rc %d \n",
+                CWARN("set slave ea "DFID" eadatalen %d rc %d\n",
                        PFID(mdo2fid(mdd_obj)), spec->u.sp_ea.eadatalen, rc);
-        }
-
-        if (rc == 0)
+                rc = mdd_attr_set_internal(env, mdd_obj, &ma->ma_attr, handle);
+        } else
                 rc = __mdd_object_initialize(env, pfid, mdd_obj, ma, handle);
+unlock:
         mdd_write_unlock(env, mdd_obj);
-
         if (rc == 0)
                 rc = mdd_attr_get_internal_locked(env, mdd_obj, ma);