Whamcloud - gitweb
LU-6491 llog: fix wrong return value for too long fsname 68/14568/5
authorWang Shilong <wshilong@ddn.com>
Fri, 6 Feb 2015 17:06:54 +0000 (01:06 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 28 May 2015 22:27:10 +0000 (22:27 +0000)
If users passed a fsname longer than 9 bytes, caller
will handle it as ENOMEM which output following results:

error: conf_param: Cannot allocate memory

which is really unfriendly for common users.

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I51d0cf28a88d828cea4f8be9977ed274b822ea01
Reviewed-on: http://review.whamcloud.com/14568
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mgs/mgs_llog.c

index d804de4..b835aa5 100644 (file)
@@ -334,12 +334,12 @@ static struct fs_db *mgs_new_fsdb(const struct lu_env *env,
 
         if (strlen(fsname) >= sizeof(fsdb->fsdb_name)) {
                 CERROR("fsname %s is too long\n", fsname);
-                RETURN(NULL);
+               RETURN(ERR_PTR(-EINVAL));
         }
 
         OBD_ALLOC_PTR(fsdb);
         if (!fsdb)
-                RETURN(NULL);
+               RETURN(ERR_PTR(-ENOMEM));
 
         strcpy(fsdb->fsdb_name, fsname);
        mutex_init(&fsdb->fsdb_mutex);
@@ -380,7 +380,7 @@ err:
         name_destroy(&fsdb->fsdb_clilov);
         name_destroy(&fsdb->fsdb_clilmv);
         OBD_FREE_PTR(fsdb);
-        RETURN(NULL);
+       RETURN(ERR_PTR(rc));
 }
 
 static void mgs_free_fsdb(struct mgs_device *mgs, struct fs_db *fsdb)
@@ -443,11 +443,11 @@ int mgs_find_or_make_fsdb(const struct lu_env *env,
         CDEBUG(D_MGS, "Creating new db\n");
        fsdb = mgs_new_fsdb(env, mgs, name);
        /* lock fsdb_mutex until the db is loaded from llogs */
-       if (fsdb)
+       if (!IS_ERR(fsdb))
                mutex_lock(&fsdb->fsdb_mutex);
        mutex_unlock(&mgs->mgs_mutex);
-        if (!fsdb)
-               RETURN(-ENOMEM);
+       if (IS_ERR(fsdb))
+               RETURN(PTR_ERR(fsdb));
 
        if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) {
                 /* populate the db from the client llog */