]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/btrfs/inode.c
btrfs: Better csum error message for data csum mismatch
[mirror_ubuntu-bionic-kernel.git] / fs / btrfs / inode.c
index 893ea924e4405334c5021c2422aa815d3c9d2880..175c28a94a576a2cf573d81604e28766f907c2fa 100644 (file)
@@ -71,6 +71,7 @@ struct btrfs_dio_data {
        u64 reserve;
        u64 unsubmitted_oe_range_start;
        u64 unsubmitted_oe_range_end;
+       int overwrite;
 };
 
 static const struct inode_operations btrfs_dir_inode_operations;
@@ -1246,7 +1247,6 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
        struct btrfs_root *root = BTRFS_I(inode)->root;
-       struct btrfs_trans_handle *trans;
        struct extent_buffer *leaf;
        struct btrfs_path *path;
        struct btrfs_file_extent_item *fi;
@@ -1282,30 +1282,10 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 
        nolock = btrfs_is_free_space_inode(inode);
 
-       if (nolock)
-               trans = btrfs_join_transaction_nolock(root);
-       else
-               trans = btrfs_join_transaction(root);
-
-       if (IS_ERR(trans)) {
-               extent_clear_unlock_delalloc(inode, start, end, end,
-                                            locked_page,
-                                            EXTENT_LOCKED | EXTENT_DELALLOC |
-                                            EXTENT_DO_ACCOUNTING |
-                                            EXTENT_DEFRAG, PAGE_UNLOCK |
-                                            PAGE_CLEAR_DIRTY |
-                                            PAGE_SET_WRITEBACK |
-                                            PAGE_END_WRITEBACK);
-               btrfs_free_path(path);
-               return PTR_ERR(trans);
-       }
-
-       trans->block_rsv = &fs_info->delalloc_block_rsv;
-
        cow_start = (u64)-1;
        cur_offset = start;
        while (1) {
-               ret = btrfs_lookup_file_extent(trans, root, path, ino,
+               ret = btrfs_lookup_file_extent(NULL, root, path, ino,
                                               cur_offset, 0);
                if (ret < 0)
                        goto error;
@@ -1378,7 +1358,7 @@ next_slot:
                                goto out_check;
                        if (btrfs_extent_readonly(fs_info, disk_bytenr))
                                goto out_check;
-                       if (btrfs_cross_ref_exist(trans, root, ino,
+                       if (btrfs_cross_ref_exist(root, ino,
                                                  found_key.offset -
                                                  extent_offset, disk_bytenr))
                                goto out_check;
@@ -1530,10 +1510,6 @@ out_check:
        }
 
 error:
-       err = btrfs_end_transaction(trans);
-       if (!ret)
-               ret = err;
-
        if (ret && cur_offset < end)
                extent_clear_unlock_delalloc(inode, cur_offset, end, end,
                                             locked_page, EXTENT_LOCKED |
@@ -2182,8 +2158,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
        ins.offset = disk_num_bytes;
        ins.type = BTRFS_EXTENT_ITEM_KEY;
        ret = btrfs_alloc_reserved_file_extent(trans, root->root_key.objectid,
-                                              btrfs_ino(BTRFS_I(inode)), file_pos,
-                                              ram_bytes, &ins);
+                       btrfs_ino(BTRFS_I(inode)), file_pos, ram_bytes, &ins);
        /*
         * Release the reserved range from inode dirty range map, as it is
         * already moved into delayed_ref_head
@@ -3111,9 +3086,8 @@ static int __readpage_endio_check(struct inode *inode,
        kunmap_atomic(kaddr);
        return 0;
 zeroit:
-       btrfs_warn_rl(BTRFS_I(inode)->root->fs_info,
-               "csum failed ino %llu off %llu csum %u expected csum %u",
-                          btrfs_ino(BTRFS_I(inode)), start, csum, csum_expected);
+       btrfs_print_data_csum_error(inode, start, csum, csum_expected,
+                                   io_bio->mirror_num);
        memset(kaddr + pgoff, 1, len);
        flush_dcache_page(page);
        kunmap_atomic(kaddr);
@@ -3314,7 +3288,8 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
 
        /* insert an orphan item to track this unlinked/truncated file */
        if (insert >= 1) {
-               ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(BTRFS_I(inode)));
+               ret = btrfs_insert_orphan_item(trans, root,
+                               btrfs_ino(BTRFS_I(inode)));
                if (ret) {
                        atomic_dec(&root->orphan_inodes);
                        if (reserve) {
@@ -3799,7 +3774,7 @@ cache_acl:
         * any xattrs or acls
         */
        maybe_acls = acls_after_inode_item(leaf, path->slots[0],
-                                          btrfs_ino(BTRFS_I(inode)), &first_xattr_slot);
+                       btrfs_ino(BTRFS_I(inode)), &first_xattr_slot);
        if (first_xattr_slot != -1) {
                path->slots[0] = first_xattr_slot;
                ret = btrfs_load_inode_props(inode, path);
@@ -3981,7 +3956,8 @@ noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
  */
 static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
                                struct btrfs_root *root,
-                               struct inode *dir, struct inode *inode,
+                               struct btrfs_inode *dir,
+                               struct btrfs_inode *inode,
                                const char *name, int name_len)
 {
        struct btrfs_fs_info *fs_info = root->fs_info;
@@ -3991,8 +3967,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
        struct btrfs_dir_item *di;
        struct btrfs_key key;
        u64 index;
-       u64 ino = btrfs_ino(BTRFS_I(inode));
-       u64 dir_ino = btrfs_ino(BTRFS_I(dir));
+       u64 ino = btrfs_ino(inode);
+       u64 dir_ino = btrfs_ino(dir);
 
        path = btrfs_alloc_path();
        if (!path) {
@@ -4028,10 +4004,10 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
         * that we delay to delete it, and just do this deletion when
         * we update the inode item.
         */
-       if (BTRFS_I(inode)->dir_index) {
+       if (inode->dir_index) {
                ret = btrfs_delayed_delete_inode_ref(inode);
                if (!ret) {
-                       index = BTRFS_I(inode)->dir_index;
+                       index = inode->dir_index;
                        goto skip_backref;
                }
        }
@@ -4052,15 +4028,15 @@ skip_backref:
                goto err;
        }
 
-       ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len,
-                                        inode, dir_ino);
+       ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, inode,
+                       dir_ino);
        if (ret != 0 && ret != -ENOENT) {
                btrfs_abort_transaction(trans, ret);
                goto err;
        }
 
-       ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len,
-                                          dir, index);
+       ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, dir,
+                       index);
        if (ret == -ENOENT)
                ret = 0;
        else if (ret)
@@ -4070,26 +4046,27 @@ err:
        if (ret)
                goto out;
 
-       btrfs_i_size_write(dir, dir->i_size - name_len * 2);
-       inode_inc_iversion(inode);
-       inode_inc_iversion(dir);
-       inode->i_ctime = dir->i_mtime =
-               dir->i_ctime = current_time(inode);
-       ret = btrfs_update_inode(trans, root, dir);
+       btrfs_i_size_write(&dir->vfs_inode,
+                       dir->vfs_inode.i_size - name_len * 2);
+       inode_inc_iversion(&inode->vfs_inode);
+       inode_inc_iversion(&dir->vfs_inode);
+       inode->vfs_inode.i_ctime = dir->vfs_inode.i_mtime =
+               dir->vfs_inode.i_ctime = current_time(&inode->vfs_inode);
+       ret = btrfs_update_inode(trans, root, &dir->vfs_inode);
 out:
        return ret;
 }
 
 int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
                       struct btrfs_root *root,
-                      struct inode *dir, struct inode *inode,
+                      struct btrfs_inode *dir, struct btrfs_inode *inode,
                       const char *name, int name_len)
 {
        int ret;
        ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len);
        if (!ret) {
-               drop_nlink(inode);
-               ret = btrfs_update_inode(trans, root, inode);
+               drop_nlink(&inode->vfs_inode);
+               ret = btrfs_update_inode(trans, root, &inode->vfs_inode);
        }
        return ret;
 }
