From: Wang Shilong Date: Fri, 6 Feb 2015 17:06:54 +0000 (+0800) Subject: LU-6491 llog: fix wrong return value for too long fsname X-Git-Tag: 2.7.55~43 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5b6d23d7fb8de7ae44ca369381a128c78f78bf21 LU-6491 llog: fix wrong return value for too long fsname 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 Change-Id: I51d0cf28a88d828cea4f8be9977ed274b822ea01 Reviewed-on: http://review.whamcloud.com/14568 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index d804de4..b835aa5 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -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 */