Whamcloud - gitweb
LU-622 Alloc enough cfg buffer space
authorBobi Jam <bobijam@whamcloud.com>
Wed, 24 Aug 2011 04:07:22 +0000 (12:07 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 25 Aug 2011 02:38:31 +0000 (22:38 -0400)
obd device name needs space enough for "<dev_name>-<instance_name>\0".
This fixes the glitch in commit cbc4ca2e8dc37d54bb7d3c9b02ab20b63e60f592.

Change-Id: Ib8c3c8db49baad8a9ca068a1c8009aee72aa1e62
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1280
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Jinshan Xiong <jay@whamcloud.com>
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Tested-by: Yu Jian <yujian@whamcloud.com>
lustre/liblustre/super.c
lustre/llite/llite_lib.c
lustre/obdclass/obd_config.c

index 9c479f5..447481e 100644 (file)
@@ -1858,6 +1858,8 @@ llu_fsswop_mount(const char *source,
         int async = 1, err = -EINVAL;
         struct obd_connect_data ocd = {0,};
         struct md_op_data op_data = {{0}};
         int async = 1, err = -EINVAL;
         struct obd_connect_data ocd = {0,};
         struct md_op_data op_data = {{0}};
+        /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
+        const int instlen = sizeof(cfg.cfg_instance) * 2 + 2;
 
         ENTRY;
 
 
         ENTRY;
 
@@ -1897,10 +1899,10 @@ llu_fsswop_mount(const char *source,
                 CERROR("No profile found: %s\n", zconf_profile);
                 GOTO(out_free, err = -EINVAL);
         }
                 CERROR("No profile found: %s\n", zconf_profile);
                 GOTO(out_free, err = -EINVAL);
         }
-        OBD_ALLOC(osc, strlen(lprof->lp_dt) + sizeof(cfg.cfg_instance)*2 + 1);
+        OBD_ALLOC(osc, strlen(lprof->lp_dt) + instlen + 2);
         sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance);
 
         sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance);
 
-        OBD_ALLOC(mdc, strlen(lprof->lp_md) + sizeof(cfg.cfg_instance)*2 + 1);
+        OBD_ALLOC(mdc, strlen(lprof->lp_md) + instlen + 2);
         sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance);
 
         if (!osc) {
         sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance);
 
         if (!osc) {
@@ -2034,9 +2036,8 @@ llu_fsswop_mount(const char *source,
         ptlrpc_req_finished(request);
 
         CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source);
         ptlrpc_req_finished(request);
 
         CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source);
-        liblustre_wait_idle();
-
-        return 0;
+        err = 0;
+        goto out_free;
 
 out_inode:
         _sysio_i_gone(root);
 
 out_inode:
         _sysio_i_gone(root);
@@ -2048,9 +2049,9 @@ out_md:
         obd_disconnect(sbi->ll_md_exp);
 out_free:
         if (osc)
         obd_disconnect(sbi->ll_md_exp);
 out_free:
         if (osc)
-                OBD_FREE(osc, strlen(osc) + 1);
+                OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2);
         if (mdc)
         if (mdc)
-                OBD_FREE(mdc, strlen(mdc) + 1);
+                OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2);
         OBD_FREE(sbi, sizeof(*sbi));
         liblustre_wait_idle();
         return err;
         OBD_FREE(sbi, sizeof(*sbi));
         liblustre_wait_idle();
         return err;
index a0b5027..f97250b 100644 (file)
@@ -900,7 +900,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
         char  *dt = NULL, *md = NULL;
         char  *profilenm = get_profile_name(sb);
         struct config_llog_instance *cfg;
         char  *dt = NULL, *md = NULL;
         char  *profilenm = get_profile_name(sb);
         struct config_llog_instance *cfg;
-        const int instlen = sizeof(cfg->cfg_instance) * 2 + 1;
+        /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
+        const int instlen = sizeof(cfg->cfg_instance) * 2 + 2;
         int    err;
         ENTRY;
 
         int    err;
         ENTRY;
 
@@ -961,12 +962,12 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
         CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
                lprof->lp_md, lprof->lp_dt);
 
         CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
                lprof->lp_md, lprof->lp_dt);
 
-        OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen);
+        OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2);
         if (!dt)
                 GOTO(out_free, err = -ENOMEM);
         sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
 
         if (!dt)
                 GOTO(out_free, err = -ENOMEM);
         sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
 
-        OBD_ALLOC(md, strlen(lprof->lp_md) + instlen);
+        OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2);
         if (!md)
                 GOTO(out_free, err = -ENOMEM);
         sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
         if (!md)
                 GOTO(out_free, err = -ENOMEM);
         sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
@@ -976,9 +977,9 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
 
 out_free:
         if (md)
 
 out_free:
         if (md)
-                OBD_FREE(md, strlen(lprof->lp_md) + instlen);
+                OBD_FREE(md, strlen(lprof->lp_md) + instlen + 2);
         if (dt)
         if (dt)
-                OBD_FREE(dt, strlen(lprof->lp_dt) + instlen);
+                OBD_FREE(dt, strlen(lprof->lp_dt) + instlen + 2);
         if (err)
                 ll_put_super(sb);
         else
         if (err)
                 ll_put_super(sb);
         else
index 49469af..f9fa331 100644 (file)
@@ -1286,7 +1286,7 @@ static int class_config_llog_handler(struct llog_handle * handle,
                     LUSTRE_CFG_BUFLEN(lcfg, 0) > 0){
                         inst = 1;
                         inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
                     LUSTRE_CFG_BUFLEN(lcfg, 0) > 0){
                         inst = 1;
                         inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
-                                   sizeof(clli->cfg_instance) * 2 + 1;
+                                   sizeof(clli->cfg_instance) * 2 + 4;
                         OBD_ALLOC(inst_name, inst_len);
                         if (inst_name == NULL)
                                 GOTO(out, rc = -ENOMEM);
                         OBD_ALLOC(inst_name, inst_len);
                         if (inst_name == NULL)
                                 GOTO(out, rc = -ENOMEM);