OSDN Git Service

Merge branch 'for-4.13-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Jul 2017 19:26:59 +0000 (12:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Jul 2017 19:26:59 +0000 (12:26 -0700)
Pull btrfs fixes from David Sterba:
 "Fixes addressing problems reported by users, and there's one more
  regression fix"

* 'for-4.13-part3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: round down size diff when shrinking/growing device
  Btrfs: fix early ENOSPC due to delalloc
  btrfs: fix lockup in find_free_extent with read-only block groups
  Btrfs: fix dir item validation when replaying xattr deletes

1  2 
fs/btrfs/volumes.c

diff --combined fs/btrfs/volumes.c
@@@ -2702,7 -2702,7 +2702,7 @@@ int btrfs_grow_device(struct btrfs_tran
  
        mutex_lock(&fs_info->chunk_mutex);
        old_total = btrfs_super_total_bytes(super_copy);
-       diff = new_size - device->total_bytes;
+       diff = round_down(new_size - device->total_bytes, fs_info->sectorsize);
  
        if (new_size <= device->total_bytes ||
            device->is_tgtdev_for_dev_replace) {
@@@ -4406,7 -4406,7 +4406,7 @@@ int btrfs_shrink_device(struct btrfs_de
        u64 diff;
  
        new_size = round_down(new_size, fs_info->sectorsize);
-       diff = old_size - new_size;
+       diff = round_down(old_size - new_size, fs_info->sectorsize);
  
        if (device->is_tgtdev_for_dev_replace)
                return -EINVAL;
@@@ -6049,10 -6049,9 +6049,10 @@@ static void btrfs_end_bio(struct bio *b
        struct btrfs_bio *bbio = bio->bi_private;
        int is_orig_bio = 0;
  
 -      if (bio->bi_error) {
 +      if (bio->bi_status) {
                atomic_inc(&bbio->error);
 -              if (bio->bi_error == -EIO || bio->bi_error == -EREMOTEIO) {
 +              if (bio->bi_status == BLK_STS_IOERR ||
 +                  bio->bi_status == BLK_STS_TARGET) {
                        unsigned int stripe_index =
                                btrfs_io_bio(bio)->stripe_index;
                        struct btrfs_device *dev;
                 * beyond the tolerance of the btrfs bio
                 */
                if (atomic_read(&bbio->error) > bbio->max_errors) {
 -                      bio->bi_error = -EIO;
 +                      bio->bi_status = BLK_STS_IOERR;
                } else {
                        /*
                         * this bio is actually up to date, we didn't
                         * go over the max number of errors
                         */
 -                      bio->bi_error = 0;
 +                      bio->bi_status = 0;
                }
  
                btrfs_end_bbio(bbio, bio);
@@@ -6207,7 -6206,7 +6207,7 @@@ static void bbio_error(struct btrfs_bi
  
                btrfs_io_bio(bio)->mirror_num = bbio->mirror_num;
                bio->bi_iter.bi_sector = logical >> 9;
 -              bio->bi_error = -EIO;
 +              bio->bi_status = BLK_STS_IOERR;
                btrfs_end_bbio(bbio, bio);
        }
  }