Skip to content

Commit 566c0d6

Browse files
roumingcomputersforpeace
authored andcommitted
mtd: mtd_blkdevs: handle REQ_FLUSH request and do explicit flush of writeback buffer
mtd_blkdevs is device with volatile cache (writeback buffer), so it should support REQ_FLUSH to do explicit flush. Without this patch 'sync' does not guarantee that writeback buffer will be flushed on disk in case of power off, e.g.: $ cp some_file /mnt $ sync ### POWER OFF In case of this sequence writeback buffer will not be flushed on disk. This patch fixes this behaviour and explicitly reports to block layer that flush requests are being supported. Signed-off-by: Roman Peniaev <r.peniaev@gmail.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Brian Norris <computersforpeace@gmail.com>
1 parent 47570bb commit 566c0d6

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎drivers/mtd/mtd_blkdevs.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
8888
if (req->cmd_type != REQ_TYPE_FS)
8989
return -EIO;
9090

91+
if (req->cmd_flags & REQ_FLUSH)
92+
return tr->flush(dev);
93+
9194
if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
9295
get_capacity(req->rq_disk))
9396
return -EIO;
@@ -408,6 +411,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
408411
if (!new->rq)
409412
goto error3;
410413

414+
if (tr->flush)
415+
blk_queue_flush(new->rq, REQ_FLUSH);
416+
411417
new->rq->queuedata = new;
412418
blk_queue_logical_block_size(new->rq, tr->blksize);
413419

0 commit comments

Comments
 (0)