[PATCH] btrfs: remove unnecessary btrfs_delalloc_release_metadata() call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In __btrfs_write_out_cache(), we don't call btrfs_delalloc_reserve_metadata()
or btrfs_delalloc_reserve_space() to reserve metadata space, so we also should
not call btrfs_delalloc_release_metadata(), in which BTRFS_I(inode)->outstanding_extents
will be decreased, then WARN_ON(BTRFS_I(inode)->outstanding_extents) in
btrfs_destroy_inode() will be triggered.

To be honest, I do not see this WARNING in real, but I think we should fix it.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@xxxxxxxxxxxxxx>
---
 fs/btrfs/free-space-cache.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 8f835bf..ababf56 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -3512,7 +3512,6 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
 	struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;
 	int ret;
 	struct btrfs_io_ctl io_ctl;
-	bool release_metadata = true;
 
 	if (!btrfs_test_opt(root, INODE_MAP_CACHE))
 		return 0;
@@ -3520,26 +3519,16 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root,
 	memset(&io_ctl, 0, sizeof(io_ctl));
 	ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl,
 				      trans, path, 0);
-	if (!ret) {
-		/*
-		 * At this point writepages() didn't error out, so our metadata
-		 * reservation is released when the writeback finishes, at
-		 * inode.c:btrfs_finish_ordered_io(), regardless of it finishing
-		 * with or without an error.
-		 */
-		release_metadata = false;
+	if (!ret)
 		ret = btrfs_wait_cache_io(root, trans, NULL, &io_ctl, path, 0);
-	}
 
-	if (ret) {
-		if (release_metadata)
-			btrfs_delalloc_release_metadata(inode, inode->i_size);
 #ifdef DEBUG
+	if (ret) {
 		btrfs_err(root->fs_info,
 			"failed to write free ino cache for root %llu",
 			root->root_key.objectid);
-#endif
 	}
+#endif
 
 	return ret;
 }
-- 
1.8.3.1



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux