btrfs: Make btrfs_clear_bit_hook take btrfs_inode
authorNikolay Borisov <nborisov@suse.com>
Mon, 20 Feb 2017 11:51:03 +0000 (13:51 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 28 Feb 2017 10:30:11 +0000 (11:30 +0100)
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/inode.c

index ded750eb90c4769b582fa8f118fbbfd490572801..d21082962565670bc6f6def97b72779ae4da8118 100644 (file)
@@ -428,7 +428,8 @@ 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->mapping->host, state, bits);
+               tree->ops->clear_bit_hook(BTRFS_I(tree->mapping->host),
+                               state, bits);
 }
 
 static void set_state_bits(struct extent_io_tree *tree,
index 345fc33f843d80b62e5e9633af2d29ad503e9205..cd8b3dd6948df19e4af7de0dd2299f28a4e1cf8d 100644 (file)
@@ -84,6 +84,7 @@ extern void le_bitmap_clear(u8 *map, unsigned int start, int len);
 
 struct extent_state;
 struct btrfs_root;
+struct btrfs_inode;
 struct btrfs_io_bio;
 struct io_failure_record;
 
@@ -107,8 +108,9 @@ struct extent_io_ops {
                                      struct extent_state *state, int uptodate);
        void (*set_bit_hook)(struct inode *inode, struct extent_state *state,
                             unsigned *bits);
-       void (*clear_bit_hook)(struct inode *inode, struct extent_state *state,
-                              unsigned *bits);
+       void (*clear_bit_hook)(struct btrfs_inode *inode,
+                       struct extent_state *state,
+                       unsigned *bits);
        void (*merge_extent_hook)(struct inode *inode,
                                  struct extent_state *new,
                                  struct extent_state *other);
index 0b46542010fb15eeb4953a77702768f8104b5020..0600d55bb173b3dea3750886a24024a1140a18dd 100644 (file)
@@ -1703,18 +1703,18 @@ static void btrfs_set_bit_hook(struct inode *inode,
 /*
  * extent_io.c clear_bit_hook, see set_bit_hook for why
  */
-static void btrfs_clear_bit_hook(struct inode *inode,
+static void btrfs_clear_bit_hook(struct btrfs_inode *inode,
                                 struct extent_state *state,
                                 unsigned *bits)
 {
-       struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+       struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
        u64 len = state->end + 1 - state->start;
        u32 num_extents = count_max_extents(len);
 
-       spin_lock(&BTRFS_I(inode)->lock);
+       spin_lock(&inode->lock);
        if ((state->state & EXTENT_DEFRAG) && (*bits & EXTENT_DEFRAG))
-               BTRFS_I(inode)->defrag_bytes -= len;
-       spin_unlock(&BTRFS_I(inode)->lock);
+               inode->defrag_bytes -= len;
+       spin_unlock(&inode->lock);
 
        /*
         * set_bit and clear bit hooks normally require _irqsave/restore
@@ -1722,15 +1722,15 @@ static void btrfs_clear_bit_hook(struct inode *inode,
         * bit, which is only set or cleared with irqs on
         */
        if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) {
-               struct btrfs_root *root = BTRFS_I(inode)->root;
-               bool do_list = !btrfs_is_free_space_inode(BTRFS_I(inode));
+               struct btrfs_root *root = inode->root;
+               bool do_list = !btrfs_is_free_space_inode(inode);
 
                if (*bits & EXTENT_FIRST_DELALLOC) {
                        *bits &= ~EXTENT_FIRST_DELALLOC;
                } else if (!(*bits & EXTENT_DO_ACCOUNTING)) {
-                       spin_lock(&BTRFS_I(inode)->lock);
-                       BTRFS_I(inode)->outstanding_extents -= num_extents;
-                       spin_unlock(&BTRFS_I(inode)->lock);
+                       spin_lock(&inode->lock);
+                       inode->outstanding_extents -= num_extents;
+                       spin_unlock(&inode->lock);
                }
 
                /*
@@ -1740,7 +1740,7 @@ static void btrfs_clear_bit_hook(struct inode *inode,
                 */
                if (*bits & EXTENT_DO_ACCOUNTING &&
                    root != fs_info->tree_root)
-                       btrfs_delalloc_release_metadata(BTRFS_I(inode), len);
+                       btrfs_delalloc_release_metadata(inode, len);
 
                /* For sanity tests. */
                if (btrfs_is_testing(fs_info))
@@ -1750,18 +1750,19 @@ static void btrfs_clear_bit_hook(struct inode *inode,
                    && do_list && !(state->state & EXTENT_NORESERVE)
                    && (*bits & (EXTENT_DO_ACCOUNTING |
                    EXTENT_CLEAR_DATA_RESV)))
-                       btrfs_free_reserved_data_space_noquota(inode,
+                       btrfs_free_reserved_data_space_noquota(
+                                       &inode->vfs_inode,
                                        state->start, len);
 
                __percpu_counter_add(&fs_info->delalloc_bytes, -len,
                                     fs_info->delalloc_batch);
-               spin_lock(&BTRFS_I(inode)->lock);
-               BTRFS_I(inode)->delalloc_bytes -= len;
-               if (do_list && BTRFS_I(inode)->delalloc_bytes == 0 &&
+               spin_lock(&inode->lock);
+               inode->delalloc_bytes -= len;
+               if (do_list && inode->delalloc_bytes == 0 &&
                    test_bit(BTRFS_INODE_IN_DELALLOC_LIST,
-                            &BTRFS_I(inode)->runtime_flags))
-                       btrfs_del_delalloc_inode(root, inode);
-               spin_unlock(&BTRFS_I(inode)->lock);
+                               &inode->runtime_flags))
+                       btrfs_del_delalloc_inode(root, &inode->vfs_inode);
+               spin_unlock(&inode->lock);
        }
 }