]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: grab write lock directly if write_lock_level is the max level
authorLiu Bo <bo.liu@linux.alibaba.com>
Fri, 18 May 2018 03:00:23 +0000 (11:00 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 May 2018 14:46:51 +0000 (16:46 +0200)
commit70f89620ffae4ff5b2ba3527130331c9a90e5ce8
treec4996ca4d8c9fd5410c400dfdffaa1dadddb2cc6
parentd1163c4fc147769fe3f5a4c0cd3a58bda41905f1
Btrfs: grab write lock directly if write_lock_level is the max level

Typically, when acquiring root node's lock, btrfs tries its best to get
read lock and trade for write lock if @write_lock_level implies to do so.

In case of (cow && (p->keep_locks || p->lowest_level)), write_lock_level
is set to BTRFS_MAX_LEVEL, which means we need to acquire root node's
write lock directly.

In this particular case, the dance of acquiring read lock and then trading
for write lock can be saved.

Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c