]> git.hungrycats.org Git - linux/commitdiff
Revert "Btrfs: fix stale directory entries after fsync log replay"
authorZygo Blaxell <zblaxell@serenity.furryterror.org>
Mon, 27 Jul 2015 17:19:10 +0000 (13:19 -0400)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Mon, 27 Jul 2015 17:19:10 +0000 (13:19 -0400)
This reverts commit 21204104437a8568371a5b152f3f28b672238e62.

fs/btrfs/tree-log.c

index 7054a4d86967f1c7fd9017985d57c15e6eedf6d6..ac90336a3a893f8dd9a5f28cdad4ed347077ab44 100644 (file)
@@ -1740,13 +1740,12 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
                                        struct extent_buffer *eb, int slot,
                                        struct btrfs_key *key)
 {
-       int ret = 0;
+       int ret;
        u32 item_size = btrfs_item_size_nr(eb, slot);
        struct btrfs_dir_item *di;
        int name_len;
        unsigned long ptr;
        unsigned long ptr_end;
-       struct btrfs_path *fixup_path = NULL;
 
        ptr = btrfs_item_ptr_offset(eb, slot);
        ptr_end = ptr + item_size;
@@ -1760,56 +1759,8 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
                        return ret;
                ptr = (unsigned long)(di + 1);
                ptr += name_len;
-
-               /*
-                * If this entry refers to a non-directory (directories can not
-                * have a link count > 1) and it was added in the transaction
-                * that was not committed, make sure we fixup the link count of
-                * the inode it the entry points to. Otherwise something like
-                * the following would result in a directory pointing to an
-                * inode with a wrong link that does not account for this dir
-                * entry:
-                *
-                * mkdir testdir
-                * touch testdir/foo
-                * touch testdir/bar
-                * sync
-                *
-                * ln testdir/bar testdir/bar_link
-                * ln testdir/foo testdir/foo_link
-                * xfs_io -c "fsync" testdir/bar
-                *
-                * <power failure>
-                *
-                * mount fs, log replay happens
-                *
-                * File foo would remain with a link count of 1 when it has two
-                * entries pointing to it in the directory testdir. This would
-                * make it impossible to ever delete the parent directory has
-                * it would result in stale dentries that can never be deleted.
-                */
-               if (btrfs_dir_type(eb, di) != BTRFS_FT_DIR &&
-                   btrfs_dir_transid(eb, di) >
-                   root->fs_info->last_trans_committed) {
-                       struct btrfs_key di_key;
-
-                       if (!fixup_path) {
-                               fixup_path = btrfs_alloc_path();
-                               if (!fixup_path) {
-                                       ret = -ENOMEM;
-                                       break;
-                               }
-                       }
-
-                       btrfs_dir_item_key_to_cpu(eb, di, &di_key);
-                       ret = link_to_fixup_dir(trans, root, fixup_path,
-                                               di_key.objectid);
-                       if (ret)
-                               break;
-               }
        }
-       btrfs_free_path(fixup_path);
-       return ret;
+       return 0;
 }
 
 /*