From: nathan Date: Wed, 24 Jun 2009 16:31:31 +0000 (+0000) Subject: b=18144 X-Git-Tag: v1_8_2_01~1^2~294 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ca972f3c306dd76dc9b8fddcfbe2f080eee1e803;p=fs%2Flustre-release.git b=18144 i=ericm i=wangybin hold the fsdb flag while assigning new OST indicies to prevent racing --- diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 4cbac7e..1f174b5 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -452,19 +452,12 @@ static __inline__ int next_index(void *index_map, int map_len) 0 newly marked as in use <0 err +EALREADY for update of an old index */ -int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti) +static int mgs_set_index(struct fs_db *fsdb, struct mgs_target_info *mti) { - struct fs_db *fsdb; void *imap; int rc = 0; ENTRY; - rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb); - if (rc) { - CERROR("Can't get db for %s\n", mti->mti_fsname); - RETURN(rc); - } - if (mti->mti_flags & LDD_F_SV_TYPE_OST) imap = fsdb->fsdb_ost_index_map; else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) @@ -1709,15 +1702,24 @@ int mgs_write_log_target(struct obd_device *obd, struct mgs_target_info *mti) { struct fs_db *fsdb; - int rc = -EINVAL; + int rc; ENTRY; + rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb); + if (rc) { + CERROR("Can't get db for %s\n", mti->mti_fsname); + RETURN(rc); + } + + down(&fsdb->fsdb_sem); + /* set/check the new target index */ - rc = mgs_set_index(obd, mti); + rc = mgs_set_index(fsdb, mti); if (rc < 0) { CERROR("Can't get index (%d)\n", rc); - RETURN(rc); + GOTO(out_up, rc); } + /* COMPAT_146 */ if (mti->mti_flags & LDD_F_UPGRADE14) { if (rc == EALREADY) { @@ -1755,14 +1757,6 @@ int mgs_write_log_target(struct obd_device *obd, } } - rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb); - if (rc) { - CERROR("Can't get db for %s\n", mti->mti_fsname); - RETURN(rc); - } - - down(&fsdb->fsdb_sem); - if (mti->mti_flags & (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) { /* Generate a log from scratch */