btrfs: Make lock_and_cleanup_extent_if_need take btrfs_inode
authorNikolay Borisov <n.borisov.lkml@gmail.com>
Mon, 20 Feb 2017 11:50:51 +0000 (13:50 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 28 Feb 2017 10:30:09 +0000 (11:30 +0100)
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c

index 1d09ecc..dff7ec1 100644 (file)
@@ -1415,13 +1415,13 @@ fail:
  * the other < 0 number - Something wrong happens
  */
 static noinline int
-lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages,
+lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
                                size_t num_pages, loff_t pos,
                                size_t write_bytes,
                                u64 *lockstart, u64 *lockend,
                                struct extent_state **cached_state)
 {
-       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 start_pos;
        u64 last_pos;
        int i;
@@ -1432,30 +1432,30 @@ lock_and_cleanup_extent_if_need(struct inode *inode, struct page **pages,
                + round_up(pos + write_bytes - start_pos,
                           fs_info->sectorsize) - 1;
 
-       if (start_pos < inode->i_size) {
+       if (start_pos < inode->vfs_inode.i_size) {
                struct btrfs_ordered_extent *ordered;
-               lock_extent_bits(&BTRFS_I(inode)->io_tree,
-                                start_pos, last_pos, cached_state);
-               ordered = btrfs_lookup_ordered_range(BTRFS_I(inode), start_pos,
+               lock_extent_bits(&inode->io_tree, start_pos, last_pos,
+                               cached_state);
+               ordered = btrfs_lookup_ordered_range(inode, start_pos,
                                                     last_pos - start_pos + 1);
                if (ordered &&
                    ordered->file_offset + ordered->len > start_pos &&
                    ordered->file_offset <= last_pos) {
-                       unlock_extent_cached(&BTRFS_I(inode)->io_tree,
-                                            start_pos, last_pos,
-                                            cached_state, GFP_NOFS);
+                       unlock_extent_cached(&inode->io_tree, start_pos,
+                                       last_pos, cached_state, GFP_NOFS);
                        for (i = 0; i < num_pages; i++) {
                                unlock_page(pages[i]);
                                put_page(pages[i]);
                        }
-                       btrfs_start_ordered_extent(inode, ordered, 1);
+                       btrfs_start_ordered_extent(&inode->vfs_inode,
+                                       ordered, 1);
                        btrfs_put_ordered_extent(ordered);
                        return -EAGAIN;
                }
                if (ordered)
                        btrfs_put_ordered_extent(ordered);
 
-               clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos,
+               clear_extent_bit(&inode->io_tree, start_pos,
                                  last_pos, EXTENT_DIRTY | EXTENT_DELALLOC |
                                  EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
                                  0, 0, cached_state, GFP_NOFS);
@@ -1626,9 +1626,9 @@ again:
                if (ret)
                        break;
 
-               ret = lock_and_cleanup_extent_if_need(inode, pages, num_pages,
-                                               pos, write_bytes, &lockstart,
-                                               &lockend, &cached_state);
+               ret = lock_and_cleanup_extent_if_need(BTRFS_I(inode), pages,
+                               num_pages, pos, write_bytes, &lockstart,
+                               &lockend, &cached_state);
                if (ret < 0) {
                        if (ret == -EAGAIN)
                                goto again;