btrfs: add dummy callback for readpage_io_failed and drop checks
authorDavid Sterba <dsterba@suse.com>
Fri, 17 Feb 2017 15:24:29 +0000 (16:24 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 28 Feb 2017 13:29:24 +0000 (14:29 +0100)
Make extent_io_ops::readpage_io_failed_hook callback mandatory and
define a dummy function for btrfs_extent_io_ops. As the failed IO
callback is not performance critical, the branch vs extra trade off does
not hurt.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/inode.c

index 60d4f1b210d7d6f66b1a578343b4872bf28ea84b..cad47ece2fdfbf4b738c0cb2391bd95bb4411a93 100644 (file)
@@ -4658,7 +4658,7 @@ static const struct extent_io_ops btree_extent_io_ops = {
        .readpage_end_io_hook = btree_readpage_end_io_hook,
        /* note we're sharing with inode.c for the merge bio hook */
        .merge_bio_hook = btrfs_merge_bio_hook,
+       .readpage_io_failed_hook = btree_io_failed_hook,
 
        /* optional callbacks */
-       .readpage_io_failed_hook = btree_io_failed_hook,
 };
index 0786985a8cc5292faa0b3f825788c291761b7fe7..28e81922a21c1ecead950f50cf3e685ad03c57f6 100644 (file)
@@ -2581,7 +2581,7 @@ static void end_bio_extent_readpage(struct bio *bio)
                if (likely(uptodate))
                        goto readpage_ok;
 
-               if (tree->ops && tree->ops->readpage_io_failed_hook) {
+               if (tree->ops) {
                        ret = tree->ops->readpage_io_failed_hook(page, mirror);
                        if (!ret && !bio->bi_error)
                                uptodate = 1;
index 1f8478dc9f8ec2128b3d64cf283a5de540d093d6..3e4fad4a909d110d9283f979ccb9dec9a48c607c 100644 (file)
@@ -103,6 +103,7 @@ struct extent_io_ops {
        int (*merge_bio_hook)(struct page *page, unsigned long offset,
                              size_t size, struct bio *bio,
                              unsigned long bio_flags);
+       int (*readpage_io_failed_hook)(struct page *page, int failed_mirror);
 
        /*
         * Optional hooks, called if the pointer is not NULL
@@ -110,7 +111,6 @@ struct extent_io_ops {
        int (*fill_delalloc)(struct inode *inode, struct page *locked_page,
                             u64 start, u64 end, int *page_started,
                             unsigned long *nr_written);
-       int (*readpage_io_failed_hook)(struct page *page, int failed_mirror);
 
        int (*writepage_start_hook)(struct page *page, u64 start, u64 end);
        void (*writepage_end_io_hook)(struct page *page, u64 start, u64 end,
index 3b327c8cfb166156bd12ef342fe47a467b894bbc..ca1995cfd8e99631acb97bfa9a4ec51e5e602dd1 100644 (file)
@@ -10509,6 +10509,12 @@ out_inode:
 
 }
 
+__attribute__((const))
+static int dummy_readpage_io_failed_hook(struct page *page, int failed_mirror)
+{
+       return 0;
+}
+
 static const struct inode_operations btrfs_dir_inode_operations = {
        .getattr        = btrfs_getattr,
        .lookup         = btrfs_lookup,
@@ -10551,6 +10557,7 @@ static const struct extent_io_ops btrfs_extent_io_ops = {
        .submit_bio_hook = btrfs_submit_bio_hook,
        .readpage_end_io_hook = btrfs_readpage_end_io_hook,
        .merge_bio_hook = btrfs_merge_bio_hook,
+       .readpage_io_failed_hook = dummy_readpage_io_failed_hook,
 
        /* optional callbacks */
        .fill_delalloc = run_delalloc_range,