@@ -4127,10 +4104,12 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
        if (IS_ERR(trans))
                return PTR_ERR(trans);
 
-       btrfs_record_unlink_dir(trans, dir, d_inode(dentry), 0);
+       btrfs_record_unlink_dir(trans, BTRFS_I(dir), BTRFS_I(d_inode(dentry)),
+                       0);
 
-       ret = btrfs_unlink_inode(trans, root, dir, d_inode(dentry),
-                                dentry->d_name.name, dentry->d_name.len);
+       ret = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
+                       BTRFS_I(d_inode(dentry)), dentry->d_name.name,
+                       dentry->d_name.len);
        if (ret)
                goto out;
 
@@ -4210,7 +4189,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
        }
        btrfs_release_path(path);
 
-       ret = btrfs_delete_delayed_dir_index(trans, fs_info, dir, index);
+       ret = btrfs_delete_delayed_dir_index(trans, fs_info, BTRFS_I(dir), index);
        if (ret) {
                btrfs_abort_transaction(trans, ret);
                goto out;
@@ -4259,8 +4238,9 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
        last_unlink_trans = BTRFS_I(inode)->last_unlink_trans;
 
        /* now the directory is empty */
-       err = btrfs_unlink_inode(trans, root, dir, d_inode(dentry),
-                                dentry->d_name.name, dentry->d_name.len);
+       err = btrfs_unlink_inode(trans, root, BTRFS_I(dir),
+                       BTRFS_I(d_inode(dentry)), dentry->d_name.name,
+                       dentry->d_name.len);
        if (!err) {
                btrfs_i_size_write(inode, 0);
                /*
@@ -4425,7 +4405,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
         * items.
         */
        if (min_type == 0 && root == BTRFS_I(inode)->root)
-               btrfs_kill_delayed_inode_items(inode);
+               btrfs_kill_delayed_inode_items(BTRFS_I(inode));
 
        key.objectid = ino;
        key.offset = (u64)-1;
@@ -4690,6 +4670,13 @@ error:
 
        btrfs_free_path(path);
 
+       if (err == 0) {
+               /* only inline file may have last_size != new_size */
+               if (new_size >= fs_info->sectorsize ||
+                   new_size > fs_info->max_inline)
+                       ASSERT(last_size == new_size);
+       }
+
        if (be_nice && bytes_deleted > SZ_32M) {
                unsigned long updates = trans->delayed_ref_updates;
                if (updates) {
@@ -4858,8 +4845,8 @@ static int maybe_insert_hole(struct btrfs_root *root, struct inode *inode,
                return ret;
        }
 
-       ret = btrfs_insert_file_extent(trans, root, btrfs_ino(BTRFS_I(inode)), offset,
-                                      0, 0, len, 0, len, 0, 0, 0);
+       ret = btrfs_insert_file_extent(trans, root, btrfs_ino(BTRFS_I(inode)),
+                       offset, 0, 0, len, 0, len, 0, 0, 0);
        if (ret)
                btrfs_abort_transaction(trans, ret);
        else
@@ -5075,6 +5062,13 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
                if (ret && inode->i_nlink) {
                        int err;
 
+                       /* To get a stable disk_i_size */
+                       err = btrfs_wait_ordered_range(inode, 0, (u64)-1);
+                       if (err) {
+                               btrfs_orphan_del(NULL, inode);
+                               return err;
+                       }
+
                        /*
                         * failed to truncate, disk_i_size is only adjusted down
                         * as we remove extents, so it should represent the true
@@ -5270,7 +5264,7 @@ void btrfs_evict_inode(struct inode *inode)
                goto no_delete;
        }
 
-       ret = btrfs_commit_inode_delayed_inode(inode);
+       ret = btrfs_commit_inode_delayed_inode(BTRFS_I(inode));
        if (ret) {
                btrfs_orphan_del(NULL, inode);
                goto no_delete;
@@ -5395,7 +5389,7 @@ void btrfs_evict_inode(struct inode *inode)
        btrfs_end_transaction(trans);
        btrfs_btree_balance_dirty(fs_info);
 no_delete:
-       btrfs_remove_delayed_node(inode);
+       btrfs_remove_delayed_node(BTRFS_I(inode));
        clear_inode(inode);
 }
 
@@ -5417,8 +5411,8 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
        if (!path)
                return -ENOMEM;
 
-       di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(BTRFS_I(dir)), name,
-                                   namelen, 0);
+       di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(BTRFS_I(dir)),
+                       name, namelen, 0);
        if (IS_ERR(di))
                ret = PTR_ERR(di);
 
@@ -6103,7 +6097,7 @@ int btrfs_set_inode_index(struct inode *dir, u64 *index)
        int ret = 0;
 
        if (BTRFS_I(dir)->index_cnt == (u64)-1) {
-               ret = btrfs_inode_delayed_dir_index_count(dir);
+               ret = btrfs_inode_delayed_dir_index_count(BTRFS_I(dir));
                if (ret) {
                        ret = btrfs_set_inode_index_count(dir);
                        if (ret)
@@ -6282,7 +6276,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
        if (ret)
                btrfs_err(fs_info,
                          "error inheriting props for ino %llu (root %llu): %d",
-                         btrfs_ino(BTRFS_I(inode)), root->root_key.objectid, ret);
+                       btrfs_ino(BTRFS_I(inode)), root->root_key.objectid, ret);
 
        return inode;
 
@@ -6415,8 +6409,8 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
                goto out_unlock;
 
        inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
-                               dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
-                               mode, &index);
+                       dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
+                       mode, &index);
        if (IS_ERR(inode)) {
                err = PTR_ERR(inode);
                goto out_unlock;
@@ -6487,8 +6481,8 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
                goto out_unlock;
 
        inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
-                               dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
-                               mode, &index);
+                       dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
+                       mode, &index);
        if (IS_ERR(inode)) {
                err = PTR_ERR(inode);
                goto out_unlock;
@@ -6597,7 +6591,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
                                goto fail;
                }
                d_instantiate(dentry, inode);
-               btrfs_log_new_name(trans, inode, NULL, parent);
+               btrfs_log_new_name(trans, BTRFS_I(inode), NULL, parent);
        }
 
        btrfs_balance_delayed_items(fs_info);
@@ -6637,8 +6631,8 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
                goto out_fail;
 
        inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
-                               dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
-                               S_IFDIR | mode, &index);
+                       dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
+                       S_IFDIR | mode, &index);
        if (IS_ERR(inode)) {
                err = PTR_ERR(inode);
                goto out_fail;
@@ -7270,7 +7264,6 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
                              u64 *ram_bytes)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-       struct btrfs_trans_handle *trans;
        struct btrfs_path *path;
        int ret;
        struct extent_buffer *leaf;
@@ -7290,8 +7283,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
        if (!path)
                return -ENOMEM;
 
-       ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(BTRFS_I(inode)),
-                                      offset, 0);
+       ret = btrfs_lookup_file_extent(NULL, root, path,
+                       btrfs_ino(BTRFS_I(inode)), offset, 0);
        if (ret < 0)
                goto out;
 
@@ -7373,15 +7366,9 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
         * look for other files referencing this extent, if we
         * find any we must cow
         */
-       trans = btrfs_join_transaction(root);
-       if (IS_ERR(trans)) {
-               ret = 0;
-               goto out;
-       }
 
-       ret = btrfs_cross_ref_exist(trans, root, btrfs_ino(BTRFS_I(inode)),
+       ret = btrfs_cross_ref_exist(root, btrfs_ino(BTRFS_I(inode)),
                                    key.offset - backref_offset, disk_bytenr);
-       btrfs_end_transaction(trans);
        if (ret) {
                ret = 0;
                goto out;
@@ -7790,7 +7777,7 @@ unlock:
                 * Need to update the i_size under the extent lock so buffered
                 * readers will get the updated i_size when we unlock.
                 */
-               if (start + len > i_size_read(inode))
+               if (!dio_data->overwrite && start + len > i_size_read(inode))
                        i_size_write(inode, start + len);
 
                adjust_dio_outstanding_extents(inode, dio_data, len);
@@ -8240,7 +8227,8 @@ static void btrfs_end_dio_bio(struct bio *bio)
        if (err)
                btrfs_warn(BTRFS_I(dip->inode)->root->fs_info,
                           "direct IO failed ino %llu rw %d,%u sector %#Lx len %u err no %d",
-                          btrfs_ino(BTRFS_I(dip->inode)), bio_op(bio), bio->bi_opf,
+                          btrfs_ino(BTRFS_I(dip->inode)), bio_op(bio),
+                          bio->bi_opf,
                           (unsigned long long)bio->bi_iter.bi_sector,
                           bio->bi_iter.bi_size, err);
 
@@ -8665,6 +8653,7 @@ static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
                 * not unlock the i_mutex at this case.
                 */
                if (offset + count <= inode->i_size) {
+                       dio_data.overwrite = 1;
                        inode_unlock(inode);
                        relock = true;
                }
@@ -9016,7 +9005,7 @@ again:
         * we can't set the delalloc bits if there are pending ordered
         * extents.  Drop our locks and wait for them to finish
         */
-       ordered = btrfs_lookup_ordered_range(inode, page_start, page_end);
+       ordered = btrfs_lookup_ordered_range(inode, page_start, PAGE_SIZE);
        if (ordered) {
                unlock_extent_cached(io_tree, page_start, page_end,
                                     &cached_state, GFP_NOFS);
@@ -9040,11 +9029,11 @@ again:
        }
 
        /*
-        * XXX - page_mkwrite gets called every time the page is dirtied, even
-        * if it was already dirty, so for space accounting reasons we need to
-        * clear any delalloc bits for the range we are fixing to save.  There
-        * is probably a better way to do this, but for now keep consistent with
-        * prepare_pages in the normal write path.
+        * page_mkwrite gets called when the page is firstly dirtied after it's
+        * faulted in, but write(2) could also dirty a page and set delalloc
+        * bits, thus in this case for space account reason, we still need to
+        * clear any delalloc bits within this page range since we have to
+        * reserve data&meta space before lock_page() (see above comments).
         */
        clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start, end,
                          EXTENT_DIRTY | EXTENT_DELALLOC |
@@ -9555,7 +9544,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
                                             new_dentry->d_name.name,
                                             new_dentry->d_name.len,
                                             old_ino,
-                                            btrfs_ino(BTRFS_I(new_dir)), old_idx);
+                                            btrfs_ino(BTRFS_I(new_dir)),
+                                            old_idx);
                if (ret)
                        goto out_fail;
        }
@@ -9571,7 +9561,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
                                             old_dentry->d_name.name,
                                             old_dentry->d_name.len,
                                             new_ino,
-                                            btrfs_ino(BTRFS_I(old_dir)), new_idx);
+                                            btrfs_ino(BTRFS_I(old_dir)),
+                                            new_idx);
                if (ret)
                        goto out_fail;
        }
@@ -9587,8 +9578,10 @@ static int btrfs_rename_exchange(struct inode *old_dir,
        new_inode->i_ctime = ctime;
 
        if (old_dentry->d_parent != new_dentry->d_parent) {
-               btrfs_record_unlink_dir(trans, old_dir, old_inode, 1);
-               btrfs_record_unlink_dir(trans, new_dir, new_inode, 1);
+               btrfs_record_unlink_dir(trans, BTRFS_I(old_dir),
+                               BTRFS_I(old_inode), 1);
+               btrfs_record_unlink_dir(trans, BTRFS_I(new_dir),
+                               BTRFS_I(new_inode), 1);
        }
 
        /* src is a subvolume */
@@ -9599,8 +9592,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
                                          old_dentry->d_name.name,
                                          old_dentry->d_name.len);
        } else { /* src is an inode */
-               ret = __btrfs_unlink_inode(trans, root, old_dir,
-                                          old_dentry->d_inode,
+               ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir),
+                                          BTRFS_I(old_dentry->d_inode),
                                           old_dentry->d_name.name,
                                           old_dentry->d_name.len);
                if (!ret)
