All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyungmin Park <kmpark@infradead.org>
To: linux-mtd@lists.infradead.org
Subject: [PATCH] [MTD] Use variable blksize for mtdblock
Date: Thu, 30 Aug 2007 15:59:55 +0900	[thread overview]
Message-ID: <20070830065955.GA8478@party> (raw)

[MTD] Use variable blksize for mtdblock

Even though we can assign the blksize, some codes are hard-coded.
It makes the problem, if you change the blksize.
Also others mtd user have same problem.

If we increase the blksize to PAGE_SIZE, it has better performance than before
Of course, we can use it as before as SECTOR_SIZE

Here's performance gain with same configuration and hardware.

* blksize = 4096
/ # time dd if=/dev/mtdblock3 of=/dev/null
32768+0 records in
32768+0 records out
real    0m 1.80s
user    0m 0.05s
sys     0m 0.55s

* blksize = 512
/ # time dd if=/dev/mtdblock3 of=/dev/null
32768+0 records in
32768+0 records out
real    0m 2.07s
user    0m 0.06s
sys     0m 0.38s

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 952da30..a908355 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -245,13 +245,15 @@ static int mtdblock_readsect(struct mtd_blktrans_dev *dev,
 			      unsigned long block, char *buf)
 {
 	struct mtdblk_dev *mtdblk = mtdblks[dev->devnum];
-	return do_cached_read(mtdblk, block<<9, 512, buf);
+	struct mtd_blktrans_ops *tr = dev->tr;
+	return do_cached_read(mtdblk, block<<tr->blkshift, tr->blksize, buf);
 }
 
 static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
 			      unsigned long block, char *buf)
 {
 	struct mtdblk_dev *mtdblk = mtdblks[dev->devnum];
+	struct mtd_blktrans_ops *tr = dev->tr;
 	if (unlikely(!mtdblk->cache_data && mtdblk->cache_size)) {
 		mtdblk->cache_data = vmalloc(mtdblk->mtd->erasesize);
 		if (!mtdblk->cache_data)
@@ -261,7 +263,7 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
 		 * return -EAGAIN sometimes, but why bother?
 		 */
 	}
-	return do_cached_write(mtdblk, block<<9, 512, buf);
+	return do_cached_write(mtdblk, block<<tr->blkshift, tr->blksize, buf);
 }
 
 static int mtdblock_open(struct mtd_blktrans_dev *mbd)
@@ -346,7 +348,7 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 	dev->mtd = mtd;
 	dev->devnum = mtd->index;
 
-	dev->size = mtd->size >> 9;
+	dev->size = mtd->size >> tr->blkshift;
 	dev->tr = tr;
 
 	if (!(mtd->flags & MTD_WRITEABLE))

                 reply	other threads:[~2007-08-30  7:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070830065955.GA8478@party \
    --to=kmpark@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.