mtd: mtd_blkdevs: handle REQ_FLUSH request and do explicit flush of writeback buffer

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Jun 10 23:59:02 PDT 2014


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=566c0d6a74169dc5cc9f353ff4a8d579d96a85ff
Commit:     566c0d6a74169dc5cc9f353ff4a8d579d96a85ff
Parent:     47570bb1f533b2a48e5222db8545b7842c229331
Author:     Roman Peniaev <r.peniaev at gmail.com>
AuthorDate: Sat Mar 8 21:59:14 2014 +0900
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Apr 15 23:25:37 2014 -0700

    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 at gmail.com>
    Cc: David Woodhouse <dwmw2 at infradead.org>
    Cc: linux-mtd at lists.infradead.org
    Cc: linux-kernel at vger.kernel.org
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/mtd_blkdevs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 0b2ccb6..d2f0da9 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -88,6 +88,9 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
 	if (req->cmd_type != REQ_TYPE_FS)
 		return -EIO;
 
+	if (req->cmd_flags & REQ_FLUSH)
+		return tr->flush(dev);
+
 	if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
 	    get_capacity(req->rq_disk))
 		return -EIO;
@@ -408,6 +411,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	if (!new->rq)
 		goto error3;
 
+	if (tr->flush)
+		blk_queue_flush(new->rq, REQ_FLUSH);
+
 	new->rq->queuedata = new;
 	blk_queue_logical_block_size(new->rq, tr->blksize);
 



More information about the linux-mtd-cvs mailing list