From owner-freebsd-current@FreeBSD.ORG Fri May 28 15:13:30 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AF5C116A4CE for ; Fri, 28 May 2004 15:13:30 -0700 (PDT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29CC343D2F for ; Fri, 28 May 2004 15:13:30 -0700 (PDT) (envelope-from se@freebsd.org) Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BTpbK-00070s-00; Sat, 29 May 2004 00:13:18 +0200 Received: from [80.132.229.82] (helo=Gatekeeper.FreeBSD.org) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BTpbJ-0003Sj-00; Sat, 29 May 2004 00:13:17 +0200 Received: from StefanEsser.FreeBSD.org (StefanEsser [192.168.0.10]) by Gatekeeper.FreeBSD.org (Postfix) with ESMTP id 4FC7B5F24; Sat, 29 May 2004 00:13:00 +0200 (CEST) Received: by StefanEsser.FreeBSD.org (Postfix, from userid 200) id C6BE72340; Sat, 29 May 2004 00:12:59 +0200 (CEST) Date: Sat, 29 May 2004 00:12:59 +0200 From: Stefan =?iso-8859-1?Q?E=DFer?= To: Ivan Voras Message-ID: <20040528221259.GA1526@StefanEsser.FreeBSD.org> Mail-Followup-To: Stefan =?iso-8859-1?Q?E=DFer?= , Ivan Voras , current@freebsd.org References: <40B4ECC8.50808@fer.hr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline In-Reply-To: <40B4ECC8.50808@fer.hr> User-Agent: Mutt/1.5.6i X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:fa3fae9b6ca38d745862a668565919f6 X-Content-Filtered-By: Mailman/MimeDel 2.1.1 cc: current@freebsd.org Subject: [PATCH] Re: Softupdates a mount option? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 May 2004 22:13:30 -0000 --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2004-05-26 21:15 +0200, Ivan Voras wrote: > This has been really nagging me for a long time: Why aren't softupdates > made a mount option (like 'sync' and 'async')? Do I remember correctly that > it is done so in NetBSD (where it's called softdeps), so it's doable? It definitely is doable, you may want to give the following patches a try. I just generated on a -CURRENT system as of today. I've been running a number of FreeBSD systems with softdep as a mount option over some 4 years now, and I think it is very convenient. The only change I did consider (but did not bother to implement before generating the attached diffs was to make softdep the default, with these patches applied you need to have "rw,softdep" in column 4 of /etc/fstab, instead of just "rw"). With these patches applied (and a new kernel and mount command), you can even enable soft-updates on a running system. Just remount the filesystem R/O and the immediately remount R/W with -o softdep (or the other way around: both are supported on a R/O filesystem). There is no risk involved in using these patches. The effect of mounting a filesystem with "-o softdep" is identical to performing a "tunefs -n enable" immediately before the mount, "-o nosoftdep" clears that flag. You can use "tunefs -p" to check the current softdep setting, but you also get it from "mount -v" and "mount -p" with the modified mount command. All other commands (including fsck) are unaffected and work as before. Just give it a try, you'll like it ;-) Regards, STefan List of modified files (most have just one line added or changed): /usr/src/sys/sys/mount.h /usr/src/sys/ufs/ffs/ffs_vfsops.c /usr/src/sys/ufs/ffs/ffs_softdep.c /usr/src/sys/ufs/ffs/ffs_softdep_stub.c /usr/src/sbin/mount/mntopts.h /usr/src/sbin/mount/mount.c /usr/src/sbin/mount/mount_ufs.c Index: /usr/src/sys/sys/mount.h --- /usr/src/sys/sys/mount.h 11 Apr 2004 21:36:31 -0000 1.161 +++ /usr/src/sys/sys/mount.h 12 Apr 2004 09:51:01 -0000 @@ -232,6 +232,7 @@ MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | \ MNT_NOATIME | \ MNT_NOSYMFOLLOW | MNT_IGNORE | MNT_JAILDEVFS | \ + MNT_SOFTDEP | \ MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR | \ MNT_ACLS | MNT_USER) Index: /usr/src/sys/ufs/ffs/ffs_vfsops.c --- /usr/src/sys/ufs/ffs/ffs_vfsops.c 29 Apr 2004 15:10:42 -0000 1.232 +++ /usr/src/sys/ufs/ffs/ffs_vfsops.c 28 May 2004 20:52:43 -0000 @@ -189,6 +189,17 @@ ump = VFSTOUFS(mp); fs = ump->um_fs; devvp = ump->um_devvp; + if (fs->fs_ronly == 0) { + /* + * preserve current softdep status, + * unless mounted read-only + */ + if (fs->fs_flags & FS_DOSOFTDEP) { + mp->mnt_flag |= MNT_SOFTDEP; + } else { + mp->mnt_flag &= ~MNT_SOFTDEP; + } + } if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) { if ((error = vn_start_write(NULL, &mp, V_WAIT)) != 0) return (error); @@ -277,7 +288,7 @@ return (error); } /* check to see if we need to start softdep */ - if ((fs->fs_flags & FS_DOSOFTDEP) && + if ((mp->mnt_flag & MNT_SOFTDEP) && (error = softdep_mount(devvp, mp, fs, td->td_ucred))){ vn_finished_write(mp); return (error); @@ -674,6 +685,9 @@ fs->fs_pendingblocks = 0; fs->fs_pendinginodes = 0; } + /* clear softdep flag in superblock, if not a softdep mount */ + if ((mp->mnt_flag & MNT_SOFTDEP) == 0) + fs->fs_flags &= ~FS_DOSOFTDEP; ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK | M_ZERO); ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT, M_WAITOK); @@ -785,7 +799,7 @@ } if (ronly == 0) { - if ((fs->fs_flags & FS_DOSOFTDEP) && + if ((mp->mnt_flag & MNT_SOFTDEP) && (error = softdep_mount(devvp, mp, fs, cred)) != 0) { free(fs->fs_csp, M_UFSMNT); goto out; Index: /usr/src/sys/ufs/ffs/ffs_softdep.c --- /usr/src/sys/ufs/ffs/ffs_softdep.c 6 Apr 2004 19:20:24 -0000 1.153 +++ /usr/src/sys/ufs/ffs/ffs_softdep.c 26 May 2004 21:57:29 -0000 @@ -1193,7 +1193,7 @@ int error, cyl; mp->mnt_flag &= ~MNT_ASYNC; - mp->mnt_flag |= MNT_SOFTDEP; + fs->fs_flags |= FS_DOSOFTDEP; /* * When doing soft updates, the counters in the * superblock may have gotten out of sync, so we have Index: /usr/src/sys/ufs/ffs/ffs_softdep_stub.c --- /usr/src/sys/ufs/ffs/ffs_softdep_stub.c 11 Jun 2003 06:31:28 -0000 1.27 +++ /usr/src/sys/ufs/ffs/ffs_softdep_stub.c 26 May 2004 21:57:29 -0000 @@ -72,6 +72,7 @@ struct fs *fs; struct ucred *cred; { + mp->mnt_flag &= ~MNT_SOFTDEP; return (0); } Index: /usr/src/sbin/mount/mount.c --- /usr/src/sbin/mount/mount.c 26 Apr 2004 15:13:45 -0000 1.66 +++ /usr/src/sbin/mount/mount.c 28 May 2004 21:36:50 -0000 @@ -758,6 +758,7 @@ if (flags & MNT_NOCLUSTERW) res = catopt(res, "noclusterw"); if (flags & MNT_NOSYMFOLLOW) res = catopt(res, "nosymfollow"); if (flags & MNT_SUIDDIR) res = catopt(res, "suiddir"); + if (flags & MNT_SOFTDEP) res = catopt(res, "softdep"); if (flags & MNT_MULTILABEL) res = catopt(res, "multilabel"); if (flags & MNT_ACLS) res = catopt(res, "acls"); Index: /usr/src/sbin/mount/mount_ufs.c --- /usr/src/sbin/mount/mount_ufs.c 9 Apr 2004 19:58:31 -0000 1.24 +++ /usr/src/sbin/mount/mount_ufs.c 28 May 2004 21:37:24 -0000 @@ -64,6 +64,7 @@ MOPT_SYNC, MOPT_UPDATE, MOPT_SNAPSHOT, + MOPT_SOFTDEP, { NULL } }; Index: /usr/src/sbin/mount/mntopts.h --- /usr/src/sbin/mount/mntopts.h 9 Apr 2004 19:58:30 -0000 1.21 +++ /usr/src/sbin/mount/mntopts.h 28 May 2004 21:35:56 -0000 @@ -53,6 +53,7 @@ #define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } #define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } #define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 } +#define MOPT_SOFTDEP { "softdep", 0, MNT_SOFTDEP, 0 } #define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 } #define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 } --bg08WKrSYDhXBjb5--