From: Josef Bacik Date: Wed, 7 Nov 2012 18:44:13 +0000 (-0500) Subject: Btrfs: only unlock and relock if we have to X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5124e00ec5b0be56155a11aec416fcc5125339f1;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git Btrfs: only unlock and relock if we have to I noticed while doing fsync tests that we were always dropping the path and re-searching when we first cow the log root even though we've already gotten the write lock on the root. That's because we don't take into account that there might not be a parent node, so fix the check to make sure there is actually a parent node before we undo all of this work for nothing. Thanks, Signed-off-by: Josef Bacik Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index e7bea1d5f75f..c7b67cf24bba 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2564,7 +2564,10 @@ again: * must have write locks on this node and the * parent */ - if (level + 1 > write_lock_level) { + if (level > write_lock_level || + (level + 1 > write_lock_level && + level + 1 < BTRFS_MAX_LEVEL && + p->nodes[level + 1])) { write_lock_level = level + 1; btrfs_release_path(p); goto again;