Whamcloud - gitweb
LU-5654 osd-ldiskfs: Handle holes in osd_ldiskfs_read() 35/12035/3
authorLi Wei <wei.g.li@intel.com>
Wed, 24 Sep 2014 04:12:37 +0000 (12:12 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 26 Sep 2014 23:08:40 +0000 (23:08 +0000)
Current osd_ldiskfs_read() incorrectly returns zero and leaves the
corresponding portion of the buffer untouched when a block to be read
is not allocated.

Change-Id: Idfd441656b99aa039a6bb4f7141b5407553855da
Signed-off-by: Li Wei <wei.g.li@intel.com>
Reviewed-on: http://review.whamcloud.com/12035
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Liang Zhen <liang.zhen@intel.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-ldiskfs/osd_io.c
lustre/tests/conf-sanity.sh

index 9765595..8344d4a 100644 (file)
@@ -1355,15 +1355,21 @@ int osd_ldiskfs_read(struct inode *inode, void *buf, int size, loff_t *offs)
                 boffs = *offs & (blocksize - 1);
                 csize = min(blocksize - boffs, size);
                 bh = ldiskfs_bread(NULL, inode, block, 0, &err);
-                if (!bh) {
-                        CERROR("%s: can't read %u@%llu on ino %lu: rc = %d\n",
-                               LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
-                               csize, *offs, inode->i_ino, err);
-                        return err;
-                }
+               if (err != 0) {
+                       CERROR("%s: can't read %u@%llu on ino %lu: rc = %d\n",
+                              LDISKFS_SB(inode->i_sb)->s_es->s_volume_name,
+                              csize, *offs, inode->i_ino, err);
+                       if (bh != NULL)
+                               brelse(bh);
+                       return err;
+               }
 
-                memcpy(buf, bh->b_data + boffs, csize);
-                brelse(bh);
+               if (bh != NULL) {
+                       memcpy(buf, bh->b_data + boffs, csize);
+                       brelse(bh);
+               } else {
+                       memset(buf, 0, csize);
+               }
 
                 *offs += csize;
                 buf += csize;
index edaf102..b050725 100644 (file)
@@ -3669,6 +3669,7 @@ run_test 55 "check lov_objid size"
 
 test_56() {
        local mds_journal_size_orig=$MDSJOURNALSIZE
+       local n
 
        MDSJOURNALSIZE=16
 
@@ -3676,22 +3677,26 @@ test_56() {
                add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
                        --reformat $(mdsdevname $num) $(mdsvdevname $num)
        done
-       add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=1000 --reformat \
+       add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=10000 --reformat \
                $(ostdevname 1) $(ostvdevname 1)
-       add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=10000 --reformat \
+       add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=1000 --reformat \
                $(ostdevname 2) $(ostvdevname 2)
 
        start_mgsmds
-       start_ost
-       start_ost2 || error "Unable to start second ost"
+       start_ost || error "Unable to start first ost (idx 10000)"
+       start_ost2 || error "Unable to start second ost (idx 1000)"
        mount_client $MOUNT || error "Unable to mount client"
        echo ok
        $LFS osts
+       $LFS setstripe --stripe-count=-1 $DIR/$tfile || error "Unable to create"
+       n=$($LFS getstripe --stripe-count $DIR/$tfile)
+       [ "$n" -eq 2 ] || error "Stripe count not two: $n"
+       rm $DIR/$tfile
        stopall
        MDSJOURNALSIZE=$mds_journal_size_orig
        reformat
 }
-run_test 56 "check big indexes"
+run_test 56 "check big OST indexes and out-of-index-order start"
 
 test_57a() { # bug 22656
        local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')