Merge branch 'for-linus' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Aug 2016 03:31:51 +0000 (23:31 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Aug 2016 03:31:51 +0000 (23:31 -0400)
Pull block fixes from Jens Axboe:
 "Here's the second round of block updates for this merge window.

  It's a mix of fixes for changes that went in previously in this round,
  and fixes in general.  This pull request contains:

   - Fixes for loop from Christoph

   - A bdi vs gendisk lifetime fix from Dan, worth two cookies.

   - A blk-mq timeout fix, when on frozen queues.  From Gabriel.

   - Writeback fix from Jan, ensuring that __writeback_single_inode()
     does the right thing.

   - Fix for bio->bi_rw usage in f2fs from me.

   - Error path deadlock fix in blk-mq sysfs registration from me.

   - Floppy O_ACCMODE fix from Jiri.

   - Fix to the new bio op methods from Mike.

     One more followup will be coming here, ensuring that we don't
     propagate the block types outside of block.  That, and a rename of
     bio->bi_rw is coming right after -rc1 is cut.

   - Various little fixes"

* 'for-linus' of git://git.kernel.dk/linux-block:
  mm/block: convert rw_page users to bio op use
  loop: make do_req_filebacked more robust
  loop: don't try to use AIO for discards
  blk-mq: fix deadlock in blk_mq_register_disk() error path
  Include: blkdev: Removed duplicate 'struct request;' declaration.
  Fixup direct bi_rw modifiers
  block: fix bdi vs gendisk lifetime mismatch
  blk-mq: Allow timeouts to run while queue is freezing
  nbd: fix race in ioctl
  block: fix use-after-free in seq file
  f2fs: drop bio->bi_rw manual assignment
  block: add missing group association in bio-cloning functions
  blkcg: kill unused field nr_undestroyed_grps
  writeback: Write dirty times for WB_SYNC_ALL writeback
  floppy: fix open(O_ACCMODE) for ioctl-only open

1  2 
fs/btrfs/extent_io.c

diff --combined fs/btrfs/extent_io.c
@@@ -163,13 -163,13 +163,13 @@@ int __init extent_io_init(void
  {
        extent_state_cache = kmem_cache_create("btrfs_extent_state",
                        sizeof(struct extent_state), 0,
 -                      SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
 +                      SLAB_MEM_SPREAD, NULL);
        if (!extent_state_cache)
                return -ENOMEM;
  
        extent_buffer_cache = kmem_cache_create("btrfs_extent_buffer",
                        sizeof(struct extent_buffer), 0,
 -                      SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
 +                      SLAB_MEM_SPREAD, NULL);
        if (!extent_buffer_cache)
                goto free_state_cache;
  
@@@ -2049,7 -2049,7 +2049,7 @@@ int repair_io_failure(struct inode *ino
                return -EIO;
        }
        bio->bi_bdev = dev->bdev;
-       bio->bi_rw = WRITE_SYNC;
+       bio_set_op_attrs(bio, REQ_OP_WRITE, WRITE_SYNC);
        bio_add_page(bio, page, length, pg_offset);
  
        if (btrfsic_submit_bio_wait(bio)) {
@@@ -2697,12 -2697,6 +2697,6 @@@ struct bio *btrfs_bio_clone(struct bio 
                btrfs_bio->csum = NULL;
                btrfs_bio->csum_allocated = NULL;
                btrfs_bio->end_io = NULL;
- #ifdef CONFIG_BLK_CGROUP
-               /* FIXME, put this into bio_clone_bioset */
-               if (bio->bi_css)
-                       bio_associate_blkcg(new, bio->bi_css);
- #endif
        }
        return new;
  }
@@@ -2756,6 -2750,7 +2750,6 @@@ static int merge_bio(struct extent_io_t
        if (tree->ops && tree->ops->merge_bio_hook)
                ret = tree->ops->merge_bio_hook(page, offset, size, bio,
                                                bio_flags);
 -      BUG_ON(ret < 0);
        return ret;
  
  }
@@@ -2878,7 -2873,6 +2872,7 @@@ __get_extent_map(struct inode *inode, s
   * into the tree that are removed when the IO is done (by the end_io
   * handlers)
   * XXX JDM: This needs looking at to ensure proper page locking
 + * return 0 on success, otherwise return error
   */
  static int __do_readpage(struct extent_io_tree *tree,
                         struct page *page,
        sector_t sector;
        struct extent_map *em;
        struct block_device *bdev;
 -      int ret;
 +      int ret = 0;
        int nr = 0;
        size_t pg_offset = 0;
        size_t iosize;
                } else {
                        SetPageError(page);
                        unlock_extent(tree, cur, cur + iosize - 1);
 +                      goto out;
                }
                cur = cur + iosize;
                pg_offset += iosize;
@@@ -3092,7 -3085,7 +3086,7 @@@ out
                        SetPageUptodate(page);
                unlock_page(page);
        }
 -      return 0;
 +      return ret;
  }
  
  static inline void __do_contiguous_readpages(struct extent_io_tree *tree,
@@@ -5231,31 -5224,14 +5225,31 @@@ int read_extent_buffer_pages(struct ext
        atomic_set(&eb->io_pages, num_reads);
        for (i = start_i; i < num_pages; i++) {
                page = eb->pages[i];
 +
                if (!PageUptodate(page)) {
 +                      if (ret) {
 +                              atomic_dec(&eb->io_pages);
 +                              unlock_page(page);
 +                              continue;
 +                      }
 +
                        ClearPageError(page);
                        err = __extent_read_full_page(tree, page,
                                                      get_extent, &bio,
                                                      mirror_num, &bio_flags,
                                                      REQ_META);
 -                      if (err)
 +                      if (err) {
                                ret = err;
 +                              /*
 +                               * We use &bio in above __extent_read_full_page,
 +                               * so we ensure that if it returns error, the
 +                               * current page fails to add itself to bio and
 +                               * it's been unlocked.
 +                               *
 +                               * We must dec io_pages by ourselves.
 +                               */
 +                              atomic_dec(&eb->io_pages);
 +                      }
                } else {
                        unlock_page(page);
                }