* [PATCH] Btrfs: document rules about bio async submit
@ 2017-11-01 23:19 Liu Bo
2017-11-08 15:52 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Liu Bo @ 2017-11-01 23:19 UTC (permalink / raw)
To: linux-btrfs
These rules have been hidden in several if-else and are not
straightforward to follow, for example, dio submit hook's nocsum case
has a bug , i.e. doing async submit instead of sync submit, which has
been fixed recently.
This is documenting the rules for reference.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/inode.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e9a827b..9a2bdd9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1962,7 +1962,21 @@ static blk_status_t __btrfs_submit_bio_done(void *private_data, struct bio *bio,
/*
* extent_io.c submission hook. This does the right thing for csum calculation
- * on write, or reading the csums from the tree before a read
+ * on write, or reading the csums from the tree before a read.
+ *
+ * Rules about async/sync submit,
+ * a) read: sync submit
+ *
+ * b) write without checksum: sync submit
+ *
+ * c) write with checksum:
+ * c-1) if bio is issued by fsync: sync submit
+ * (sync_writers != 0)
+ *
+ * c-2) if root is reloc root: sync submit
+ * (only in case of buffered IO)
+ *
+ * c-3) otherwise: async submit
*/
static blk_status_t btrfs_submit_bio_hook(void *private_data, struct bio *bio,
int mirror_num, unsigned long bio_flags,
@@ -8549,6 +8563,7 @@ __btrfs_submit_dio_bio(struct bio *bio, struct inode *inode, u64 file_offset,
bool write = bio_op(bio) == REQ_OP_WRITE;
blk_status_t ret;
+ /* Check btrfs_submit_bio_hook() for rules about async submit. */
if (async_submit)
async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers);
--
2.9.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: document rules about bio async submit
2017-11-01 23:19 [PATCH] Btrfs: document rules about bio async submit Liu Bo
@ 2017-11-08 15:52 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-11-08 15:52 UTC (permalink / raw)
To: Liu Bo; +Cc: linux-btrfs
On Wed, Nov 01, 2017 at 05:19:27PM -0600, Liu Bo wrote:
> These rules have been hidden in several if-else and are not
> straightforward to follow, for example, dio submit hook's nocsum case
> has a bug , i.e. doing async submit instead of sync submit, which has
> been fixed recently.
>
> This is documenting the rules for reference.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Added to the queue, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-08 15:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 23:19 [PATCH] Btrfs: document rules about bio async submit Liu Bo
2017-11-08 15:52 ` David Sterba
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).