* [PATCH] loop: add fs_start_write() and fs_end_write()
@ 2025-05-22 14:35 Ming Lei
2025-05-22 15:31 ` Caleb Sander Mateos
0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2025-05-22 14:35 UTC (permalink / raw)
To: Jens Axboe, linux-block; +Cc: Ming Lei, Jeff Moyer
fs_start_write() and fs_end_write() should be added around ->write_iter().
Recently we switch to ->write_iter() from vfs_iter_write(), and the
implied fs_start_write() and fs_end_write() are lost.
Also we never add them for dio code path, so add them back for covering
both.
Cc: Jeff Moyer <jmoyer@redhat.com>
Fixes: f2fed441c69b ("loop: stop using vfs_iter_{read,write} for buffered I/O")
Fixes: bc07c10a3603 ("block: loop: support DIO & AIO")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/loop.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 46cba261075f..5107cc9a1872 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -308,11 +308,14 @@ static void lo_complete_rq(struct request *rq)
static void lo_rw_aio_do_completion(struct loop_cmd *cmd)
{
struct request *rq = blk_mq_rq_from_pdu(cmd);
+ struct loop_device *lo = rq->q->queuedata;
if (!atomic_dec_and_test(&cmd->ref))
return;
kfree(cmd->bvec);
cmd->bvec = NULL;
+ if (req_op(rq) == REQ_OP_WRITE)
+ file_end_write(lo->lo_backing_file);
if (likely(!blk_should_fake_timeout(rq->q)))
blk_mq_complete_request(rq);
}
@@ -387,9 +390,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
cmd->iocb.ki_flags = 0;
}
- if (rw == ITER_SOURCE)
+ if (rw == ITER_SOURCE) {
+ file_start_write(lo->lo_backing_file);
ret = file->f_op->write_iter(&cmd->iocb, &iter);
- else
+ } else
ret = file->f_op->read_iter(&cmd->iocb, &iter);
lo_rw_aio_do_completion(cmd);
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] loop: add fs_start_write() and fs_end_write()
2025-05-22 14:35 [PATCH] loop: add fs_start_write() and fs_end_write() Ming Lei
@ 2025-05-22 15:31 ` Caleb Sander Mateos
2025-05-22 16:36 ` Ming Lei
0 siblings, 1 reply; 3+ messages in thread
From: Caleb Sander Mateos @ 2025-05-22 15:31 UTC (permalink / raw)
To: Ming Lei; +Cc: Jens Axboe, linux-block, Jeff Moyer
On Thu, May 22, 2025 at 7:37 AM Ming Lei <ming.lei@redhat.com> wrote:
>
> fs_start_write() and fs_end_write() should be added around ->write_iter().
Do you mean file_start_write() and file_end_write()?
Best,
Caleb
>
> Recently we switch to ->write_iter() from vfs_iter_write(), and the
> implied fs_start_write() and fs_end_write() are lost.
>
> Also we never add them for dio code path, so add them back for covering
> both.
>
> Cc: Jeff Moyer <jmoyer@redhat.com>
> Fixes: f2fed441c69b ("loop: stop using vfs_iter_{read,write} for buffered I/O")
> Fixes: bc07c10a3603 ("block: loop: support DIO & AIO")
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> drivers/block/loop.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 46cba261075f..5107cc9a1872 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -308,11 +308,14 @@ static void lo_complete_rq(struct request *rq)
> static void lo_rw_aio_do_completion(struct loop_cmd *cmd)
> {
> struct request *rq = blk_mq_rq_from_pdu(cmd);
> + struct loop_device *lo = rq->q->queuedata;
>
> if (!atomic_dec_and_test(&cmd->ref))
> return;
> kfree(cmd->bvec);
> cmd->bvec = NULL;
> + if (req_op(rq) == REQ_OP_WRITE)
> + file_end_write(lo->lo_backing_file);
> if (likely(!blk_should_fake_timeout(rq->q)))
> blk_mq_complete_request(rq);
> }
> @@ -387,9 +390,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
> cmd->iocb.ki_flags = 0;
> }
>
> - if (rw == ITER_SOURCE)
> + if (rw == ITER_SOURCE) {
> + file_start_write(lo->lo_backing_file);
> ret = file->f_op->write_iter(&cmd->iocb, &iter);
> - else
> + } else
> ret = file->f_op->read_iter(&cmd->iocb, &iter);
>
> lo_rw_aio_do_completion(cmd);
> --
> 2.47.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] loop: add fs_start_write() and fs_end_write()
2025-05-22 15:31 ` Caleb Sander Mateos
@ 2025-05-22 16:36 ` Ming Lei
0 siblings, 0 replies; 3+ messages in thread
From: Ming Lei @ 2025-05-22 16:36 UTC (permalink / raw)
To: Caleb Sander Mateos; +Cc: Jens Axboe, linux-block, Jeff Moyer
On Thu, May 22, 2025 at 08:31:41AM -0700, Caleb Sander Mateos wrote:
> On Thu, May 22, 2025 at 7:37 AM Ming Lei <ming.lei@redhat.com> wrote:
> >
> > fs_start_write() and fs_end_write() should be added around ->write_iter().
>
> Do you mean file_start_write() and file_end_write()?
Yeah, will change it if V2 is needed.
Thanks,
Ming
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-22 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22 14:35 [PATCH] loop: add fs_start_write() and fs_end_write() Ming Lei
2025-05-22 15:31 ` Caleb Sander Mateos
2025-05-22 16:36 ` Ming Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox