e464725
From: Josef Bacik <jbacik@fb.com>
e464725
Date: Thu, 18 Sep 2014 11:30:44 -0400
e464725
Subject: [PATCH] Btrfs: try not to ENOSPC on log replay
e464725
e464725
(cherry picked from commit 1d52c78afbbf80b58299e076a159617d6b42fe3c)
e464725
e464725
When doing log replay we may have to update inodes, which traditionally goes
e464725
through our delayed inode stuff.  This will try to move space over from the
e464725
trans handle, but we don't reserve space in our trans handle on replay since we
e464725
don't know how much we will need, so instead we try to flush.  But because we
e464725
have a trans handle open we won't flush anything, so if we are out of reserve
e464725
space we will simply return ENOSPC.  Since we know that if an operation made it
e464725
into the log then we definitely had space before the box bought the farm then we
e464725
don't need to worry about doing this space reservation.  Use the
e464725
fs_info->log_root_recovering flag to skip the delayed inode stuff and update the
e464725
item directly.  Thanks,
e464725
e464725
Signed-off-by: Josef Bacik <jbacik@fb.com>
e464725
Signed-off-by: Chris Mason <clm@fb.com>
e464725
---
e464725
 fs/btrfs/inode.c | 3 ++-
e464725
 1 file changed, 2 insertions(+), 1 deletion(-)
e464725
e464725
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
e464725
index 8039021353ab..1c1173e59adf 100644
e464725
--- a/fs/btrfs/inode.c
e464725
+++ b/fs/btrfs/inode.c
e464725
@@ -3662,7 +3662,8 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
e464725
 	 * without delay
e464725
 	 */
e464725
 	if (!btrfs_is_free_space_inode(inode)
e464725
-	    && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) {
e464725
+	    && root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID
e464725
+	    && !root->fs_info->log_root_recovering) {
e464725
 		btrfs_update_root_times(trans, root);
e464725
 
e464725
 		ret = btrfs_delayed_update_inode(trans, root, inode);
e464725
-- 
e464725
1.9.3
e464725