From: Nathaniel Clark Date: Wed, 19 Apr 2017 14:54:51 +0000 (-0400) Subject: LU-2155 utils: Enable ldiskfs mmp on tunefs failover add X-Git-Tag: 2.9.57~64 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F26758%2F2;p=fs%2Flustre-release.git LU-2155 utils: Enable ldiskfs mmp on tunefs failover add Enable Multi-Mount Protection in ldiskfs when adding a failover peer via tunefs. MMP is enabled in mkfs if failover is configured initially, but it wasn't if failover was added later. Signed-off-by: Nathaniel Clark Change-Id: Ie21ef5324de240afe0fd760cb4a9b3e1b4165064 Reviewed-on: https://review.whamcloud.com/26758 Tested-by: Jenkins Reviewed-by: Zhiqi Tao Reviewed-by: Bob Glossman Reviewed-by: Andreas Dilger Tested-by: Maloo --- diff --git a/lustre/utils/mount_utils_ldiskfs.c b/lustre/utils/mount_utils_ldiskfs.c index 4092eca..2620238 100644 --- a/lustre/utils/mount_utils_ldiskfs.c +++ b/lustre/utils/mount_utils_ldiskfs.c @@ -94,6 +94,8 @@ extern char *progname; static void append_unique(char *buf, char *prefix, char *key, char *val, size_t maxbuflen); +static int is_e2fsprogs_feature_supp(const char *feature); +static void disp_old_e2fsprogs_msg(const char *feature, int make_backfs); /* * Concatenate context of the temporary mount point if selinux is enabled @@ -264,6 +266,23 @@ int ldiskfs_write_ldd(struct mkfs_opts *mop) if (mop->mo_flags & MO_IS_LOOP) dev = mop->mo_loopdev; + /* Multiple mount protection enabled if failover node specified */ + if (mop->mo_flags & MO_FAILOVER && + !is_feature_enabled("mmp", dev)) { + if (is_e2fsprogs_feature_supp("-O mmp") == 0) { + char *command = filepnm; + + snprintf(command, sizeof(filepnm), + TUNE2FS" -O mmp '%s' >/dev/null 2>&1", dev); + ret = run_command(command, sizeof(filepnm)); + if (ret) + fprintf(stderr, + "%s: Unable to set 'mmp' on %s: %d\n", + progname, dev, ret); + } else + disp_old_e2fsprogs_msg("mmp", 1); + } + ret = mount(dev, mntpt, MT_STR(&mop->mo_ldd), 0, (mop->mo_mountopts == NULL) ? "errors=remount-ro" : mop->mo_mountopts);