Skip to contentSkip to conversation

Btrfs: fix return code in drop_objectid_items

PATCH In review Josef Bacik 2 participants 2 messages May 29, 2012 – May 30, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: fix return code in drop_objectid_items

So dpkg fsync()'s the file and the directory containing the file whenever it writes to a file which is really slow in btrfs. This is partly because fsync()'ing a directory _always_ committed the transaction instead of just going to the tree log. This is because drop_objectid_items() would return 1 since it does a btrfs_search_slot() which returns 1. In tree-log jargon this means that we have to commit the transaction to be safe. So just check if ret is greater than 0 and set it to 0 if it does. With this patch we now use the tree-log instead of committing the entire transaction, which is twice as fast on my box. Thanks,

---
 fs/btrfs/tree-log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/tree-log.c +2 -0
index 425014b..2017d0f 100644
@@ -2667,6 +2667,8 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
 		btrfs_release_path(path);
 	}
 	btrfs_release_path(path);
+	if (ret > 0)
+		ret = 0;
 	return ret;
 }
 
Signature · 1 line
1.7.7.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Josef Bacik

So dpkg fsync()'s the file and the directory containing the file whenever it writes to a file which is really slow in btrfs. This is partly because fsync()'ing a directory _always_ committed the transaction instead of just going to the tree log. This is because drop_objectid_items() would return 1 since it does a btrfs_search_slot() which returns 1. In tree-log jargon this means that we have to commit the transaction to be safe. So just check if ret is greater than 0 and set it to 0 if it does. With this patch we now use the tree-log instead of committing the entire transaction, which is twice as fast on my box. Thanks,

Good catch.

Quoted 18 lines
---
 fs/btrfs/tree-log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/tree-log.c +2 -0
index 425014b..2017d0f 100644
@@ -2667,6 +2667,8 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
 		btrfs_release_path(path);
 	}
 	btrfs_release_path(path);
+	if (ret > 0)
+		ret = 0;
 	return ret;
 }