Btrfs: add ref_count and free function for btrfs_bio
1: ref_count is simple than current RBIO_HOLD_BBIO_MAP_BIT flag to keep btrfs_bio's memory in raid56 recovery implement. 2: free function for bbio will make code clean and flexible, plus forced data type checking in compile. Changelog v1->v2: Rename following by David Sterba's suggestion: put_btrfs_bio() -> btrfs_put_bio() get_btrfs_bio() -> btrfs_get_bio() bbio->ref_count -> bbio->refs Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
@@ -855,7 +855,7 @@ static inline void scrub_get_recover(struct scrub_recover *recover)
|
||||
static inline void scrub_put_recover(struct scrub_recover *recover)
|
||||
{
|
||||
if (atomic_dec_and_test(&recover->refs)) {
|
||||
kfree(recover->bbio);
|
||||
btrfs_put_bbio(recover->bbio);
|
||||
kfree(recover);
|
||||
}
|
||||
}
|
||||
@@ -1373,13 +1373,13 @@ static int scrub_setup_recheck_block(struct scrub_ctx *sctx,
|
||||
ret = btrfs_map_sblock(fs_info, REQ_GET_READ_MIRRORS, logical,
|
||||
&mapped_length, &bbio, 0, 1);
|
||||
if (ret || !bbio || mapped_length < sublen) {
|
||||
kfree(bbio);
|
||||
btrfs_put_bbio(bbio);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
recover = kzalloc(sizeof(struct scrub_recover), GFP_NOFS);
|
||||
if (!recover) {
|
||||
kfree(bbio);
|
||||
btrfs_put_bbio(bbio);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -2748,7 +2748,7 @@ static void scrub_parity_check_and_repair(struct scrub_parity *sparity)
|
||||
rbio_out:
|
||||
bio_put(bio);
|
||||
bbio_out:
|
||||
kfree(bbio);
|
||||
btrfs_put_bbio(bbio);
|
||||
bitmap_or(sparity->ebitmap, sparity->ebitmap, sparity->dbitmap,
|
||||
sparity->nsectors);
|
||||
spin_lock(&sctx->stat_lock);
|
||||
@@ -3879,14 +3879,14 @@ static void scrub_remap_extent(struct btrfs_fs_info *fs_info,
|
||||
&mapped_length, &bbio, 0);
|
||||
if (ret || !bbio || mapped_length < extent_len ||
|
||||
!bbio->stripes[0].dev->bdev) {
|
||||
kfree(bbio);
|
||||
btrfs_put_bbio(bbio);
|
||||
return;
|
||||
}
|
||||
|
||||
*extent_physical = bbio->stripes[0].physical;
|
||||
*extent_mirror_num = bbio->mirror_num;
|
||||
*extent_dev = bbio->stripes[0].dev;
|
||||
kfree(bbio);
|
||||
btrfs_put_bbio(bbio);
|
||||
}
|
||||
|
||||
static int scrub_setup_wr_ctx(struct scrub_ctx *sctx,
|
||||
|
مرجع در شماره جدید
Block a user