All of lore.kernel.org
 help / color / mirror / Atom feed
From: "George Spelvin" <linux@horizon.com>
To: adilger@dilger.ca, linux@horizon.com, sandeen@redhat.com
Cc: linux-ext4@vger.kernel.org
Subject: Re: mke2fs -O 64bit -E resize=<anything> divides by 0
Date: 15 Nov 2012 10:38:33 -0500	[thread overview]
Message-ID: <20121115153833.31569.qmail@science.horizon.com> (raw)
In-Reply-To: <20121112063208.16223.qmail@science.horizon.com>

Just to follow up to this thread so that anyone searching archives
will know:  DO NOT DO THIS, IT IS BUGGY.  (As of today's mke2fs 1.43-WIP.)


Asking for preallocated space boils down to reserving space in the block
group descriptor table (both the primary and all backups) for the final
total number of block groups.

A block group is as many blocks as can be controlled by a 1-block
allocation bitmap.  So with 4K blocks, that's 32K blocks, or 128 MiB.

Each descriptor is 32 bytes (or 64 bytes for 64-bit), so the largest
possible 32-bit FS, of 2^32 blocks, requires 2^17 block groups, which
requires 2^22 bytes of block group descriptor table.  That's 2^10 =
1024 blocks of 2^12 = 4K size,

mke2fs keeps track of the reserved blocks by allocating them to a
special inode (#7), with each reserved area getting one indirect block,
since that corresponds to the maximum possible size.


But here's the bug!  It turns out that mke2fs *cannot* preallocate more
than 1024 blocks of block group descriptor table, so the maximum
growth is 16 TiB on 32-bit, or 8 TiB on 64-bit (where the descriptors
are twice as large).

(Note that this is the size *in addition to* the current size, not
the final total.)

For 32-bit file systems, this is of course not a problem.  The "1000x
default growth" documented in mke2fs really means that, if you create
a file system of 16 GiB or larger, it preallocates to the 16 TiB max.

However, when using a 64bit file syste, you can sensibly ask for more
preallocation.  But if you do, (as of today; I expect Ted will at least
make it fail in future) mke2fs silently truncates the request to the
maximum it can supply.


Now, I was trying to reallocate from 10 TB to 22 TB, a 12 TB increase,
which is above the 8 TiB limit.

It turns out that there's a second bug in resize2fs which notices the
preallocated space and tries to use it, but when it's not big enough,
it does things wrong and destroys some inodes.  (if flex_bg is also
enabled, which is always is for ext4).


I expect these all to get fixed fairly soon, but please, nobody else have
my data-loss experience.

      reply	other threads:[~2012-11-15 15:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-11 22:27 mke2fs -O 64bit -E resize=<anything> divides by 0 George Spelvin
2012-11-12  1:54 ` Andreas Dilger
2012-11-12  4:32   ` George Spelvin
2012-11-12  4:37   ` Eric Sandeen
2012-11-12  6:32     ` George Spelvin
2012-11-15 15:38       ` George Spelvin [this message]

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=20121115153833.31569.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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.