NetBSD-Bugs archive

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

bin/41416: tunefs(8) can't clear external log



>Number:         41416
>Category:       bin
>Synopsis:       tunefs(8) can't clear external log
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 12 19:50:00 +0000 2009
>Originator:     Manuel Bouyer
>Release:        NetBSD 5.0_STABLE
>Organization:
>Environment:
System: NetBSD ftp.lip6.fr 5.0_STABLE NetBSD 5.0_STABLE (FTP) #3: Tue May 12 
21:09:27 CEST 2009 
bouyer@roll:/dsk/l1/misc/bouyer/tmp/amd64/obj/dsk/l1/misc/bouyer/netbsd-5/src/sys/arch/amd64/compile/FTP
 amd64
Architecture: x86_64
Machine: amd64
>Description:
        If mount -o log creates a non-in-filesystem log (i.e. places the log
        at the end of the partition) tunefs(8) doesn't want to add
        UFS_WAPBL_FLAGS_CLEAR_LOG because it claims it can only
        operate on in-filesystem. This is not true; as long as the
        UFS_WAPBL_FLAGS_CLEAR_LOG flag is present the kernel will
        clear the log, whatever type it is.
>How-To-Repeat:
        mount -o log a raw partition which is larger than 2TB. The
        kernel will create a bogus log, with a silly size and place
        it at what it thinks is the end of the partition.
        try to delete this bogus log.
        
>Fix:
        This patch allowed me to clear this log. It just
        uncoditionally clear the log if we set the size to 0, whatever
        log type it is.

Index: tunefs.c
===================================================================
RCS file: /cvsroot/src/sbin/tunefs/tunefs.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 tunefs.c
--- tunefs.c    31 Jul 2008 15:55:41 -0000      1.37
+++ tunefs.c    12 May 2009 19:42:01 -0000
@@ -389,15 +389,6 @@ change_log_info(long long logfilesize)
                break;
        }
 
-       if (!in_fs_log)
-               errx(1, "Can't change size of non-in-filesystem log");
-
-       if (old_size == logfilesize && logfilesize > 0) {
-               /* no action */
-               warnx("log file size remains unchanged at %lld", logfilesize);
-               return;
-       }
-
        if (logfilesize == 0) {
                /*
                 * Don't clear out the locators - the kernel might need
@@ -410,6 +401,15 @@ change_log_info(long long logfilesize)
                return;
        }
 
+       if (!in_fs_log)
+               errx(1, "Can't change size of non-in-filesystem log");
+
+       if (old_size == logfilesize && logfilesize > 0) {
+               /* no action */
+               warnx("log file size remains unchanged at %lld", logfilesize);
+               return;
+       }
+
        if (old_size == 0) {
                /* create new log of desired size next mount */
                sblock.fs_journal_location = UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM;



Home | Main Index | Thread Index | Old Index