Whamcloud - gitweb
b: 2226
authorniu <niu>
Wed, 10 Dec 2003 01:36:14 +0000 (01:36 +0000)
committerniu <niu>
Wed, 10 Dec 2003 01:36:14 +0000 (01:36 +0000)
r: Phil

Remove all orhpans on OST while MDS startup, and set last_id correctly.

lustre/obdfilter/filter.c
lustre/osc/osc_create.c
lustre/tests/sanity.sh

index 62e0f44..1131dfa 100644 (file)
@@ -1555,29 +1555,32 @@ static int filter_should_precreate(struct obd_export *exp, struct obdo *oa,
         int diff, rc;
         ENTRY;
 
-        /* only precreate if group == 0 and o_id is specfied */
-        if (group != 0 || oa->o_id == 0)
-                RETURN(1);
-
         diff = oa->o_id - filter_last_id(filter, oa);
         CDEBUG(D_INFO, "filter_last_id() = "LPU64" -> diff = %d\n",
                filter_last_id(filter, oa), diff);
-        if (diff >= 0)
-                RETURN(diff);
-
-        if (!(oa->o_valid & OBD_MD_FLFLAGS) ||
-            !(oa->o_flags & OBD_FL_DELORPHAN)) {
-                CERROR("filter asked to delete %d objects, but DELORPHAN flag "
-                       "isn't set!\n", -diff);
+       
+        /* delete orphans request */
+        if ((oa->o_valid & OBD_MD_FLFLAGS) && 
+            (oa->o_flags & OBD_FL_DELORPHAN)) {
+                LASSERT(diff <= 0);
+                if (diff == 0)
+                        RETURN(0);
+                filter_destroy_precreated(exp, oa, filter);
+                rc = filter_update_last_objid(obd, group, 0);
+                if (rc)
+                        CERROR("unable to write lastobjid, but orphans" 
+                               "were deleted\n");
                 RETURN(0);
+        } else {
+                /* only precreate if group == 0 and o_id is specfied */
+                if (!(oa->o_valid & OBD_FL_DELORPHAN) && 
+                    (group != 0 || oa->o_id == 0))
+                        RETURN(1);
+
+                LASSERT(diff >= 0);
+                RETURN(diff);
         }
 
-        /* delete orphan request */
-        filter_destroy_precreated(exp, oa, filter);
-        rc = filter_update_last_objid(obd, group, 0);
-        if (rc)
-                CERROR("unable to write lastobjid, but orphans were deleted\n");
-        RETURN(rc);
 }
 
 /* We rely on the fact that only one thread will be creating files in a given
index 2f6d431..04970cc 100644 (file)
@@ -216,9 +216,8 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
            oa->o_flags == OBD_FL_DELORPHAN) {
                 /* delete from next_id on up */
                 oa->o_valid |= OBD_MD_FLID;
-                oa->o_id = oscc->oscc_next_id;
-                if (oa->o_id == 0)
-                        RETURN(0);
+                oa->o_id = oscc->oscc_next_id - 1;
+
                 rc = osc_real_create(oscc->oscc_exp, oa, ea, NULL);
 
                 spin_lock(&oscc->oscc_lock);
index 5b30118..fc4af06 100644 (file)
@@ -1480,7 +1480,7 @@ run_test 52b "immutable flag test =============================="
 
 test_53() {
         for i in /proc/fs/lustre/osc/OSC*mds1 ; do
-                ostname=`echo $i | cut -d _ -f 3-4`
+                ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
                 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
                 mds_last=`cat $i/prealloc_last_id`
                 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"