Commit c7c3a6dc authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: store a block_device in struct btrfs_ordered_extent

Store the block device instead of the gendisk in the btrfs_ordered_extent
structure instead of acquiring a reference to it later.

Note: this is from series removing bdgrab/bdput, btrfs is one of the
last users.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8949b9a1
...@@ -2992,7 +2992,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) ...@@ -2992,7 +2992,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
goto out; goto out;
} }
if (ordered_extent->disk) if (ordered_extent->bdev)
btrfs_rewrite_logical_zoned(ordered_extent); btrfs_rewrite_logical_zoned(ordered_extent);
btrfs_free_io_failure_record(inode, start, end); btrfs_free_io_failure_record(inode, start, end);
......
...@@ -190,8 +190,6 @@ static int __btrfs_add_ordered_extent(struct btrfs_inode *inode, u64 file_offset ...@@ -190,8 +190,6 @@ static int __btrfs_add_ordered_extent(struct btrfs_inode *inode, u64 file_offset
entry->truncated_len = (u64)-1; entry->truncated_len = (u64)-1;
entry->qgroup_rsv = ret; entry->qgroup_rsv = ret;
entry->physical = (u64)-1; entry->physical = (u64)-1;
entry->disk = NULL;
entry->partno = (u8)-1;
ASSERT(type == BTRFS_ORDERED_REGULAR || ASSERT(type == BTRFS_ORDERED_REGULAR ||
type == BTRFS_ORDERED_NOCOW || type == BTRFS_ORDERED_NOCOW ||
......
...@@ -145,8 +145,7 @@ struct btrfs_ordered_extent { ...@@ -145,8 +145,7 @@ struct btrfs_ordered_extent {
* command in a workqueue context * command in a workqueue context
*/ */
u64 physical; u64 physical;
struct gendisk *disk; struct block_device *bdev;
u8 partno;
}; };
/* /*
......
...@@ -1349,8 +1349,7 @@ void btrfs_record_physical_zoned(struct inode *inode, u64 file_offset, ...@@ -1349,8 +1349,7 @@ void btrfs_record_physical_zoned(struct inode *inode, u64 file_offset,
return; return;
ordered->physical = physical; ordered->physical = physical;
ordered->disk = bio->bi_bdev->bd_disk; ordered->bdev = bio->bi_bdev;
ordered->partno = bio->bi_bdev->bd_partno;
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(ordered);
} }
...@@ -1362,18 +1361,16 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) ...@@ -1362,18 +1361,16 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered)
struct extent_map_tree *em_tree; struct extent_map_tree *em_tree;
struct extent_map *em; struct extent_map *em;
struct btrfs_ordered_sum *sum; struct btrfs_ordered_sum *sum;
struct block_device *bdev;
u64 orig_logical = ordered->disk_bytenr; u64 orig_logical = ordered->disk_bytenr;
u64 *logical = NULL; u64 *logical = NULL;
int nr, stripe_len; int nr, stripe_len;
/* Zoned devices should not have partitions. So, we can assume it is 0 */ /* Zoned devices should not have partitions. So, we can assume it is 0 */
ASSERT(ordered->partno == 0); ASSERT(!bdev_is_partition(ordered->bdev));
bdev = bdgrab(ordered->disk->part0); if (WARN_ON(!ordered->bdev))
if (WARN_ON(!bdev))
return; return;
if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, bdev, if (WARN_ON(btrfs_rmap_block(fs_info, orig_logical, ordered->bdev,
ordered->physical, &logical, &nr, ordered->physical, &logical, &nr,
&stripe_len))) &stripe_len)))
goto out; goto out;
...@@ -1402,7 +1399,6 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered) ...@@ -1402,7 +1399,6 @@ void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered)
out: out:
kfree(logical); kfree(logical);
bdput(bdev);
} }
bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info, bool btrfs_check_meta_write_pointer(struct btrfs_fs_info *fs_info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment