[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1326552921.19039.75.camel@sauron.fi.intel.com>
Date: Sat, 14 Jan 2012 16:55:21 +0200
From: Artem Bityutskiy <dedekind1@...il.com>
To: Alexander Stein <alexander.stein@...tec-electronic.com>
Cc: linux-mtd@...ts.infradead.org,
David Woodhouse <dwmw2@...radead.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] [MTD] Only call mtd->sync() method in mtdblock_release
if opened for write.
On Tue, 2012-01-10 at 13:26 +0100, Alexander Stein wrote:
> Signed-off-by: Alexander Stein <alexander.stein@...tec-electronic.com>
Added commit message, amended the patch, and pushed to l2-mtd.git,
thanks!
From 961aa500ce7592a4ac917b7b56a15d1998722acf Mon Sep 17 00:00:00 2001
From: Alexander Stein <alexander.stein@...tec-electronic.com>
Date: Tue, 10 Jan 2012 13:26:58 +0100
Subject: [PATCH] mtd: mtdblock: call mtd_sync() only if opened for write
Because it is useless to call it if the device is opened in R/O mode, and also
harmful: on CFI NOR flash it may block for long time waiting for erase
operations to complete is another partition with a R/W file-system on this
chip.
Artem Bityutskiy: write commit message, amend the patch to match the latest
tree (we use mtd_sync(), not mtd->sync() nowadays).
Signed-off-by: Alexander Stein <alexander.stein@...tec-electronic.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>
---
drivers/mtd/mtd_blkdevs.c | 1 +
drivers/mtd/mtdblock.c | 8 ++++++--
include/linux/mtd/blktrans.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index 424ca5f..f1f0671 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -233,6 +233,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
ret = __get_mtd_device(dev->mtd);
if (ret)
goto error_release;
+ dev->file_mode = mode;
unlock:
dev->open++;
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index af65912..6c6d807 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -321,8 +321,12 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
mutex_unlock(&mtdblk->cache_mutex);
if (!--mtdblk->count) {
- /* It was the last usage. Free the cache */
- mtd_sync(mbd->mtd);
+ /*
+ * It was the last usage. Free the cache, but only sync if
+ * opened for writing.
+ */
+ if (mbd->file_mode & FMODE_WRITE)
+ mtd_sync(mbd->mtd);
vfree(mtdblk->cache_data);
}
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 1bbd9f2..ed270bd 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -47,6 +47,7 @@ struct mtd_blktrans_dev {
struct request_queue *rq;
spinlock_t queue_lock;
void *priv;
+ fmode_t file_mode;
};
struct mtd_blktrans_ops {
--
1.7.7.5
--
Best Regards,
Artem Bityutskiy
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists