From 2839ad0d1dc60a6a4e0cc81585c5a9f99b8852c3 Mon Sep 17 00:00:00 2001 From: niu Date: Wed, 10 Dec 2003 01:36:14 +0000 Subject: [PATCH] b: 2226 r: Phil Remove all orhpans on OST while MDS startup, and set last_id correctly. --- lustre/obdfilter/filter.c | 37 ++++++++++++++++++++----------------- lustre/osc/osc_create.c | 5 ++--- lustre/tests/sanity.sh | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 62e0f44..1131dfa 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -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 diff --git a/lustre/osc/osc_create.c b/lustre/osc/osc_create.c index 2f6d431..04970cc 100644 --- a/lustre/osc/osc_create.c +++ b/lustre/osc/osc_create.c @@ -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); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5b30118..fc4af06 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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" -- 1.8.3.1