@@ -9619,8 +9612,8 @@ static int btrfs_rename_exchange(struct inode *old_dir,
                                          new_dentry->d_name.name,
                                          new_dentry->d_name.len);
        } else { /* dest is an inode */
-               ret = __btrfs_unlink_inode(trans, dest, new_dir,
-                                          new_dentry->d_inode,
+               ret = __btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir),
+                                          BTRFS_I(new_dentry->d_inode),
                                           new_dentry->d_name.name,
                                           new_dentry->d_name.len);
                if (!ret)
@@ -9654,13 +9647,15 @@ static int btrfs_rename_exchange(struct inode *old_dir,
 
        if (root_log_pinned) {
                parent = new_dentry->d_parent;
-               btrfs_log_new_name(trans, old_inode, old_dir, parent);
+               btrfs_log_new_name(trans, BTRFS_I(old_inode), BTRFS_I(old_dir),
+                               parent);
                btrfs_end_log_trans(root);
                root_log_pinned = false;
        }
        if (dest_log_pinned) {
                parent = old_dentry->d_parent;
-               btrfs_log_new_name(trans, new_inode, new_dir, parent);
+               btrfs_log_new_name(trans, BTRFS_I(new_inode), BTRFS_I(new_dir),
+                               parent);
                btrfs_end_log_trans(dest);
                dest_log_pinned = false;
        }
@@ -9677,11 +9672,11 @@ out_fail:
         * allow the tasks to sync it.
         */
        if (ret && (root_log_pinned || dest_log_pinned)) {
-               if (btrfs_inode_in_log(old_dir, fs_info->generation) ||
-                   btrfs_inode_in_log(new_dir, fs_info->generation) ||
-                   btrfs_inode_in_log(old_inode, fs_info->generation) ||
+               if (btrfs_inode_in_log(BTRFS_I(old_dir), fs_info->generation) ||
+                   btrfs_inode_in_log(BTRFS_I(new_dir), fs_info->generation) ||
+                   btrfs_inode_in_log(BTRFS_I(old_inode), fs_info->generation) ||
                    (new_inode &&
-                    btrfs_inode_in_log(new_inode, fs_info->generation)))
+                    btrfs_inode_in_log(BTRFS_I(new_inode), fs_info->generation)))
                        btrfs_set_log_full_commit(fs_info, trans);
 
                if (root_log_pinned) {
@@ -9867,7 +9862,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        old_inode->i_ctime = current_time(old_dir);
 
        if (old_dentry->d_parent != new_dentry->d_parent)
-               btrfs_record_unlink_dir(trans, old_dir, old_inode, 1);
+               btrfs_record_unlink_dir(trans, BTRFS_I(old_dir),
+                               BTRFS_I(old_inode), 1);
 
        if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) {
                root_objectid = BTRFS_I(old_inode)->root->root_key.objectid;
@@ -9875,8 +9871,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                                        old_dentry->d_name.name,
                                        old_dentry->d_name.len);
        } else {
-               ret = __btrfs_unlink_inode(trans, root, old_dir,
-                                       d_inode(old_dentry),
+               ret = __btrfs_unlink_inode(trans, root, BTRFS_I(old_dir),
+                                       BTRFS_I(d_inode(old_dentry)),
                                        old_dentry->d_name.name,
                                        old_dentry->d_name.len);
                if (!ret)
@@ -9899,8 +9895,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                                                new_dentry->d_name.len);
                        BUG_ON(new_inode->i_nlink == 0);
                } else {
-                       ret = btrfs_unlink_inode(trans, dest, new_dir,
-                                                d_inode(new_dentry),
+                       ret = btrfs_unlink_inode(trans, dest, BTRFS_I(new_dir),
+                                                BTRFS_I(d_inode(new_dentry)),
                                                 new_dentry->d_name.name,
                                                 new_dentry->d_name.len);
                }
@@ -9926,7 +9922,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        if (log_pinned) {
                struct dentry *parent = new_dentry->d_parent;
 
-               btrfs_log_new_name(trans, old_inode, old_dir, parent);
+               btrfs_log_new_name(trans, BTRFS_I(old_inode), BTRFS_I(old_dir),
+                               parent);
                btrfs_end_log_trans(root);
                log_pinned = false;
        }
@@ -9953,11 +9950,11 @@ out_fail:
         * allow the tasks to sync it.
         */
        if (ret && log_pinned) {
-               if (btrfs_inode_in_log(old_dir, fs_info->generation) ||
-                   btrfs_inode_in_log(new_dir, fs_info->generation) ||
-                   btrfs_inode_in_log(old_inode, fs_info->generation) ||
+               if (btrfs_inode_in_log(BTRFS_I(old_dir), fs_info->generation) ||
+                   btrfs_inode_in_log(BTRFS_I(new_dir), fs_info->generation) ||
+                   btrfs_inode_in_log(BTRFS_I(old_inode), fs_info->generation) ||
                    (new_inode &&
-                    btrfs_inode_in_log(new_inode, fs_info->generation)))
+                    btrfs_inode_in_log(BTRFS_I(new_inode), fs_info->generation)))
                        btrfs_set_log_full_commit(fs_info, trans);
 
                btrfs_end_log_trans(root);
@@ -10221,8 +10218,8 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
                goto out_unlock;
 
        inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
-                               dentry->d_name.len, btrfs_ino(BTRFS_I(dir)), objectid,
-                               S_IFLNK|S_IRWXUGO, &index);
+                               dentry->d_name.len, btrfs_ino(BTRFS_I(dir)),
+                               objectid, S_IFLNK|S_IRWXUGO, &index);
        if (IS_ERR(inode)) {
                err = PTR_ERR(inode);
                goto out_unlock;
@@ -10501,7 +10498,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
                goto out;
 
        inode = btrfs_new_inode(trans, root, dir, NULL, 0,
-                               btrfs_ino(BTRFS_I(dir)), objectid, mode, &index);
+                       btrfs_ino(BTRFS_I(dir)), objectid, mode, &index);
        if (IS_ERR(inode)) {
                ret = PTR_ERR(inode);
                inode = NULL;