All of lore.kernel.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Anatolij Gustschin <agust@denx.de>,
	Holger Brunck <holger.brunck@keymile.com>,
	Norbert van Bolhuis <nvbolhuis@aimvalley.nl>,
	Adrian Hunter <adrian.hunter@nokia.com>
Cc: "linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>
Subject: [PATCH v2 2/5] UBIFS: incorporate maximum write size
Date: Sun,  6 Feb 2011 15:17:47 +0200	[thread overview]
Message-ID: <1296998270-19853-3-git-send-email-dedekind1@gmail.com> (raw)
In-Reply-To: <1296998270-19853-1-git-send-email-dedekind1@gmail.com>

From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Incorporate maximum write size into the UBIFS description data
structure. This patch just introduces new 'c->max_write_size'
and 'c->max_write_shift' fields as a preparation for the following
patches.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 fs/ubifs/super.c |   19 +++++++++++++++++++
 fs/ubifs/ubifs.h |    5 +++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index d203c99..6a38174 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -515,6 +515,8 @@ static int init_constants_early(struct ubifs_info *c)
 	c->half_leb_size = c->leb_size / 2;
 	c->min_io_size = c->di.min_io_size;
 	c->min_io_shift = fls(c->min_io_size) - 1;
+	c->max_write_size = c->di.max_write_size;
+	c->max_write_shift = fls(c->max_write_size) - 1;
 
 	if (c->leb_size < UBIFS_MIN_LEB_SZ) {
 		ubifs_err("too small LEBs (%d bytes), min. is %d bytes",
@@ -534,6 +536,18 @@ static int init_constants_early(struct ubifs_info *c)
 	}
 
 	/*
+	 * Maximum write size has to be greater or equivalent to min. I/O
+	 * size, and be multiple of min. I/O size.
+	 */
+	if (c->max_write_size < c->min_io_size ||
+	    c->max_write_size % c->min_io_size ||
+	    !is_power_of_2(c->max_write_size)) {
+		ubifs_err("bad write buffer size %d for %d min. I/O unit",
+			  c->max_write_size, c->min_io_size);
+		return -EINVAL;
+	}
+
+	/*
 	 * UBIFS aligns all node to 8-byte boundary, so to make function in
 	 * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is
 	 * less than 8.
@@ -541,6 +555,10 @@ static int init_constants_early(struct ubifs_info *c)
 	if (c->min_io_size < 8) {
 		c->min_io_size = 8;
 		c->min_io_shift = 3;
+		if (c->max_write_size < c->min_io_size) {
+			c->max_write_size = c->min_io_size;
+			c->max_write_shift = c->min_io_shift;
+		}
 	}
 
 	c->ref_node_alsz = ALIGN(UBIFS_REF_NODE_SZ, c->min_io_size);
@@ -1399,6 +1417,7 @@ static int mount_ubifs(struct ubifs_info *c)
 
 	dbg_msg("compiled on:         " __DATE__ " at " __TIME__);
 	dbg_msg("min. I/O unit size:  %d bytes", c->min_io_size);
+	dbg_msg("max. write size:     %d bytes", c->max_write_size);
 	dbg_msg("LEB size:            %d bytes (%d KiB)",
 		c->leb_size, c->leb_size >> 10);
 	dbg_msg("data journal heads:  %d",
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index d182354..8b51949 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1024,6 +1024,9 @@ struct ubifs_debug_info;
  *
  * @min_io_size: minimal input/output unit size
  * @min_io_shift: number of bits in @min_io_size minus one
+ * @max_write_size: maximum amount of bytes the underlying flash can write at a
+ *                  time (MTD write buffer size)
+ * @max_write_shift: number of bits in @max_write_size minus one
  * @leb_size: logical eraseblock size in bytes
  * @half_leb_size: half LEB size
  * @idx_leb_size: how many bytes of an LEB are effectively available when it is
@@ -1270,6 +1273,8 @@ struct ubifs_info {
 
 	int min_io_size;
 	int min_io_shift;
+	int max_write_size;
+	int max_write_shift;
 	int leb_size;
 	int half_leb_size;
 	int idx_leb_size;
-- 
1.7.2.3

  parent reply	other threads:[~2011-02-06 13:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-06 13:17 [PATCH v2 0/5] UBIFS: fix recovery on CFI NOR Artem Bityutskiy
2011-02-06 13:17 ` [PATCH v2 1/5] UBI: incorporate maximum write size Artem Bityutskiy
2011-02-06 13:17 ` Artem Bityutskiy [this message]
2011-02-06 13:17 ` [PATCH v2 3/5] UBIFS: introduce write-buffer size field Artem Bityutskiy
2011-02-06 13:17 ` [PATCH v2 4/5] UBIFS: use max_write_size for write-buffers Artem Bityutskiy
2011-02-06 13:17 ` [PATCH v2 5/5] UBIFS: use max_write_size during recovery Artem Bityutskiy
2011-02-07 16:25 ` [PATCH v2 0/5] UBIFS: fix recovery on CFI NOR Anatolij Gustschin
2011-02-07 16:43   ` Artem Bityutskiy
2011-02-07 16:58   ` Artem Bityutskiy
2011-02-07 18:06     ` Anatolij Gustschin
2011-02-08 14:33 ` Anatolij Gustschin
2011-02-08 21:31   ` Anatolij Gustschin
2011-02-10 15:01 ` [PATCH 0/2] Further fixes for UBIFS " Anatolij Gustschin
2011-02-10 15:01 ` [PATCH 1/2] UBIFS: fix no_more_nodes() to align to max_write_size Anatolij Gustschin
2011-02-10 15:06   ` Artem Bityutskiy
2011-02-10 15:01 ` [PATCH 2/2] mtd: cfi: fix writebufsize initialization Anatolij Gustschin
2011-02-10 15:13   ` Guillaume LECERF
2011-02-10 15:27     ` Artem Bityutskiy
2011-02-11 12:04     ` Anatolij Gustschin
2011-02-11 12:25       ` Guillaume LECERF
2011-02-11 14:36   ` Artem Bityutskiy
2011-02-11 15:05     ` Guillaume LECERF
2011-02-11 15:32   ` Artem Bityutskiy
2011-02-11 13:45 ` [PATCH v2 0/5] UBIFS: fix recovery on CFI NOR Artem Bityutskiy
2011-03-07 11:39 ` Artem Bityutskiy
2011-03-07 13:05   ` Anatolij Gustschin
2011-03-07 13:51     ` Artem Bityutskiy
2011-03-07 17:06       ` Anatolij Gustschin

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=1296998270-19853-3-git-send-email-dedekind1@gmail.com \
    --to=dedekind1@gmail.com \
    --cc=adrian.hunter@nokia.com \
    --cc=agust@denx.de \
    --cc=holger.brunck@keymile.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=nvbolhuis@aimvalley.nl \
    /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.