OSDN Git Service

btrfs: extent-tree: Detect bytes_may_use underflow earlier
authorQu Wenruo <wqu@suse.com>
Wed, 24 Oct 2018 12:24:01 +0000 (20:24 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:25 +0000 (14:51 +0100)
commit9f9b8e8d0ebe1af42ddd3c86e12569c53914a89d
tree6d845a630f5a031fc0ef2d365eb243579b2185ba
parent85dd506c8e022a5c5555ad22decfa0abf93a5d64
btrfs: extent-tree: Detect bytes_may_use underflow earlier

Although we have space_info::bytes_may_use underflow detection in
btrfs_free_reserved_data_space_noquota(), we have more callers who are
subtracting number from space_info::bytes_may_use.

So instead of doing underflow detection for every caller, introduce a
new wrapper update_bytes_may_use() to replace open coded bytes_may_use
modifiers.

This also introduce a macro to declare more wrappers, but currently
space_info::bytes_may_use is the mostly interesting one.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c