Whamcloud - gitweb
LU-3006 utils: mount to pass/clear UPDATE flag
authorAlex Zhuravlev <alexey.zhuravlev@intel.com>
Tue, 23 Apr 2013 12:11:00 +0000 (16:11 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 27 Apr 2013 19:44:52 +0000 (15:44 -0400)
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 <alexey.zhuravlev@intel.com>
Change-Id: Ic0b4eb6b86798450e4dd4201611e4f5a1c54ef40
Reviewed-on: http://review.whamcloud.com/5982
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
lustre/include/lustre_disk.h
lustre/obdclass/obd_mount.c
lustre/obdclass/obd_mount_server.c
lustre/tests/conf-sanity.sh
lustre/utils/mount_lustre.c

index 819513f..b685dcb 100644 (file)
@@ -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_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)
 
 
 #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT)
 
index 6cb33aa..1c99179 100644 (file)
@@ -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, "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++;
                } else if (strncmp(s1, "virgin", 6) == 0) {
                        lmd->lmd_flags |= LMD_FLG_VIRGIN;
                        clear++;
index ce7eba5..01fd9e0 100644 (file)
@@ -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;
                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) ?
        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) ?
index 2bde5ee..12deabb 100644 (file)
@@ -3991,6 +3991,21 @@ test_72() { #LU-2634
 }
 run_test 72 "test fast symlink with extents flag enabled"
 
 }
 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
 if ! combined_mgs_mds ; then
        stop mgs
 fi
index 57348a5..1986c4b 100644 (file)
@@ -314,6 +314,58 @@ static int add_mgsnids(struct mount_opts *mop, char *options,
        return 0;
 }
 
        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;
 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;
        }
 
                return EINVAL;
        }
 
+       if (ldd->ldd_flags & LDD_F_UPDATE)
+               clear_update_ondisk(source, ldd);
+
        /* Since we never rewrite ldd, ignore temp flags */
        /* 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);
 
        /* 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_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)
        if (ldd->ldd_flags & LDD_F_WRITECONF)
                append_option(options, "writeconf");
        if (ldd->ldd_flags & LDD_F_NO_PRIMNODE)