From edd23b38148bf7bddc3727adda8f33f43e0d3287 Mon Sep 17 00:00:00 2001 From: shadow Date: Thu, 17 Sep 2009 09:27:06 +0000 Subject: [PATCH] Don't allow make backward step on assiging osc next id. Branch b_release_1_8_1 b=19557 i=tappro i=jay --- lustre/ChangeLog | 6 ++++++ lustre/osc/osc_request.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 85d146d..adb076d 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -15,6 +15,12 @@ TBD Sun Microsystems, Inc. * ext4 support for RHEL5 is experimental and thus should not be used in production. +Severity : normal +Bugzilla : 19557 +Description: Don't allow make backward step on assiging osc next id. +Details : race between allocation next id and ll_sync thread can be cause + of set wrong osc next id and can be kill valid ost objects. + Severity : enhancement Bugzilla : 20400 Description: Update kernel to RHEL5 2.6.18-128.7.1.el5. diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 31de776..eec906b 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3945,18 +3945,30 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen, OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); if (KEY_IS(KEY_NEXT_ID)) { + obd_id new_val; + struct osc_creator *oscc = &obd->u.cli.cl_oscc; + if (vallen != sizeof(obd_id)) RETURN(-EINVAL); - obd->u.cli.cl_oscc.oscc_next_id = *((obd_id*)val) + 1; + + /* avoid race between allocate new object and set next id + * from ll_sync thread */ + spin_lock(&oscc->oscc_lock); + new_val = *((obd_id*)val) + 1; + if (new_val >= oscc->oscc_next_id); + oscc->oscc_next_id = new_val; + spin_unlock(&oscc->oscc_lock); + CDEBUG(D_HA, "%s: set oscc_next_id = "LPU64"\n", exp->exp_obd->obd_name, - obd->u.cli.cl_oscc.oscc_next_id); + oscc->oscc_next_id); RETURN(0); } if (KEY_IS(KEY_UNLINKED)) { struct osc_creator *oscc = &obd->u.cli.cl_oscc; + spin_lock(&oscc->oscc_lock); oscc->oscc_flags &= ~OSCC_FLAG_NOSPC; spin_unlock(&oscc->oscc_lock); -- 1.8.3.1