From: James Simmons Date: Tue, 4 Oct 2016 13:44:45 +0000 (-0400) Subject: LU-8660 mgs: handle return code of server_make_name() X-Git-Tag: 2.8.60~47 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=refs%2Fchanges%2F67%2F22867%2F3 LU-8660 mgs: handle return code of server_make_name() Make sure server_make_name() actually succeeded when called in mkfs_lustre utility and mgs_set_index(). Change-Id: I218351f0f3dd98e1b928664f872c1702a419a7cc Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/22867 Tested-by: Jenkins Reviewed-by: Dmitry Eremin Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index b688435..e221485 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -49,6 +49,7 @@ #ifdef __KERNEL__ #include #else +#include #include #endif #include @@ -191,9 +192,11 @@ struct lustre_disk_data { #define MT_STR(data) mt_str((data)->ldd_mount_type) /* Make the mdt/ost server obd name based on the filesystem name */ -static inline int server_make_name(__u32 flags, __u16 index, char *fs, - char *name) +static inline bool server_make_name(__u32 flags, __u16 index, char *fs, + char *name) { + bool invalid_flag = false; + if (flags & (LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) { if (!(flags & LDD_F_SV_ALL)) sprintf(name, "%.8s%c%s%04x", fs, @@ -205,9 +208,9 @@ static inline int server_make_name(__u32 flags, __u16 index, char *fs, sprintf(name, "MGS"); } else { CERROR("unknown server type %#x\n", flags); - return 1; - } - return 0; + invalid_flag = true; + } + return invalid_flag; } /****************** mount command *********************/ diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index 6b0aadb..689ff3c 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -594,8 +594,12 @@ static int mgs_set_index(const struct lu_env *env, set_bit(mti->mti_stripe_index, imap); clear_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags); mutex_unlock(&fsdb->fsdb_mutex); - server_make_name(mti->mti_flags & ~(LDD_F_VIRGIN | LDD_F_WRITECONF), - mti->mti_stripe_index, mti->mti_fsname, mti->mti_svname); + if (server_make_name(mti->mti_flags & ~(LDD_F_VIRGIN | LDD_F_WRITECONF), + mti->mti_stripe_index, mti->mti_fsname, + mti->mti_svname)) { + CERROR("unknown server type %#x\n", mti->mti_flags); + return -EINVAL; + } CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname, mti->mti_stripe_index); diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c index f2c1ec9..1a365e9 100644 --- a/lustre/utils/mkfs_lustre.c +++ b/lustre/utils/mkfs_lustre.c @@ -776,8 +776,11 @@ int main(int argc, char *const argv[]) goto out; } - server_make_name(ldd->ldd_flags, ldd->ldd_svindex, - ldd->ldd_fsname, ldd->ldd_svname); + if (server_make_name(ldd->ldd_flags, ldd->ldd_svindex, + ldd->ldd_fsname, ldd->ldd_svname)) { + printf("unknown server type %#x\n", ldd->ldd_flags); + goto out; + } if (verbose >= 0) print_ldd("Permanent disk data", ldd);