Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
PATCH 1/6 Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code.
--- fs/btrfs/extent-tree.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-)
fs/btrfs/extent-tree.c +12 -16
@@ -3796,16 +3796,16 @@ void btrfs_free_block_rsv(struct btrfs_root *root,kfree (rsv); } -int btrfs_block_rsv_add (struct btrfs_root *root, -struct btrfs_block_rsv *block_rsv, -u64 num_bytes) +static inline int __block_rsv_add (struct btrfs_root *root, +struct btrfs_block_rsv *block_rsv, +u64 num_bytes,int flush) {int ret;if (num_bytes ==0 )return 0 ; - ret =reserve_metadata_bytes (root, block_rsv, num_bytes,1 ); + ret =reserve_metadata_bytes (root, block_rsv, num_bytes, flush);if (!ret) {block_rsv_add_bytes (block_rsv, num_bytes,1 );return 0 ;
@@ -3814,22 +3814,18 @@ int btrfs_block_rsv_add(struct btrfs_root *root,return ret; } +int btrfs_block_rsv_add (struct btrfs_root *root, +struct btrfs_block_rsv *block_rsv, +u64 num_bytes) +{ +return __block_rsv_add (root, block_rsv, num_bytes,1 ); +} +int btrfs_block_rsv_add_noflush (struct btrfs_root *root,struct btrfs_block_rsv *block_rsv,u64 num_bytes) { -int ret; - -if (num_bytes ==0 ) -return 0 ; - - ret =reserve_metadata_bytes (root, block_rsv, num_bytes,0 ); -if (!ret) { -block_rsv_add_bytes (block_rsv, num_bytes,1 ); -return 0 ; - } - -return ret; +return __block_rsv_add (root, block_rsv, num_bytes,0 ); } int btrfs_block_rsv_check(struct btrfs_root *root,
Signature · 1 line
1.7.6.4
The mail of PATCH 0 was always rejected, so I try to send it as the reply of PATCH 1.
====================
Title: [PATCH 0/6] Random fix of the space relocation
This patchset fixes 5 bugs of the space relocation, one fixes the problem that we forgot to reserve space for writing out i-node cache, one fixes that the path is not released, this problem may cause the deadlock. one fixes the no-cow problem, this problem will break the meta-data. one fixes the deadlock that caused by the race between the relocation and the snapshot creation, the last one fixes BUG_ON() which is triggered by the orphan back-ref nodes.
NOTE: This patchset is based on the danger branch.
Miao Xie (6):
Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}()
Btrfs: fix no reserved space for writing out inode cache
Btrfs: fix unreleased path in btrfs_orphan_cleanup()
Btrfs: fix nocow when deleting the item
Btrfs: fix deadlock caused by the race between relocation and snapshot creation
Btrfs: fix orphan backref nodes
fs/btrfs/extent-tree.c | 28 ++++++++++++---------------- fs/btrfs/inode-map.c | 28 ++++++++++++++++++++++++---- fs/btrfs/inode.c | 3 +++ fs/btrfs/relocation.c | 2 ++ fs/btrfs/transaction.c | 4 ++-- fs/btrfs/volumes.c | 5 ++++- 6 files changed, 47 insertions(+), 23 deletions(-)
Quoted 63 lines · Miao Xie
btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code.
Signed-off-by Miao Xie <[email protected]>--- fs/btrfs/extent-tree.c | 28 ++++++++++++---------------- 1 files changed, 12 insertions(+), 16 deletions(-)fs/btrfs/extent-tree.c +12
-16@@ -3796,16 +3796,16 @@ void btrfs_free_block_rsv(struct btrfs_root *root,kfree (rsv); } -int btrfs_block_rsv_add (struct btrfs_root *root, -struct btrfs_block_rsv *block_rsv, -u64 num_bytes) +static inline int __block_rsv_add (struct btrfs_root *root, +struct btrfs_block_rsv *block_rsv, +u64 num_bytes,int flush) {int ret;if (num_bytes ==0 )return 0 ; - ret =reserve_metadata_bytes (root, block_rsv, num_bytes,1 ); + ret =reserve_metadata_bytes (root, block_rsv, num_bytes, flush);if (!ret) {block_rsv_add_bytes (block_rsv, num_bytes,1 );return 0 ;@@ -3814,22 +3814,18 @@ int btrfs_block_rsv_add(struct btrfs_root *root,return ret; } +int btrfs_block_rsv_add (struct btrfs_root *root, +struct btrfs_block_rsv *block_rsv, +u64 num_bytes) +{ +return __block_rsv_add (root, block_rsv, num_bytes,1 ); +} +int btrfs_block_rsv_add_noflush (struct btrfs_root *root,struct btrfs_block_rsv *block_rsv,u64 num_bytes) { -int ret; - -if (num_bytes ==0 ) -return 0 ; - - ret =reserve_metadata_bytes (root, block_rsv, num_bytes,0 ); -if (!ret) { -block_rsv_add_bytes (block_rsv, num_bytes,1 ); -return 0 ; - } - -return ret; +return __block_rsv_add (root, block_rsv, num_bytes,0 ); } int btrfs_block_rsv_check(struct btrfs_root *root,
Quoted 13 lines · Miao Xie
The mail of PATCH 0 was always rejected, so I try to send it as the reply of PATCH 1.
====================
Title: [PATCH 0/6] Random fix of the space relocationThis patchset fixes 5 bugs of the space relocation, one fixes the problem that we forgot to reserve space for writing out i-node cache, one fixes that the path is not released, this problem may cause the deadlock. one fixes the no-cow problem, this problem will break the meta-data. one fixes the deadlock that caused by the race between the relocation and the snapshot creation, the last one fixes
BUG_ON()which is triggered by the orphan back-ref nodes.
Quoted 1 line
NOTE: This patchset is based on the danger branch.
Thanks! For future patches, please use the for-linus branch instead. danger still has the subtransid code, which we need to fix
-chris