]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Btrfs: fix how we discard outstanding ordered extents on abort
authorJosef Bacik <jbacik@fusionio.com>
Thu, 31 Jan 2013 19:30:08 +0000 (14:30 -0500)
committerJosef Bacik <jbacik@fusionio.com>
Wed, 20 Feb 2013 17:59:28 +0000 (12:59 -0500)
When we abort we've been just free'ing up all the ordered extents and
hoping for the best.  This results in lots of warnings from various places,
warnings from btrfs_destroy_inode() because it's ENOSPC accounting isn't
fixed.  It will also screw up lots of pages who have been set private but
never get cleared because the ordered extents are never allowed to be
submitted.  This patch fixes those warnings.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/disk-io.c

index 8140cb01951f14e6e4d4ecdda1b3d8961c2d5d54..259d7891d10c3f18902918230f6f99d1f71a1f23 100644 (file)
@@ -3565,35 +3565,16 @@ static void btrfs_destroy_ordered_operations(struct btrfs_root *root)
 
 static void btrfs_destroy_ordered_extents(struct btrfs_root *root)
 {
-       struct list_head splice;
        struct btrfs_ordered_extent *ordered;
-       struct inode *inode;
-
-       INIT_LIST_HEAD(&splice);
 
        spin_lock(&root->fs_info->ordered_extent_lock);
-
-       list_splice_init(&root->fs_info->ordered_extents, &splice);
-       while (!list_empty(&splice)) {
-               ordered = list_entry(splice.next, struct btrfs_ordered_extent,
-                                    root_extent_list);
-
-               list_del_init(&ordered->root_extent_list);
-               atomic_inc(&ordered->refs);
-
-               /* the inode may be getting freed (in sys_unlink path). */
-               inode = igrab(ordered->inode);
-
-               spin_unlock(&root->fs_info->ordered_extent_lock);
-               if (inode)
-                       iput(inode);
-
-               atomic_set(&ordered->refs, 1);
-               btrfs_put_ordered_extent(ordered);
-
-               spin_lock(&root->fs_info->ordered_extent_lock);
-       }
-
+       /*
+        * This will just short circuit the ordered completion stuff which will
+        * make sure the ordered extent gets properly cleaned up.
+        */
+       list_for_each_entry(ordered, &root->fs_info->ordered_extents,
+                           root_extent_list)
+               set_bit(BTRFS_ORDERED_IOERR, &ordered->flags);
        spin_unlock(&root->fs_info->ordered_extent_lock);
 }