]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Btrfs: allow callers to specify if flushing can occur for btrfs_block_rsv_check
authorJosef Bacik <josef@redhat.com>
Fri, 19 Aug 2011 14:31:56 +0000 (10:31 -0400)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:17 +0000 (21:20 -0500)
If you run xfstest 224 it you will get lots of messages about not being able to
delete inodes and that they will be cleaned up next mount.  This is because
btrfs_block_rsv_check was not calling reserve_metadata_bytes with the ability to
flush, so if there was not enough space, it simply failed.  But in truncate and
evict case we could easily flush space to try and get enough space to do our
work, so make btrfs_block_rsv_check take a flush argument to pass down to
reserve_metadata_bytes.  Now xfstests 224 runs fine without all those
complaints.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
(cherry picked from commit 482e6dc5261406fdb921946e70b51467b0305bad)

fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/free-space-cache.c
fs/btrfs/inode.c
fs/btrfs/relocation.c
fs/btrfs/transaction.c

index d1ae92126f4997680bb6d867d95fe9805840ab85..79cfe0e062b6838966f05820a1f9d1e0b0f97a43 100644 (file)
@@ -2249,7 +2249,7 @@ int btrfs_block_rsv_add(struct btrfs_trans_handle *trans,
 int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
                          struct btrfs_root *root,
                          struct btrfs_block_rsv *block_rsv,
-                         u64 min_reserved, int min_factor);
+                         u64 min_reserved, int min_factor, int flush);
 int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
                            struct btrfs_block_rsv *dst_rsv,
                            u64 num_bytes);
index a3ecc02b1c412e27d5eb72d5df08c56cec287bcf..3d5a8d74ef0f07ae86c3d916de27b1ea03940db8 100644 (file)
@@ -3705,7 +3705,7 @@ int btrfs_block_rsv_add(struct btrfs_trans_handle *trans,
 int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
                          struct btrfs_root *root,
                          struct btrfs_block_rsv *block_rsv,
-                         u64 min_reserved, int min_factor)
+                         u64 min_reserved, int min_factor, int flush)
 {
        u64 num_bytes = 0;
        int ret = -ENOSPC;
@@ -3728,7 +3728,7 @@ int btrfs_block_rsv_check(struct btrfs_trans_handle *trans,
        if (!ret)
                return 0;
 
-       ret = reserve_metadata_bytes(trans, root, block_rsv, num_bytes, 0);
+       ret = reserve_metadata_bytes(trans, root, block_rsv, num_bytes, flush);
        if (!ret) {
                block_rsv_add_bytes(block_rsv, num_bytes, 0);
                return 0;
index ecc1a4f85d20f9037f96b29f4bf38bdcd4bb3611..b0122e19db6b407a7ac958f678c661d9c05c31c3 100644 (file)
@@ -199,7 +199,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_root *root,
        trans->block_rsv = root->orphan_block_rsv;
        ret = btrfs_block_rsv_check(trans, root,
                                    root->orphan_block_rsv,
-                                   0, 5);
+                                   0, 5, 0);
        if (ret)
                return ret;
 
index 057edcfc08915a61ceb05852d2259aceb150a0f8..eac37815e468bdd6f0a13a17525684ccf5811a23 100644 (file)
@@ -3428,10 +3428,10 @@ void btrfs_evict_inode(struct inode *inode)
         * doing the truncate.
         */
        while (1) {
-               ret = btrfs_block_rsv_check(NULL, root, rsv, min_size, 0);
+               ret = btrfs_block_rsv_check(NULL, root, rsv, min_size, 0, 1);
                if (ret) {
                        printk(KERN_WARNING "Could not get space for a "
-                              "delete, will truncate on mount\n");
+                              "delete, will truncate on mount %d\n", ret);
                        btrfs_orphan_del(NULL, inode);
                        btrfs_free_block_rsv(root, rsv);
                        goto no_delete;
@@ -6383,7 +6383,7 @@ static int btrfs_truncate(struct inode *inode)
                btrfs_add_ordered_operation(trans, root, inode);
 
        while (1) {
-               ret = btrfs_block_rsv_check(trans, root, rsv, min_size, 0);
+               ret = btrfs_block_rsv_check(trans, root, rsv, min_size, 0, 1);
                if (ret) {
                        /*
                         * This can only happen with the original transaction we
index aeaed99e9cfeacfec109331718720500973c6bdb..fd9ac66434b0a41ab834b8080f50816514611128 100644 (file)
@@ -2042,7 +2042,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
                trans->block_rsv = rc->block_rsv;
 
                ret = btrfs_block_rsv_check(trans, root, rc->block_rsv,
-                                           min_reserved, 0);
+                                           min_reserved, 0, 0);
                if (ret) {
                        BUG_ON(ret != -EAGAIN);
                        ret = btrfs_commit_transaction(trans, root);
@@ -3775,7 +3775,7 @@ restart:
                }
 
                ret = btrfs_block_rsv_check(trans, rc->extent_root,
-                                           rc->block_rsv, 0, 5);
+                                           rc->block_rsv, 0, 5, 0);
                if (ret < 0) {
                        if (ret != -EAGAIN) {
                                err = ret;
index 3e20cc8c1c069c88a605cd817d9b20d62d914ec8..a1d8c322c1ba723257e9432fb35c6cbdc1ff1067 100644 (file)
@@ -419,7 +419,7 @@ static int should_end_transaction(struct btrfs_trans_handle *trans,
 {
        int ret;
        ret = btrfs_block_rsv_check(trans, root,
-                                   &root->fs_info->global_block_rsv, 0, 5);
+                                   &root->fs_info->global_block_rsv, 0, 5, 0);
        return ret ? 1 : 0;
 }