From: Alex Zhuravlev Date: Tue, 23 Apr 2013 12:11:00 +0000 (+0400) Subject: LU-3006 utils: mount to pass/clear UPDATE flag X-Git-Tag: 2.3.65~56 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=10cf5e4ec079fed1fa339240e00c027232f7971e;hp=20544bd96269dbda51a76d31c2d09935637e8b2d LU-3006 utils: mount to pass/clear UPDATE flag this flag is maintained in mountdata (or fs attribute in case of ZFS) and used to signal MGS parameters have been changed and this need to be reflected in configuration profiles. the flag is cleared before actual mount as the device can be exclusively open by the filesystem preventing any updates. the scope of the patch is limited to UPDATE flag, but later we can try to use the approach to deal with WRITECONF/VIRGIN flags as well. test 73 added to conf-sanity to verify the case. Signed-off-by: Alex Zhuravlev Change-Id: Ic0b4eb6b86798450e4dd4201611e4f5a1c54ef40 Reviewed-on: http://review.whamcloud.com/5982 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Niu Yawei --- diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 819513f..b685dcb 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -240,6 +240,7 @@ struct lustre_mount_data { #define LMD_FLG_IAM 0x0400 /* IAM dir */ #define LMD_FLG_NO_PRIMNODE 0x0800 /* all nodes are service nodes */ #define LMD_FLG_VIRGIN 0x1000 /* the service registers first time */ +#define LMD_FLG_UPDATE 0x2000 /* update parameters */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 6cb33aa..1c99179 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1065,6 +1065,9 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) } else if (strncmp(s1, "writeconf", 9) == 0) { lmd->lmd_flags |= LMD_FLG_WRITECONF; clear++; + } else if (strncmp(s1, "update", 6) == 0) { + lmd->lmd_flags |= LMD_FLG_UPDATE; + clear++; } else if (strncmp(s1, "virgin", 6) == 0) { lmd->lmd_flags |= LMD_FLG_VIRGIN; clear++; diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index ce7eba5..01fd9e0 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -1384,6 +1384,8 @@ static int lsi_prepare(struct lustre_sb_info *lsi) LDD_F_WRITECONF : 0; lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_VIRGIN) ? LDD_F_VIRGIN : 0; + lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_UPDATE) ? + LDD_F_UPDATE : 0; lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_MGS) ? LDD_F_SV_TYPE_MGS : 0; lsi->lsi_flags |= (lsi->lsi_lmd->lmd_flags & LMD_FLG_NO_PRIMNODE) ? diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 2bde5ee..12deabb 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -3991,6 +3991,21 @@ test_72() { #LU-2634 } run_test 72 "test fast symlink with extents flag enabled" +test_73() { #LU-3006 + load_modules + do_facet ost1 "$TUNEFS --failnode=1.2.3.4@tcp $(ostdevname 1)" || + error "1st tunefs failed" + start_mgsmds || error "start mds failed" + start_ost || error "start ost failed" + mount_client $MOUNT || error "mount client failed" + lctl get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids | + grep 1.2.3.4@tcp || error "failover nids haven't changed" + umount_client $MOUNT || error "umount client failed" + stop_all + reformat +} +run_test 73 "failnode to update from mountdata properly" + if ! combined_mgs_mds ; then stop mgs fi diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 57348a5..1986c4b 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -314,6 +314,58 @@ static int add_mgsnids(struct mount_opts *mop, char *options, return 0; } +static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd) +{ + char always_mountopts[512] = ""; + char default_mountopts[512] = ""; + struct mkfs_opts mkop; + int ret; + + memset(&mkop, 0, sizeof(mkop)); + mkop.mo_ldd = *ldd; + mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE; + strcpy(mkop.mo_device, source); + + ret = osd_prepare_lustre(&mkop, + default_mountopts, sizeof(default_mountopts), + always_mountopts, sizeof(always_mountopts)); + if (ret) { + fatal(); + fprintf(stderr, "Can't prepare device %s: %s\n", + source, strerror(ret)); + return ret; + } + + /* Create the loopback file */ + if (mkop.mo_flags & MO_IS_LOOP) { + ret = access(mkop.mo_device, F_OK); + if (ret) { + ret = errno; + fatal(); + fprintf(stderr, "Can't access device %s: %s\n", + source, strerror(ret)); + return ret; + } + + ret = loop_setup(&mkop); + if (ret) { + fatal(); + fprintf(stderr, "Loop device setup for %s failed: %s\n", + mkop.mo_device, strerror(ret)); + return ret; + } + } + ret = osd_write_ldd(&mkop); + if (ret != 0) { + fatal(); + fprintf(stderr, "failed to write local files: %s\n", + strerror(ret)); + } + loop_cleanup(&mkop); + + return ret; +} + static int parse_ldd(char *source, struct mount_opts *mop, char *options) { struct lustre_disk_data *ldd = &mop->mo_ldd; @@ -349,8 +401,11 @@ static int parse_ldd(char *source, struct mount_opts *mop, char *options) return EINVAL; } + if (ldd->ldd_flags & LDD_F_UPDATE) + clear_update_ondisk(source, ldd); + /* Since we never rewrite ldd, ignore temp flags */ - ldd->ldd_flags &= ~(LDD_F_VIRGIN | LDD_F_UPDATE | LDD_F_WRITECONF); + ldd->ldd_flags &= ~(LDD_F_VIRGIN | LDD_F_WRITECONF); /* svname of the form lustre:OST1234 means never registered */ rc = strlen(ldd->ldd_svname); @@ -387,6 +442,8 @@ static int parse_ldd(char *source, struct mount_opts *mop, char *options) if (ldd->ldd_flags & LDD_F_VIRGIN) append_option(options, "virgin"); + if (ldd->ldd_flags & LDD_F_UPDATE) + append_option(options, "update"); if (ldd->ldd_flags & LDD_F_WRITECONF) append_option(options, "writeconf"); if (ldd->ldd_flags & LDD_F_NO_PRIMNODE)