tags 355644 +pending
thanks

On Tue, Mar 07, 2006 at 06:12:25PM -0800, Elliott Mitchell wrote:
> That isn't what I have a problem with in this case. Problem is `mount`
> would have to understand the target filesystem in order to find out the
> journal UUID is. `mount` doesn't have that sort of understanding of any
> filesystem.

Actually mount does already, in order to support mount-by-label, but
what I would do is put that understanding into the blkid library,
which would is already being called by mount. 

> In the case of a read-only mount, sure. In the case of a read-write
> mount, it already is required if the filesystem is unclean.

But if you know the filesystem is clean, why should you run e2fsck?
Just to set the superblock hint?  That's broken, it should be
automatically done by mount.  Anyway, that's the long-term direction
but it will requre getting the new blkid library functionality
released first, so I won't worry about it right away.

In any case, I've added the feature you requested, which is a
reasonable one; I just don't think it's an adequate solution by
itself.

                                                - Ted

# HG changeset patch
# User [EMAIL PROTECTED]
# Node ID 75de1f7c349f4cd5938dccae7f196a3c2062e12f
# Parent  8634d28a8f278d91485c2dabb448188b586c9d01
Enhance e2fsck so it can fix external journal hint in the superblock 

Check to see if the superblock hint for the external journal needs to
be updated, and if so, offer to update it.  (Addresses Debian Bug:
#355644)

Signed-off-by: "Theodore Ts'o" <[EMAIL PROTECTED]>

diff -r 8634d28a8f27 -r 75de1f7c349f e2fsck/ChangeLog
--- a/e2fsck/ChangeLog  Wed Mar  8 18:25:30 2006 -0500
+++ b/e2fsck/ChangeLog  Fri Mar 10 15:25:59 2006 -0500
@@ -1,3 +1,12 @@
+2006-03-10  Theodore Ts'o  <[EMAIL PROTECTED]>
+
+       * e2fsck.h, journal.c (e2fsck_fix_ext3_journal_hint), 
+               problem.c (PR_0_EXTERNAL_JOURNAL_HINT), 
+               problem.h (PR_0_EXTERNAL_JOURNAL_HINT), super.c: Check
+               to see if the superblock hint for the external journal
+               needs to be updated, and if so, offer to update it.
+               (Addresses Debian Bug: #355644)
+
 2006-01-29  Theodore Ts'o  <[EMAIL PROTECTED]>
 
        * unix.c (check_if_skip): When skipping a check due to being on
diff -r 8634d28a8f27 -r 75de1f7c349f e2fsck/e2fsck.h
--- a/e2fsck/e2fsck.h   Wed Mar  8 18:25:30 2006 -0500
+++ b/e2fsck/e2fsck.h   Fri Mar 10 15:25:59 2006 -0500
@@ -406,6 +406,7 @@
 extern int e2fsck_check_ext3_journal(e2fsck_t ctx);
 extern int e2fsck_run_ext3_journal(e2fsck_t ctx);
 extern void e2fsck_move_ext3_journal(e2fsck_t ctx);
+extern int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx);
 
 /* pass1.c */
 extern void e2fsck_use_inode_shortcuts(e2fsck_t ctx, int bool);
diff -r 8634d28a8f27 -r 75de1f7c349f e2fsck/journal.c
--- a/e2fsck/journal.c  Wed Mar  8 18:25:30 2006 -0500
+++ b/e2fsck/journal.c  Fri Mar 10 15:25:59 2006 -0500
@@ -959,3 +959,40 @@
        return;
 }
 
+/*
+ * This function makes sure the superblock hint for the external
+ * journal is correct.
+ */
+int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx)
+{
+       struct ext2_super_block *sb = ctx->fs->super;
+       struct problem_context pctx;
+       char uuid[37], *journal_name;
+       struct stat st;
+       problem_t problem;
+       int retval;
+
+       if (!(sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) ||
+           uuid_is_null(sb->s_journal_uuid))
+               return 0;
+
+       uuid_unparse(sb->s_journal_uuid, uuid);
+       journal_name = blkid_get_devname(ctx->blkid, "UUID", uuid);
+       if (!journal_name)
+               return 0;
+
+       if (stat(journal_name, &st) < 0)
+               return 0;
+
+       if (st.st_rdev != sb->s_journal_dev) {
+               clear_problem_context(&pctx);
+               pctx.num = st.st_rdev;
+               if (fix_problem(ctx, PR_0_EXTERNAL_JOURNAL_HINT, &pctx)) {
+                       sb->s_journal_dev = st.st_rdev;
+                       ext2fs_mark_super_dirty(ctx->fs);
+               }
+       }
+
+       free(journal_name);
+       return 0;
+}
diff -r 8634d28a8f27 -r 75de1f7c349f e2fsck/problem.c
--- a/e2fsck/problem.c  Wed Mar  8 18:25:30 2006 -0500
+++ b/e2fsck/problem.c  Fri Mar 10 15:25:59 2006 -0500
@@ -341,6 +341,10 @@
        { PR_0_FUTURE_SB_LAST_WRITE,
          N_("@S last write time is in the future.  "),
          PROMPT_FIX, PR_PREEN_OK },
+
+       { PR_0_EXTERNAL_JOURNAL_HINT,
+         N_("@S hint for external superblock @s %X.  "),
+            PROMPT_FIX, PR_PREEN_OK },
 
        /* Pass 1 errors */
        
diff -r 8634d28a8f27 -r 75de1f7c349f e2fsck/problem.h
--- a/e2fsck/problem.h  Wed Mar  8 18:25:30 2006 -0500
+++ b/e2fsck/problem.h  Fri Mar 10 15:25:59 2006 -0500
@@ -189,6 +189,9 @@
 
 /* Last write time is in the future */
 #define PR_0_FUTURE_SB_LAST_WRITE              0x000032
+
+/* Superblock hint for external journal incorrect */
+#define PR_0_EXTERNAL_JOURNAL_HINT             0x000033
 
 /*
  * Pass 1 errors
diff -r 8634d28a8f27 -r 75de1f7c349f e2fsck/super.c
--- a/e2fsck/super.c    Wed Mar  8 18:25:30 2006 -0500
+++ b/e2fsck/super.c    Fri Mar 10 15:25:59 2006 -0500
@@ -728,5 +728,11 @@
         * Move the ext3 journal file, if necessary.
         */
        e2fsck_move_ext3_journal(ctx);
+
+       /*
+        * Fix journal hint, if necessary
+        */
+       e2fsck_fix_ext3_journal_hint(ctx);
+
        return;
 }


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to