Whamcloud - gitweb
LU-6400 osd: initialize variable before use 08/16008/4
authorYang Sheng <yang.sheng@intel.com>
Tue, 25 Aug 2015 08:35:36 +0000 (16:35 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 26 Aug 2015 20:55:04 +0000 (20:55 +0000)
ldisk_bread use a pointer return error value. But not
initialized it. So maybe return a random value even in
normal case.

Signed-off-by: Yang Sheng <yang.sheng@intel.com>
Change-Id: I2ab424b285003c85b63dbea0b787b606fc368245
Reviewed-on: http://review.whamcloud.com/16008
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mgs/mgs_llog.c
lustre/osd-ldiskfs/osd_iam.c
lustre/osd-ldiskfs/osd_io.c

index 1b43a56..cc004ad 100644 (file)
@@ -2155,8 +2155,7 @@ static int mgs_write_log_osp_to_mdt(const struct lu_env *env,
                GOTO(out_end, rc);
 
        /* Add mdc(osp) to lod */
-       snprintf(index_str, sizeof(mti->mti_stripe_index), "%d",
-                mti->mti_stripe_index);
+       snprintf(index_str, sizeof(index_str), "%d", mti->mti_stripe_index);
        rc = record_base(env, llh, lovname, 0, LCFG_ADD_MDC, mti->mti_uuid,
                         index_str, "1", NULL);
        if (rc)
index 8d10fe9..edada30 100644 (file)
@@ -174,7 +174,7 @@ iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk)
        struct inode *inode = c->ic_object;
        struct iam_idle_head *head;
        struct buffer_head *bh;
-       int err;
+       int err = 0;
 
        LASSERT(mutex_is_locked(&c->ic_idle_mutex));
 
@@ -186,6 +186,7 @@ iam_load_idle_blocks(struct iam_container *c, iam_ptr_t blk)
                CERROR("%.16s: cannot load idle blocks, blk = %u, err = %d\n",
                       LDISKFS_SB(inode->i_sb)->s_es->s_volume_name, blk, err);
                c->ic_idle_failed = 1;
+               err = err ? err : -EIO;
                return ERR_PTR(err);
        }
 
@@ -374,7 +375,7 @@ int iam_node_read(struct iam_container *c, iam_ptr_t ptr,
 
         *bh = ldiskfs_bread(h, c->ic_object, (int)ptr, 0, &result);
         if (*bh == NULL)
-                result = -EIO;
+               result = result ? result : -EIO;
         return result;
 }
 
@@ -1676,8 +1677,10 @@ iam_new_node(handle_t *h, struct iam_container *c, iam_ptr_t *b, int *e)
 
                mutex_unlock(&c->ic_idle_mutex);
                bh = ldiskfs_bread(NULL, inode, *b, 0, e);
-               if (bh == NULL)
+               if (bh == NULL) {
+                       *e = *e ? *e : -EIO;
                        return NULL;
+               }
                goto got;
        }
 
index 3939ae9..7356fb2 100644 (file)
@@ -1377,7 +1377,7 @@ int osd_ldiskfs_read(struct inode *inode, void *buf, int size, loff_t *offs)
         int blocksize;
         int csize;
         int boffs;
-        int err;
+       int err = 0;
 
         /* prevent reading after eof */
        spin_lock(&inode->i_lock);
@@ -1637,6 +1637,7 @@ int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize,
                 size = min(blocksize - boffs, bufsize);
                 bh = ldiskfs_bread(handle, inode, block, 1, &err);
                 if (!bh) {
+                       err = err ? err : -EIO;
                         CERROR("%s: error reading offset %llu (block %lu): "
                                "rc = %d\n",
                                inode->i_sb->s_id, offset, block, err);