btrfs: Remove extent_io_ops::clear_bit_hook callback
authorNikolay Borisov <nborisov@suse.com>
Thu, 1 Nov 2018 12:09:51 +0000 (14:09 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:28 +0000 (14:51 +0100)
This is the counterpart to ex-set_bit_hook (now btrfs_set_delalloc_extent),
similar to what was done before remove clear_bit_hook and rename the
function. No functional changes.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/inode.c

index 9a0e4e1c59eab8b93e4f2523e69aadb016e21da8..18ed4643cde1b55d45abdbc5b1b003d5b7901290 100644 (file)
@@ -3152,6 +3152,8 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
                             u64 new_dirid);
 void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
                               unsigned *bits);
+void btrfs_clear_delalloc_extent(struct inode *inode,
+                                struct extent_state *state, unsigned *bits);
 int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
                         size_t size, struct bio *bio,
                         unsigned long bio_flags);
index 1678adae79638845837e99e593e077c8b72a68cf..b9aadbf1a9f91bc7eeaa82ac0cf61dbef5b6c0e9 100644 (file)
@@ -404,13 +404,6 @@ static void merge_state(struct extent_io_tree *tree,
        }
 }
 
-static void clear_state_cb(struct extent_io_tree *tree,
-                          struct extent_state *state, unsigned *bits)
-{
-       if (tree->ops && tree->ops->clear_bit_hook)
-               tree->ops->clear_bit_hook(tree->private_data, state, bits);
-}
-
 static void set_state_bits(struct extent_io_tree *tree,
                           struct extent_state *state, unsigned *bits,
                           struct extent_changeset *changeset);
@@ -525,7 +518,10 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
                WARN_ON(range > tree->dirty_bytes);
                tree->dirty_bytes -= range;
        }
-       clear_state_cb(tree, state, bits);
+
+       if (tree->private_data && is_data_inode(tree->private_data))
+               btrfs_clear_delalloc_extent(tree->private_data, state, bits);
+
        ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
        BUG_ON(ret < 0);
        state->state &= ~bits_to_clear;
index b3235d46b5c3ffc2ae1b4ba9a4875c385a12f2ad..a3a3302f3625936af4e35e07922d3e066ba2cff1 100644 (file)
@@ -106,9 +106,6 @@ struct extent_io_ops {
        /*
         * Optional hooks, called if the pointer is not NULL
         */
-       void (*clear_bit_hook)(void *private_data,
-                       struct extent_state *state,
-                       unsigned *bits);
        void (*merge_extent_hook)(void *private_data,
                                  struct extent_state *new,
                                  struct extent_state *other);
index f95733fc970420304ae21498539dc8cd0baa8980..79a900d1bcdf1b0c2186b8a3509613191d0bf58f 100644 (file)
@@ -1806,14 +1806,14 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
 }
 
 /*
- * extent_io.c clear_bit_hook, see set_bit_hook for why
+ * Once a range is no longer delalloc this function ensures that proper
+ * accounting happens.
  */
-static void btrfs_clear_bit_hook(void *private_data,
-                                struct extent_state *state,
-                                unsigned *bits)
+void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
+                                struct extent_state *state, unsigned *bits)
 {
-       struct btrfs_inode *inode = BTRFS_I((struct inode *)private_data);
-       struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+       struct btrfs_inode *inode = BTRFS_I(vfs_inode);
+       struct btrfs_fs_info *fs_info = btrfs_sb(vfs_inode->i_sb);
        u64 len = state->end + 1 - state->start;
        u32 num_extents = count_max_extents(len);
 
@@ -10509,7 +10509,6 @@ static const struct extent_io_ops btrfs_extent_io_ops = {
        .readpage_io_failed_hook = btrfs_readpage_io_failed_hook,
 
        /* optional callbacks */
-       .clear_bit_hook = btrfs_clear_bit_hook,
        .merge_extent_hook = btrfs_merge_extent_hook,
        .split_extent_hook = btrfs_split_extent_hook,
 };