mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
btrfs: change how repair action is passed to btrfs_repair_one_sector
There's a function pointer passed to btrfs_repair_one_sector that will submit the right bio for repair. However there are only two callbacks, for buffered and for direct IO. This can be simplified to a bool-based switch and call either function, indirect calls in this case is an unnecessary abstraction. This allows to remove the submit_bio_hook_t typedef. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
961f5b8bf4
commit
19af6a7d34
5 changed files with 18 additions and 16 deletions
|
@ -414,6 +414,9 @@ static inline void btrfs_inode_split_flags(u64 inode_item_flags,
|
||||||
void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirror_num);
|
void btrfs_submit_data_write_bio(struct inode *inode, struct bio *bio, int mirror_num);
|
||||||
void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
|
void btrfs_submit_data_read_bio(struct inode *inode, struct bio *bio,
|
||||||
int mirror_num, enum btrfs_compression_type compress_type);
|
int mirror_num, enum btrfs_compression_type compress_type);
|
||||||
|
void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio,
|
||||||
|
int mirror_num,
|
||||||
|
enum btrfs_compression_type compress_type);
|
||||||
int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
|
int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
|
||||||
u32 pgoff, u8 *csum, const u8 * const csum_expected);
|
u32 pgoff, u8 *csum, const u8 * const csum_expected);
|
||||||
int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
|
int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
|
||||||
|
|
|
@ -196,7 +196,7 @@ static void end_compressed_bio_read(struct btrfs_bio *bbio)
|
||||||
refcount_inc(&cb->pending_ios);
|
refcount_inc(&cb->pending_ios);
|
||||||
ret = btrfs_repair_one_sector(inode, bbio, offset,
|
ret = btrfs_repair_one_sector(inode, bbio, offset,
|
||||||
bv.bv_page, bv.bv_offset,
|
bv.bv_page, bv.bv_offset,
|
||||||
btrfs_submit_data_read_bio);
|
true);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
refcount_dec(&cb->pending_ios);
|
refcount_dec(&cb->pending_ios);
|
||||||
status = errno_to_blk_status(ret);
|
status = errno_to_blk_status(ret);
|
||||||
|
|
|
@ -797,7 +797,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
|
||||||
|
|
||||||
int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
|
int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
|
||||||
u32 bio_offset, struct page *page, unsigned int pgoff,
|
u32 bio_offset, struct page *page, unsigned int pgoff,
|
||||||
submit_bio_hook_t *submit_bio_hook)
|
bool submit_buffered)
|
||||||
{
|
{
|
||||||
u64 start = failed_bbio->file_offset + bio_offset;
|
u64 start = failed_bbio->file_offset + bio_offset;
|
||||||
struct io_failure_record *failrec;
|
struct io_failure_record *failrec;
|
||||||
|
@ -856,11 +856,15 @@ int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
|
||||||
failrec->this_mirror);
|
failrec->this_mirror);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point we have a bio, so any errors from submit_bio_hook()
|
* At this point we have a bio, so any errors from bio submission will
|
||||||
* will be handled by the endio on the repair_bio, so we can't return an
|
* be handled by the endio on the repair_bio, so we can't return an
|
||||||
* error here.
|
* error here.
|
||||||
*/
|
*/
|
||||||
submit_bio_hook(inode, repair_bio, failrec->this_mirror, 0);
|
if (submit_buffered)
|
||||||
|
btrfs_submit_data_read_bio(inode, repair_bio, failrec->this_mirror, 0);
|
||||||
|
else
|
||||||
|
btrfs_submit_dio_repair_bio(inode, repair_bio, failrec->this_mirror, 0);
|
||||||
|
|
||||||
return BLK_STS_OK;
|
return BLK_STS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +955,7 @@ static void submit_data_read_repair(struct inode *inode,
|
||||||
|
|
||||||
ret = btrfs_repair_one_sector(inode, failed_bbio,
|
ret = btrfs_repair_one_sector(inode, failed_bbio,
|
||||||
bio_offset + offset, page, pgoff + offset,
|
bio_offset + offset, page, pgoff + offset,
|
||||||
btrfs_submit_data_read_bio);
|
true);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
/*
|
/*
|
||||||
* We have submitted the read repair, the page release
|
* We have submitted the read repair, the page release
|
||||||
|
|
|
@ -70,10 +70,6 @@ struct extent_io_tree;
|
||||||
int __init extent_buffer_init_cachep(void);
|
int __init extent_buffer_init_cachep(void);
|
||||||
void __cold extent_buffer_free_cachep(void);
|
void __cold extent_buffer_free_cachep(void);
|
||||||
|
|
||||||
typedef void (submit_bio_hook_t)(struct inode *inode, struct bio *bio,
|
|
||||||
int mirror_num,
|
|
||||||
enum btrfs_compression_type compress_type);
|
|
||||||
|
|
||||||
typedef blk_status_t (extent_submit_bio_start_t)(struct inode *inode,
|
typedef blk_status_t (extent_submit_bio_start_t)(struct inode *inode,
|
||||||
struct bio *bio, u64 dio_file_offset);
|
struct bio *bio, u64 dio_file_offset);
|
||||||
|
|
||||||
|
@ -277,7 +273,7 @@ struct io_failure_record {
|
||||||
|
|
||||||
int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
|
int btrfs_repair_one_sector(struct inode *inode, struct btrfs_bio *failed_bbio,
|
||||||
u32 bio_offset, struct page *page, unsigned int pgoff,
|
u32 bio_offset, struct page *page, unsigned int pgoff,
|
||||||
submit_bio_hook_t *submit_bio_hook);
|
bool submit_buffered);
|
||||||
void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, u64 end);
|
void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, u64 end);
|
||||||
int btrfs_clean_io_failure(struct btrfs_inode *inode, u64 start,
|
int btrfs_clean_io_failure(struct btrfs_inode *inode, u64 start,
|
||||||
struct page *page, unsigned int pg_offset);
|
struct page *page, unsigned int pg_offset);
|
||||||
|
|
|
@ -7923,9 +7923,9 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
|
||||||
bio_endio(&dip->bio);
|
bio_endio(&dip->bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void submit_dio_repair_bio(struct inode *inode, struct bio *bio,
|
void btrfs_submit_dio_repair_bio(struct inode *inode, struct bio *bio,
|
||||||
int mirror_num,
|
int mirror_num,
|
||||||
enum btrfs_compression_type compress_type)
|
enum btrfs_compression_type compress_type)
|
||||||
{
|
{
|
||||||
struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
|
struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
||||||
|
@ -7960,8 +7960,7 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = btrfs_repair_one_sector(inode, bbio, offset,
|
ret = btrfs_repair_one_sector(inode, bbio, offset,
|
||||||
bv.bv_page, bv.bv_offset,
|
bv.bv_page, bv.bv_offset, false);
|
||||||
submit_dio_repair_bio);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
err = errno_to_blk_status(ret);
|
err = errno_to_blk_status(ret);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue