]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
UBIFS: incorporate maximum write size
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 30 Jan 2011 16:58:32 +0000 (18:58 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 8 Mar 2011 08:12:48 +0000 (10:12 +0200)
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
fs/ubifs/ubifs.h

index 703a62109cf220cee1ce59c54b916af35bff925e..efc327b92f982bd4e2cc684b3571d4f664c68f8b 100644 (file)
@@ -507,6 +507,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",
@@ -525,6 +527,18 @@ static int init_constants_early(struct ubifs_info *c)
                return -EINVAL;
        }
 
+       /*
+        * 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
@@ -533,6 +547,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);
@@ -1391,6 +1409,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",
index d1823541f9875e3b2e21d45ca23fe3284b3d8b92..8b519499f14af08b6e7d3d2e61d3e47bcfcc3d83 100644 (file)
@@ -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;