Re: [PATCH, RFC] ext4: Store basic fs error information in the superblock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ted,

I saw your patch to store fs error information in the superblock.
I think it is a very useful feature and I have implemented something similar in
next3_snapshot_journal_error.patch and e2fs_next3_message_buffer.patch
(attached).

There is one big problem I encountered with this feature:
If the file system error behavior is set to "abort" or "remount-ro",
the journal recovery on the next mount will most likely write over the
superblock with the errors information.

To solve this problem I stored the errors message buffer in the
journal superblock
and copied the message buffer to the filesystem superblock on journal
recovery (both on mount and fsck).
fsck also displays the errors buffer and clears it.

This feature helped me hunt down some rare bugs that happened on beta
sites, which I had to analyse post-mortem.
fsck simply gives me the first few error messages after the last time
fsck was run.

Amir.


On Wed, May 5, 2010 at 9:28 PM, Amir Goldstein <amir73il@xxxxxxxxxxxx> wrote:
> Next3 error messages are recorded in a 2K message buffer after the
> journal super block.  On journal recovery, the journal message buffer
> is copied to the file system message buffer.  On fsck, if the message
> buffer is not empty, the recorded messages are printed to stdout and
> the buffer is cleared.
> Next3 supports only block size of 4K, so there is always 2K of free
> space for the message buffer after the 1K super block.
>
> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxxxxx>
> ---
>  e2fsck/journal.c |   14 ++++++++++++++
>  e2fsck/super.c   |   42 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+), 0 deletions(-)
>
> diff --git a/e2fsck/journal.c b/e2fsck/journal.c
> index 57783eb..72d2ea0 100644
> --- a/e2fsck/journal.c
> +++ b/e2fsck/journal.c
> @@ -836,6 +836,20 @@ static errcode_t recover_ext3_journal(e2fsck_t ctx)
>
>
>        if (journal->j_superblock->s_errno) {
> +               /* journal message buffer at journal super block + 1K */
> +               char *buf = ((char *) journal->j_superblock) +
> +                       SUPERBLOCK_OFFSET;
> +               int len = ctx->fs->blocksize - 2*SUPERBLOCK_OFFSET;
> +
> +               if (len >= 2*SUPERBLOCK_OFFSET && *buf) {
> +                       /* write journal message buffer to super block + 2K */
> +                       io_channel_set_blksize(ctx->fs->io, SUPERBLOCK_OFFSET);
> +                       retval = io_channel_write_blk(ctx->fs->io, 2, 2, buf);
> +                       io_channel_set_blksize(ctx->fs->io, ctx->fs->blocksize);
> +                       /* clear journal message buffer */
> +                       memset(buf, 0, len);
> +               }
> +
>                ctx->fs->super->s_state |= EXT2_ERROR_FS;
>                ext2fs_mark_super_dirty(ctx->fs);
>                journal->j_superblock->s_errno = 0;
> diff --git a/e2fsck/super.c b/e2fsck/super.c
> index f66ce9d..4a830bc 100644
> --- a/e2fsck/super.c
> +++ b/e2fsck/super.c
> @@ -584,6 +584,43 @@ static void e2fsck_fix_dirhash_hint(e2fsck_t ctx)
>        }
>  }
>
> +/*
> + * This function prints the message buffer at the end of super block.
> + */
> +static void e2fsck_print_message_buffer(e2fsck_t ctx)
> +{
> +       char *buf;
> +       int len = ctx->fs->blocksize - 2*SUPERBLOCK_OFFSET;
> +       unsigned offset = 0;
> +       int retval;
> +#define MSGLEN 256
> +
> +       if (len < 2*SUPERBLOCK_OFFSET)
> +               return;
> +
> +       buf = (char *) e2fsck_allocate_memory(ctx, len, "message buffer");
> +
> +       io_channel_set_blksize(ctx->fs->io, SUPERBLOCK_OFFSET);
> +       /* read message buffer from super block + 2K */
> +       retval = io_channel_read_blk(ctx->fs->io, 2, 2, buf);
> +       if (retval || !*buf)
> +               goto out;
> +
> +       /* print messages in buffer */
> +       puts("Error messages recorded in message buffer:");
> +       while (offset < len && buf[offset]) {
> +               printf(buf+offset);
> +               offset += MSGLEN;
> +       }
> +       /* clear message buffer */
> +       memset(buf, 0, len);
> +       retval = io_channel_write_blk(ctx->fs->io, 2, 2, buf);
> +       puts("End of message buffer.");
> +out:
> +       io_channel_set_blksize(ctx->fs->io, ctx->fs->blocksize);
> +       ext2fs_free_mem(&buf);
> +}
> +
>
>  void check_super_block(e2fsck_t ctx)
>  {
> @@ -998,6 +1035,11 @@ void check_super_block(e2fsck_t ctx)
>         */
>        e2fsck_fix_dirhash_hint(ctx);
>
> +       /*
> +        * Print message buffer if necessary
> +        */
> +       e2fsck_print_message_buffer(ctx);
> +
>        return;
>  }
>
> --
> 1.6.6
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux