diff options
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r-- | fs/btrfs/free-space-cache.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 41c510b7cc11..9dbe5b548fa6 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -86,7 +86,7 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root, | |||
86 | 86 | ||
87 | mapping_set_gfp_mask(inode->i_mapping, | 87 | mapping_set_gfp_mask(inode->i_mapping, |
88 | mapping_gfp_mask(inode->i_mapping) & | 88 | mapping_gfp_mask(inode->i_mapping) & |
89 | ~(GFP_NOFS & ~__GFP_HIGHMEM)); | 89 | ~(__GFP_FS | __GFP_HIGHMEM)); |
90 | 90 | ||
91 | return inode; | 91 | return inode; |
92 | } | 92 | } |
@@ -3466,6 +3466,7 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, | |||
3466 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | 3466 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; |
3467 | int ret; | 3467 | int ret; |
3468 | struct btrfs_io_ctl io_ctl; | 3468 | struct btrfs_io_ctl io_ctl; |
3469 | bool release_metadata = true; | ||
3469 | 3470 | ||
3470 | if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | 3471 | if (!btrfs_test_opt(root, INODE_MAP_CACHE)) |
3471 | return 0; | 3472 | return 0; |
@@ -3473,11 +3474,20 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, | |||
3473 | memset(&io_ctl, 0, sizeof(io_ctl)); | 3474 | memset(&io_ctl, 0, sizeof(io_ctl)); |
3474 | ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl, | 3475 | ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl, |
3475 | trans, path, 0); | 3476 | trans, path, 0); |
3476 | if (!ret) | 3477 | if (!ret) { |
3478 | /* | ||
3479 | * At this point writepages() didn't error out, so our metadata | ||
3480 | * reservation is released when the writeback finishes, at | ||
3481 | * inode.c:btrfs_finish_ordered_io(), regardless of it finishing | ||
3482 | * with or without an error. | ||
3483 | */ | ||
3484 | release_metadata = false; | ||
3477 | ret = btrfs_wait_cache_io(root, trans, NULL, &io_ctl, path, 0); | 3485 | ret = btrfs_wait_cache_io(root, trans, NULL, &io_ctl, path, 0); |
3486 | } | ||
3478 | 3487 | ||
3479 | if (ret) { | 3488 | if (ret) { |
3480 | btrfs_delalloc_release_metadata(inode, inode->i_size); | 3489 | if (release_metadata) |
3490 | btrfs_delalloc_release_metadata(inode, inode->i_size); | ||
3481 | #ifdef DEBUG | 3491 | #ifdef DEBUG |
3482 | btrfs_err(root->fs_info, | 3492 | btrfs_err(root->fs_info, |
3483 | "failed to write free ino cache for root %llu", | 3493 | "failed to write free ino cache for root %llu", |