All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Susi <psusi@ubuntu.com>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org
Subject: e2fsck discard errors
Date: Mon, 20 Feb 2012 15:56:28 -0500	[thread overview]
Message-ID: <4F42B37C.1000200@ubuntu.com> (raw)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was experimenting with e2fsck -E discard on image files and found
some errors introduced by commit efa1a355.  The following section of
code attempts to discard unused portions of the inode table:


/* Discard inode table */
if (ctx->options & E2F_OPT_DISCARD) {
        blk64_t used_blks, blk, num;

        used_blks = DIV_ROUND_UP(
                (EXT2_INODES_PER_GROUP(fs->super) -
                 group_free),
                EXT2_INODES_PER_BLOCK(fs->super));

        blk = ext2fs_inode_table_loc(fs, group) +
                used_blks;
        num = fs->inode_blocks_per_group -
                used_blks;
        e2fsck_discard_blocks(ctx, manager, blk, num);
}

There are two problems with this.  The first is that trying to discard
a count of zero blocks results in an -EINVAL, which silently halts (
shouldn't this at least issue a warning? ) further discard attempts.
The second I noticed after fixing that problem and had a bunch of
valid inodes discarded.  It looks like the intent of this code is to
free the part of the inode table that lies beyond the highest used
inode, but instead it is using the count of free inodes, so when you
have some free inodes followed by some used inodes, the used inodes at
the end get discarded.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPQrN8AAoJEJrBOlT6nu75X+cH/RkJeOCGM574YabLu081oGC1
d59Y9Q3gD0jswTtceFFLHWQkRsI6IiRznEp6h+IMixl7VARL6q8eoFWW0iIWqjkX
mCle03+fORxXOv2U4qg3bud5gZ4jDKW7cKZvKl+LbOFFuV11W8UKdmgDqL0HyUxh
bIC5lyUCHEWSm6/ellfSRJDFLL0ygw2irktjyszIgAGPfnbtH/fu3E0se98ke9P5
5j8jQSeONJA5VDOtVnsLR3TD9SnnhBrtbjkzSbqBDMBSy+/ji0208CY5UyrxX0y8
Oh3pWsi6GAgAKdQgVdv/acRTirOkXLMLMK0SuoUuxIlzmrAIolWI2CO8DinwZ3U=
=8H+8
-----END PGP SIGNATURE-----

             reply	other threads:[~2012-02-20 20:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20 20:56 Phillip Susi [this message]
2012-02-21  7:28 ` e2fsck discard errors Lukas Czerner

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=4F42B37C.1000200@ubuntu.com \
    --to=psusi@ubuntu.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.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.