Whamcloud - gitweb
LU-8660 mgs: handle return code of server_make_name() 67/22867/3
authorJames Simmons <uja.ornl@yahoo.com>
Tue, 4 Oct 2016 13:44:45 +0000 (09:44 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 20 Oct 2016 10:38:34 +0000 (10:38 +0000)
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 <uja.ornl@yahoo.com>
Reviewed-on: http://review.whamcloud.com/22867
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_disk.h
lustre/mgs/mgs_llog.c
lustre/utils/mkfs_lustre.c

index b688435..e221485 100644 (file)
@@ -49,6 +49,7 @@
 #ifdef __KERNEL__
 #include <linux/list.h>
 #else
+#include <stdbool.h>
 #include <libcfs/util/list.h>
 #endif
 #include <lnet/types.h>
@@ -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 *********************/
index 6b0aadb..689ff3c 100644 (file)
@@ -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);
index f2c1ec9..1a365e9 100644 (file)
@@ -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);