On Wed, Sep 12, 2018 at 09:51:33AM +0300, Nikolay Borisov wrote: > > > On 12.09.2018 01:06, Liu Bo wrote: > > balance_level() may return early in some cases, but these checks don't > > have to be done with blocking write lock. > > > > This puts together these checks into a helper and the benefit is to > > avoid switching spinning locks to blocking locks (in these paticular > > cases) which slows down btrfs overall. > > Performance patches without numbers are frowned upon. You need to > substantiate your claims. > > > > > > Signed-off-by: Liu Bo <bo.liu@xxxxxxxxxxxxxxxxx> > > --- > > fs/btrfs/ctree.c | 41 ++++++++++++++++++++++++++++++----------- > > 1 file changed, 30 insertions(+), 11 deletions(-) > > > > diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c > > index 858085490e23..ba267a069ca1 100644 > > --- a/fs/btrfs/ctree.c > > +++ b/fs/btrfs/ctree.c > > @@ -1758,6 +1758,29 @@ static void root_sub_used(struct btrfs_root *root, u32 size) > > return eb; > > } > > > > +static bool need_balance_level(struct btrfs_fs_info *fs_info, > > nit: I think should_balance_level seems more readable, but it could be > just me so won't insist on that. Quick grep shows that should_ is used more frequently, so I'd go with that.
