From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 01/40] btrfs: change how repair action is passed to btrfs_repair_one_sector
Date: Tue, 1 Nov 2022 21:11:42 +0100 [thread overview]
Message-ID: <76a74d0aca9d0c16bab3bb1811b3f86f572b03ab.1667331828.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1667331828.git.dsterba@suse.com>
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.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/btrfs_inode.h | 3 +++
fs/btrfs/compression.c | 2 +-
fs/btrfs/extent_io.c | 14 +++++++++-----
fs/btrfs/extent_io.h | 6 +-----
fs/btrfs/inode.c | 9 ++++-----
5 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index d21c30bf7053..fa0c72cabd8f 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -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_read_bio(struct inode *inode, struct bio *bio,
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,
u32 pgoff, u8 *csum, const u8 * const csum_expected);
int btrfs_check_data_csum(struct inode *inode, struct btrfs_bio *bbio,
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 52df6c06cc91..e84764ef250b 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -196,7 +196,7 @@ static void end_compressed_bio_read(struct btrfs_bio *bbio)
refcount_inc(&cb->pending_ios);
ret = btrfs_repair_one_sector(inode, bbio, offset,
bv.bv_page, bv.bv_offset,
- btrfs_submit_data_read_bio);
+ true);
if (ret) {
refcount_dec(&cb->pending_ios);
status = errno_to_blk_status(ret);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 2ec989b83f54..44ff41304247 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -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,
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;
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);
/*
- * At this point we have a bio, so any errors from submit_bio_hook()
- * will be handled by the endio on the repair_bio, so we can't return an
+ * At this point we have a bio, so any errors from bio submission will
+ * be handled by the endio on the repair_bio, so we can't return an
* 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;
}
@@ -951,7 +955,7 @@ static void submit_data_read_repair(struct inode *inode,
ret = btrfs_repair_one_sector(inode, failed_bbio,
bio_offset + offset, page, pgoff + offset,
- btrfs_submit_data_read_bio);
+ true);
if (!ret) {
/*
* We have submitted the read repair, the page release
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index a5ec1475988f..321680f229c6 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -70,10 +70,6 @@ struct extent_io_tree;
int __init extent_buffer_init_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,
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,
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);
int btrfs_clean_io_failure(struct btrfs_inode *inode, u64 start,
struct page *page, unsigned int pg_offset);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 255959574724..b9aa805bbe55 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7922,9 +7922,9 @@ static void btrfs_dio_private_put(struct btrfs_dio_private *dip)
bio_endio(&dip->bio);
}
-static void submit_dio_repair_bio(struct inode *inode, struct bio *bio,
- 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)
{
struct btrfs_dio_private *dip = btrfs_bio(bio)->private;
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -7959,8 +7959,7 @@ static blk_status_t btrfs_check_read_dio_bio(struct btrfs_dio_private *dip,
int ret;
ret = btrfs_repair_one_sector(inode, bbio, offset,
- bv.bv_page, bv.bv_offset,
- submit_dio_repair_bio);
+ bv.bv_page, bv.bv_offset, false);
if (ret)
err = errno_to_blk_status(ret);
}
--
2.37.3
next prev parent reply other threads:[~2022-11-01 20:12 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 20:11 [PATCH 00/40] Parameter and type changes to btrfs_inode David Sterba
2022-11-01 20:11 ` David Sterba [this message]
2022-11-01 20:11 ` [PATCH 02/40] btrfs: drop parameter compression_type from btrfs_submit_dio_repair_bio David Sterba
2022-11-01 20:11 ` [PATCH 03/40] btrfs: change how submit bio callback is passed to btrfs_wq_submit_bio David Sterba
2022-11-01 20:11 ` [PATCH 04/40] btrfs: simplify btree_submit_bio_start and btrfs_submit_bio_start parameters David Sterba
2022-11-02 0:12 ` Anand Jain
2022-11-03 13:28 ` David Sterba
2022-11-03 14:34 ` Anand Jain
2022-11-01 20:11 ` [PATCH 05/40] btrfs: switch async_submit_bio::inode to btrfs_inode David Sterba
2022-11-01 20:11 ` [PATCH 06/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start David Sterba
2022-11-01 20:11 ` [PATCH 07/40] btrfs: pass btrfs_inode to btrfs_submit_bio_start_direct_io David Sterba
2022-11-01 20:11 ` [PATCH 08/40] btrfs: pass btrfs_inode to btrfs_wq_submit_bio David Sterba
2022-11-01 20:11 ` [PATCH 09/40] btrfs: pass btrfs_inode to btrfs_submit_metadata_bio David Sterba
2022-11-01 20:12 ` [PATCH 10/40] btrfs: pass btrfs_inode to btrfs_submit_data_write_bio David Sterba
2022-11-01 20:12 ` [PATCH 11/40] btrfs: pass btrfs_inode to btrfs_submit_data_read_bio David Sterba
2022-11-01 20:12 ` [PATCH 12/40] btrfs: pass btrfs_inode to btrfs_submit_dio_repair_bio David Sterba
2022-11-01 20:12 ` [PATCH 13/40] btrfs: pass btrfs_inode to submit_one_bio David Sterba
2022-11-01 20:12 ` [PATCH 14/40] btrfs: pass btrfs_inode to btrfs_repair_one_sector David Sterba
2022-11-01 20:12 ` [PATCH 15/40] btrfs: switch btrfs_dio_private::inode to btrfs_inode David Sterba
2022-11-01 20:12 ` [PATCH 16/40] btrfs: pass btrfs_inode to btrfs_submit_dio_bio David Sterba
2022-11-01 20:12 ` [PATCH 17/40] btrfs: pass btrfs_inode to btrfs_truncate David Sterba
2022-11-01 20:12 ` [PATCH 18/40] btrfs: pass btrfs_inode to btrfs_inode_lock David Sterba
2022-11-01 20:12 ` [PATCH 19/40] btrfs: pass btrfs_inode to btrfs_inode_unlock David Sterba
2022-11-01 20:12 ` [PATCH 20/40] btrfs: pass btrfs_inode to btrfs_dirty_inode David Sterba
2022-11-01 20:12 ` [PATCH 21/40] btrfs: pass btrfs_inode to btrfs_add_delalloc_inodes David Sterba
2022-11-01 20:12 ` [PATCH 22/40] btrfs: switch btrfs_writepage_fixup::inode to btrfs_inode David Sterba
2022-11-01 20:12 ` [PATCH 23/40] btrfs: pass btrfs_inode to btrfs_check_data_csum David Sterba
2022-11-01 20:12 ` [PATCH 24/40] btrfs: pass btrfs_inode to __unlink_start_trans David Sterba
2022-11-01 20:12 ` [PATCH 25/40] btrfs: pass btrfs_inode to btrfs_delete_subvolume David Sterba
2022-11-01 20:12 ` [PATCH 26/40] btrfs: drop private_data parameter from extent_io_tree_init David Sterba
2022-11-01 20:12 ` [PATCH 27/40] btrfs: switch extent_io_tree::private_data to btrfs_inode and rename David Sterba
2022-11-01 20:12 ` [PATCH 28/40] btrfs: pass btrfs_inode to btrfs_merge_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 29/40] btrfs: pass btrfs_inode to btrfs_set_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 30/40] btrfs: pass btrfs_inode to btrfs_split_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 31/40] btrfs: pass btrfs_inode to btrfs_clear_delalloc_extent David Sterba
2022-11-01 20:12 ` [PATCH 32/40] btrfs: pass btrfs_inode to btrfs_unlink_subvol David Sterba
2022-11-01 20:12 ` [PATCH 33/40] btrfs: pass btrfs_inode to btrfs_inode_by_name David Sterba
2022-11-01 20:12 ` [PATCH 34/40] btrfs: pass btrfs_inode to fixup_tree_root_location David Sterba
2022-11-01 20:12 ` [PATCH 35/40] btrfs: pass btrfs_inode to inode_tree_add David Sterba
2022-11-01 20:12 ` [PATCH 36/40] btrfs: pass btrfs_inode to btrfs_inherit_iflags David Sterba
2022-11-01 20:13 ` [PATCH 37/40] btrfs: switch async_chunk::inode to btrfs_inode David Sterba
2022-11-01 20:13 ` [PATCH 38/40] btrfs: use btrfs_inode inside compress_file_range David Sterba
2022-11-01 20:13 ` [PATCH 39/40] btrfs: use btrfs_inode inside btrfs_verify_data_csum David Sterba
2022-11-01 20:13 ` [PATCH 40/40] btrfs: pass btrfs_inode to btrfs_add_delayed_iput David Sterba
2022-11-03 14:45 ` [PATCH 00/40] Parameter and type changes to btrfs_inode Anand Jain
2022-11-11 15:40 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76a74d0aca9d0c16bab3bb1811b3f86f572b03ab.1667331828.git.dsterba@suse.com \
--to=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).