Skip to content

Commit 39d86db

Browse files
Ming Leiaxboe
authored andcommitted
loop: add file_start_write() and file_end_write()
file_start_write() and file_end_write() should be added around ->write_iter(). Recently we switch to ->write_iter() from vfs_iter_write(), and the implied file_start_write() and file_end_write() are lost. Also we never add them for dio code path, so add them back for covering both. Cc: Jeff Moyer <[email protected]> Fixes: f2fed44 ("loop: stop using vfs_iter_{read,write} for buffered I/O") Fixes: bc07c10 ("block: loop: support DIO & AIO") Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 208c155 commit 39d86db

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/block/loop.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,14 @@ static void lo_complete_rq(struct request *rq)
308308
static void lo_rw_aio_do_completion(struct loop_cmd *cmd)
309309
{
310310
struct request *rq = blk_mq_rq_from_pdu(cmd);
311+
struct loop_device *lo = rq->q->queuedata;
311312

312313
if (!atomic_dec_and_test(&cmd->ref))
313314
return;
314315
kfree(cmd->bvec);
315316
cmd->bvec = NULL;
317+
if (req_op(rq) == REQ_OP_WRITE)
318+
file_end_write(lo->lo_backing_file);
316319
if (likely(!blk_should_fake_timeout(rq->q)))
317320
blk_mq_complete_request(rq);
318321
}
@@ -387,9 +390,10 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
387390
cmd->iocb.ki_flags = 0;
388391
}
389392

390-
if (rw == ITER_SOURCE)
393+
if (rw == ITER_SOURCE) {
394+
file_start_write(lo->lo_backing_file);
391395
ret = file->f_op->write_iter(&cmd->iocb, &iter);
392-
else
396+
} else
393397
ret = file->f_op->read_iter(&cmd->iocb, &iter);
394398

395399
lo_rw_aio_do_completion(cmd);

0 commit comments

Comments
 (0)