CVS commit: src/sys/ufs/ffs

2023-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Sep  8 23:21:55 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs_sync: Avoid unlocked access to v_numoutput/v_dirtyblkhd.

Found by lockdoc.

PR kern/57606


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.381 src/sys/ufs/ffs/ffs_vfsops.c:1.382
--- src/sys/ufs/ffs/ffs_vfsops.c:1.381	Thu Jun 15 09:15:54 2023
+++ src/sys/ufs/ffs/ffs_vfsops.c	Fri Sep  8 23:21:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.381 2023/06/15 09:15:54 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.382 2023/09/08 23:21:55 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.381 2023/06/15 09:15:54 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.382 2023/09/08 23:21:55 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2021,14 +2021,25 @@ ffs_sync(struct mount *mp, int waitfor, 
 	/*
 	 * Force stale file system control information to be flushed.
 	 */
-	if (waitfor != MNT_LAZY && (ump->um_devvp->v_numoutput > 0 ||
-	!LIST_EMPTY(&ump->um_devvp->v_dirtyblkhd))) {
-		vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
-		if ((error = VOP_FSYNC(ump->um_devvp, cred,
-		(waitfor == MNT_WAIT ? FSYNC_WAIT : 0) | FSYNC_NOLOG,
-		0, 0)) != 0)
-			allerror = error;
-		VOP_UNLOCK(ump->um_devvp);
+	if (waitfor != MNT_LAZY)  {
+		bool need_devvp_fsync;
+
+		mutex_enter(ump->um_devvp->v_interlock);
+		need_devvp_fsync = (ump->um_devvp->v_numoutput > 0 ||
+		!LIST_EMPTY(&ump->um_devvp->v_dirtyblkhd));
+		mutex_exit(ump->um_devvp->v_interlock);
+		if (need_devvp_fsync) {
+			int flags = FSYNC_NOLOG;
+
+			if (waitfor == MNT_WAIT)
+flags |= FSYNC_WAIT;
+
+			vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
+			if ((error = VOP_FSYNC(ump->um_devvp, cred, flags, 0,
+0)) != 0)
+allerror = error;
+			VOP_UNLOCK(ump->um_devvp);
+		}
 	}
 #if defined(QUOTA) || defined(QUOTA2)
 	qsync(mp);



CVS commit: src/sys/ufs/ffs

2023-09-08 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Sep  8 23:21:55 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs_sync: Avoid unlocked access to v_numoutput/v_dirtyblkhd.

Found by lockdoc.

PR kern/57606


To generate a diff of this commit:
cvs rdiff -u -r1.381 -r1.382 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2023-06-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun  5 04:59:46 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Make DEBUG_FFS_MOUNT compile again (with 64-bit ino_t).


To generate a diff of this commit:
cvs rdiff -u -r1.379 -r1.380 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.379 src/sys/ufs/ffs/ffs_vfsops.c:1.380
--- src/sys/ufs/ffs/ffs_vfsops.c:1.379	Wed Dec 21 18:58:25 2022
+++ src/sys/ufs/ffs/ffs_vfsops.c	Mon Jun  5 04:59:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.379 2022/12/21 18:58:25 chs Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.380 2023/06/05 04:59:46 rin Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.379 2022/12/21 18:58:25 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.380 2023/06/05 04:59:46 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -195,7 +195,7 @@ ffs_checkrange(struct mount *mp, ino_t i
 	struct fs *fs = VFSTOUFS(mp)->um_fs;
 
 	if (ino < UFS_ROOTINO || ino >= fs->fs_ncg * fs->fs_ipg) {
-		DPRINTF("out of range %u\n", ino);
+		DPRINTF("out of range %" PRIu64 "\n", ino);
 		return ESTALE;
 	}
 
@@ -213,7 +213,8 @@ ffs_checkrange(struct mount *mp, ino_t i
 	int error = bread(ump->um_devvp, FFS_FSBTODB(fs, cgtod(fs, cg)),
 	(int)fs->fs_cgsize, B_MODIFY, &bp);
 	if (error) {
-		DPRINTF("error %d reading cg %d ino %u\n", error, cg, ino);
+		DPRINTF("error %d reading cg %d ino %" PRIu64 "\n",
+		error, cg, ino);
 		return error;
 	}
 
@@ -222,7 +223,8 @@ ffs_checkrange(struct mount *mp, ino_t i
 	struct cg *cgp = (struct cg *)bp->b_data;
 	if (!cg_chkmagic(cgp, needswap)) {
 		brelse(bp, 0);
-		DPRINTF("bad cylinder group magic cg %d ino %u\n", cg, ino);
+		DPRINTF("bad cylinder group magic cg %d ino %" PRIu64 "\n",
+		cg, ino);
 		return ESTALE;
 	}
 
@@ -230,7 +232,7 @@ ffs_checkrange(struct mount *mp, ino_t i
 	brelse(bp, 0);
 
 	if (cg * fs->fs_ipg + initediblk < ino) {
-		DPRINTF("cg=%d fs->fs_ipg=%d initediblk=%d ino=%u\n",
+		DPRINTF("cg=%d fs->fs_ipg=%d initediblk=%d ino=%" PRIu64 "\n",
 		cg, fs->fs_ipg, initediblk, ino);
 		return ESTALE;
 	}



CVS commit: src/sys/ufs/ffs

2023-06-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun  5 04:59:46 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Make DEBUG_FFS_MOUNT compile again (with 64-bit ino_t).


To generate a diff of this commit:
cvs rdiff -u -r1.379 -r1.380 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2023-05-11 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu May 11 23:11:25 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
ffs: apply the remaining ffs_snapshot.c part of this FreeBSD commit:

  commit 364ed814e7285c8216d8a201d3ab3674eb34ce29
  Author: Kirk McKusick 
  Date:   Thu Dec 9 21:24:00 2004 +

Fixes a bug that caused UFS2 filesystems bigger than 2TB to
prematurely report that they were full and/or to panic the kernel
with the message ``ffs_clusteralloc: allocated out of group''.

Submitted by:   Henry Whincup 
MFC after:  1 week

all the other changes in that commit were applied previously by others:
 - sborrill commmitted ffs_alloc.c rev 1.123 in 2009
 - simonb committed ffs_alloc.c rev 1.110 in 2008
 - the ffs_clusteralloc() part is not needed because we no longer have
   that function.

fixes PR 57307


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ffs/ffs_snapshot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.154 src/sys/ufs/ffs/ffs_snapshot.c:1.155
--- src/sys/ufs/ffs/ffs_snapshot.c:1.154	Sat Apr 16 07:59:46 2022
+++ src/sys/ufs/ffs/ffs_snapshot.c	Thu May 11 23:11:25 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.154 2022/04/16 07:59:46 hannken Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.155 2023/05/11 23:11:25 chs Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.154 2022/04/16 07:59:46 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.155 2023/05/11 23:11:25 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -990,7 +990,7 @@ cgaccount1(int cg, struct vnode *vp, voi
 		fs->fs_bsize - fs->fs_cgsize);
 	numblks = howmany(fs->fs_size, fs->fs_frag);
 	len = howmany(fs->fs_fpg, fs->fs_frag);
-	base = cg * fs->fs_fpg / fs->fs_frag;
+	base = cgbase(fs, cg) / fs->fs_frag;
 	if (base + len >= numblks)
 		len = numblks - base - 1;
 	loc = 0;



CVS commit: src/sys/ufs/ffs

2023-05-11 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu May 11 23:11:25 UTC 2023

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
ffs: apply the remaining ffs_snapshot.c part of this FreeBSD commit:

  commit 364ed814e7285c8216d8a201d3ab3674eb34ce29
  Author: Kirk McKusick 
  Date:   Thu Dec 9 21:24:00 2004 +

Fixes a bug that caused UFS2 filesystems bigger than 2TB to
prematurely report that they were full and/or to panic the kernel
with the message ``ffs_clusteralloc: allocated out of group''.

Submitted by:   Henry Whincup 
MFC after:  1 week

all the other changes in that commit were applied previously by others:
 - sborrill commmitted ffs_alloc.c rev 1.123 in 2009
 - simonb committed ffs_alloc.c rev 1.110 in 2008
 - the ffs_clusteralloc() part is not needed because we no longer have
   that function.

fixes PR 57307


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ffs/ffs_snapshot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 18:58:25 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs: fail mounts requesting ACLs for non-ea UFS2 file systems

For non-ea UFS2 file system, fail mounts that request ACLs rather than
letting the mount succeed only to reject all ACL operations later.

Also fix the messages about the on-disk fs flags conflicting with
the mount options for which type of ACLs to use, and about requesting
both types of ACLs.


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.378 src/sys/ufs/ffs/ffs_vfsops.c:1.379
--- src/sys/ufs/ffs/ffs_vfsops.c:1.378	Thu Nov 17 06:40:40 2022
+++ src/sys/ufs/ffs/ffs_vfsops.c	Wed Dec 21 18:58:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.378 2022/11/17 06:40:40 chs Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.379 2022/12/21 18:58:25 chs Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.378 2022/11/17 06:40:40 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.379 2022/12/21 18:58:25 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -395,28 +395,25 @@ ffs_mountroot(void)
 	return (0);
 }
 
-static void
+static int
 ffs_acls(struct mount *mp, int fs_flags)
 {
-	if ((fs_flags & FS_NFS4ACLS) != 0) {
-#ifdef UFS_ACL
-		if (mp->mnt_flag & MNT_POSIX1EACLS)
-			printf("WARNING: %s: ACLs flag on fs conflicts with "
-			"\"posix1eacls\" mount option; option ignored\n",
-			mp->mnt_stat.f_mntonname);
-		mp->mnt_flag &= ~MNT_POSIX1EACLS;
-		mp->mnt_flag |= MNT_NFS4ACLS;
+	struct ufsmount *ump;
 
-#else
-		printf("WARNING: %s: ACLs flag on fs but no ACLs support\n",
-		mp->mnt_stat.f_mntonname);
-#endif
+	ump = VFSTOUFS(mp);
+	if (ump->um_fstype == UFS2 && (ump->um_flags & UFS_EA) == 0 &&
+	((mp->mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS)) != 0 ||
+	 (fs_flags & (FS_POSIX1EACLS | FS_NFS4ACLS)) != 0)) {
+		printf("%s: ACLs requested but not supported by this fs\n",
+		   mp->mnt_stat.f_mntonname);
+		return EINVAL;
 	}
+
 	if ((fs_flags & FS_POSIX1EACLS) != 0) {
 #ifdef UFS_ACL
 		if (mp->mnt_flag & MNT_NFS4ACLS)
-			printf("WARNING: %s: NFSv4 ACLs flag on fs conflicts "
-			"with \"acls\" mount option; option ignored\n",
+			printf("WARNING: %s: POSIX.1e ACLs flag on fs conflicts "
+			"with \"nfsv4acls\" mount option; option ignored\n",
 			mp->mnt_stat.f_mntonname);
 		mp->mnt_flag &= ~MNT_NFS4ACLS;
 		mp->mnt_flag |= MNT_POSIX1EACLS;
@@ -425,20 +422,34 @@ ffs_acls(struct mount *mp, int fs_flags)
 		"ACLs support\n", mp->mnt_stat.f_mntonname);
 #endif
 	}
+	if ((fs_flags & FS_NFS4ACLS) != 0) {
+#ifdef UFS_ACL
+		if (mp->mnt_flag & MNT_POSIX1EACLS)
+			printf("WARNING: %s: NFSv4 ACLs flag on fs conflicts "
+			"with \"posix1eacls\" mount option; option ignored\n",
+			mp->mnt_stat.f_mntonname);
+		mp->mnt_flag &= ~MNT_POSIX1EACLS;
+		mp->mnt_flag |= MNT_NFS4ACLS;
 
+#else
+		printf("WARNING: %s: NFSv4 ACLs flag on fs but no "
+		"ACLs support\n", mp->mnt_stat.f_mntonname);
+#endif
+	}
 	if ((mp->mnt_flag & (MNT_NFS4ACLS | MNT_POSIX1EACLS))
 	== (MNT_NFS4ACLS | MNT_POSIX1EACLS))
 	{
-		printf("WARNING: %s: posix1eacl conflicts "
-		"with \"acls\" mount option; option ignored\n",
+		printf("%s: \"posix1eacls\" and \"nfsv4acls\" options "
+		   "are mutually exclusive\n",
 		mp->mnt_stat.f_mntonname);
-		mp->mnt_flag &= ~MNT_POSIX1EACLS;
+		return EINVAL;
 	}
 
 	if (mp->mnt_flag & (MNT_NFS4ACLS | MNT_POSIX1EACLS))
 		mp->mnt_iflag &= ~(IMNT_SHRLOOKUP|IMNT_NCLOOKUP);
 	else
 		mp->mnt_iflag |= IMNT_SHRLOOKUP|IMNT_NCLOOKUP;
+	return 0;
 }
 
 /*
@@ -568,6 +579,11 @@ ffs_mount(struct mount *mp, const char *
 	mp->mnt_flag &= ~MNT_LOG;
 #endif /* !WAPBL */
 
+	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
+	UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
+	if (error)
+		goto fail;
+
 	if (!update) {
 		int xflags;
 
@@ -658,7 +674,9 @@ ffs_mount(struct mount *mp, const char *
 			fs->fs_fmod = 0;
 		}
 
-		ffs_acls(mp, fs->fs_flags);
+		error = ffs_acls(mp, fs->fs_flags);
+		if (error)
+			return error;
 		if (mp->mnt_flag & MNT_RELOAD) {
 			error = ffs_reload(mp, l->l_cred, l);
 			if (error) {
@@ -735,14 +753,9 @@ ffs_mount(struct mount *mp, const char *
 			return 0;
 	}
 
-	error = set_statvfs_info(path, UIO_USERSPACE, args->fspec,
-	UIO_USERSPACE, mp->mnt_op->vfs_name, mp, l);
-	if (error == 0)
-		(void)strncpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname,
-		sizeof(fs->fs_fsmnt));
-	else {
-	DPRINTF("set_statvfs_info returned %d", error);
-	}
+	(void)strncpy(fs->fs_fsmnt, mp->mnt_stat.f_mntonname,
+	sizeof(fs->fs_fsmnt));
+
 	fs->fs_flags &

CVS commit: src/sys/ufs/ffs

2022-12-21 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Wed Dec 21 18:58:25 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs: fail mounts requesting ACLs for non-ea UFS2 file systems

For non-ea UFS2 file system, fail mounts that request ACLs rather than
letting the mount succeed only to reject all ACL operations later.

Also fix the messages about the on-disk fs flags conflicting with
the mount options for which type of ACLs to use, and about requesting
both types of ACLs.


To generate a diff of this commit:
cvs rdiff -u -r1.378 -r1.379 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:53:29 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Some changes to "fs->fs_fmod" and "fs->fs_clean":
- clear "fs->fs_fmod" after reading the super block.
- assert we don't write a super block when mounted read-only.
- make sure "fs->fs_clean" is one of FS_ISCLEAN or FS_WASCLEAN.
- print "file system not clean" on every mount.

Should fix PR kern/57010: ffs: mounting unclean non-root fs read-only
causes spurious write to superblock


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.376 src/sys/ufs/ffs/ffs_vfsops.c:1.377
--- src/sys/ufs/ffs/ffs_vfsops.c:1.376	Sat Apr 16 08:00:55 2022
+++ src/sys/ufs/ffs/ffs_vfsops.c	Thu Nov 10 10:53:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.376 2022/04/16 08:00:55 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.377 2022/11/10 10:53:29 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.376 2022/04/16 08:00:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.377 2022/11/10 10:53:29 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -683,7 +683,8 @@ ffs_mount(struct mount *mp, const char *
 			}
 #endif
 			fs->fs_ronly = 0;
-			fs->fs_clean <<= 1;
+			fs->fs_clean =
+			fs->fs_clean == FS_ISCLEAN ? FS_WASCLEAN : 0;
 			fs->fs_fmod = 1;
 #ifdef WAPBL
 			if (fs->fs_flags & FS_DOWAPBL) {
@@ -743,20 +744,22 @@ ffs_mount(struct mount *mp, const char *
 	DPRINTF("set_statvfs_info returned %d", error);
 	}
 	fs->fs_flags &= ~FS_DOSOFTDEP;
-	if (fs->fs_fmod != 0) {	/* XXX */
+
+	if ((fs->fs_ronly && (fs->fs_clean & FS_ISCLEAN) == 0) ||
+	(!fs->fs_ronly && (fs->fs_clean & FS_WASCLEAN) == 0)) {
+		printf("%s: file system not clean (fs_clean=%#x); "
+		"please fsck(8)\n", mp->mnt_stat.f_mntfromname,
+		fs->fs_clean);
+	}
+
+	if (fs->fs_fmod != 0) {
 		int err;
 
-		fs->fs_fmod = 0;
+		KASSERT(!fs->fs_ronly);
+
 		if (fs->fs_clean & FS_WASCLEAN)
 			fs->fs_time = time_second;
-		else {
-			printf("%s: file system not clean (fs_clean=%#x); "
-			"please fsck(8)\n", mp->mnt_stat.f_mntfromname,
-			fs->fs_clean);
-			printf("%s: lost blocks %" PRId64 " files %d\n",
-			mp->mnt_stat.f_mntfromname, fs->fs_pendingblocks,
-			fs->fs_pendinginodes);
-		}
+		fs->fs_fmod = 0;
 		err = UFS_WAPBL_BEGIN(mp);
 		if (err == 0) {
 			(void) ffs_cgupdate(ump, MNT_WAIT);
@@ -1346,6 +1349,7 @@ ffs_mountfs(struct vnode *devvp, struct 
 		}
 	}
 
+	fs->fs_fmod = 0;
 	if (fs->fs_pendingblocks != 0 || fs->fs_pendinginodes != 0) {
 		fs->fs_pendingblocks = 0;
 		fs->fs_pendinginodes = 0;
@@ -1427,7 +1431,8 @@ ffs_mountfs(struct vnode *devvp, struct 
 	/* Don't bump fs_clean if we're replaying journal */
 	if (!((fs->fs_flags & FS_DOWAPBL) && (fs->fs_clean & FS_WASCLEAN))) {
 		if (ronly == 0) {
-			fs->fs_clean <<= 1;
+			fs->fs_clean =
+			fs->fs_clean == FS_ISCLEAN ? FS_WASCLEAN : 0;
 			fs->fs_fmod = 1;
 		}
 	}



CVS commit: src/sys/ufs/ffs

2022-11-10 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu Nov 10 10:53:29 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Some changes to "fs->fs_fmod" and "fs->fs_clean":
- clear "fs->fs_fmod" after reading the super block.
- assert we don't write a super block when mounted read-only.
- make sure "fs->fs_clean" is one of FS_ISCLEAN or FS_WASCLEAN.
- print "file system not clean" on every mount.

Should fix PR kern/57010: ffs: mounting unclean non-root fs read-only
causes spurious write to superblock


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2022-05-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 13 15:02:34 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
Fix typo dallocate -> deallocate


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ffs/ffs_wapbl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_wapbl.c
diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.46 src/sys/ufs/ffs/ffs_wapbl.c:1.47
--- src/sys/ufs/ffs/ffs_wapbl.c:1.46	Sat Apr 11 17:43:54 2020
+++ src/sys/ufs/ffs/ffs_wapbl.c	Fri May 13 15:02:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_wapbl.c,v 1.46 2020/04/11 17:43:54 jdolecek Exp $	*/
+/*	$NetBSD: ffs_wapbl.c,v 1.47 2022/05/13 15:02:34 reinoud Exp $	*/
 
 /*-
  * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.46 2020/04/11 17:43:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.47 2022/05/13 15:02:34 reinoud Exp $");
 
 #define WAPBL_INTERNAL
 
@@ -146,7 +146,7 @@ ffs_wapbl_replay_finish(struct mount *mp
 		 * The journal may have left partially allocated inodes in mode
 		 * zero.  This may occur if a crash occurs betweeen the node
 		 * allocation in ffs_nodeallocg and when the node is properly
-		 * initialized in ufs_makeinode.  If so, just dallocate them.
+		 * initialized in ufs_makeinode.  If so, just deallocate them.
 		 */
 		if (ip->i_mode == 0) {
 			error = UFS_WAPBL_BEGIN(mp);



CVS commit: src/sys/ufs/ffs

2022-05-13 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri May 13 15:02:34 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
Fix typo dallocate -> deallocate


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/ufs/ffs/ffs_wapbl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2022-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 16 08:00:55 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Unlock vnode for VOP_IOCTL() and wapbl_flush().


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.375 src/sys/ufs/ffs/ffs_vfsops.c:1.376
--- src/sys/ufs/ffs/ffs_vfsops.c:1.375	Sat Mar 19 13:53:33 2022
+++ src/sys/ufs/ffs/ffs_vfsops.c	Sat Apr 16 08:00:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.375 2022/03/19 13:53:33 hannken Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.376 2022/04/16 08:00:55 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.375 2022/03/19 13:53:33 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.376 2022/04/16 08:00:55 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -2480,7 +2480,9 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
 		 * contains no dirty buffers that could be in the log.
 		 */
 		if (!LIST_EMPTY(&vp->v_dirtyblkhd)) {
+			VOP_UNLOCK(vp);
 			error = wapbl_flush(mp->mnt_wapbl, 0);
+			vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 			if (error)
 return error;
 		}
@@ -2499,8 +2501,10 @@ ffs_vfs_fsync(vnode_t *vp, int flags)
 	error = vflushbuf(vp, flags);
 	if (error == 0 && (flags & FSYNC_CACHE) != 0) {
 		i = 1;
+		VOP_UNLOCK(vp);
 		(void)VOP_IOCTL(vp, DIOCCACHESYNC, &i, FWRITE,
 		kauth_cred_get());
+		vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	}
 
 	return error;



CVS commit: src/sys/ufs/ffs

2022-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 16 08:00:55 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Unlock vnode for VOP_IOCTL() and wapbl_flush().


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2022-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 16 07:59:46 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
Take the link count from the inode.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/ufs/ffs/ffs_snapshot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_snapshot.c
diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.153 src/sys/ufs/ffs/ffs_snapshot.c:1.154
--- src/sys/ufs/ffs/ffs_snapshot.c:1.153	Sun Dec  5 07:51:26 2021
+++ src/sys/ufs/ffs/ffs_snapshot.c	Sat Apr 16 07:59:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_snapshot.c,v 1.153 2021/12/05 07:51:26 msaitoh Exp $	*/
+/*	$NetBSD: ffs_snapshot.c,v 1.154 2022/04/16 07:59:46 hannken Exp $	*/
 
 /*
  * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.153 2021/12/05 07:51:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.154 2022/04/16 07:59:46 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -613,7 +613,6 @@ snapshot_copyfs(struct mount *mp, struct
 
 struct snapshot_expunge_ctx {
 	struct vnode *logvp;
-	struct lwp *l;
 	struct vnode *vp;
 	struct fs *copy_fs;
 };
@@ -621,7 +620,6 @@ struct snapshot_expunge_ctx {
 static bool
 snapshot_expunge_selector(void *cl, struct vnode *xvp)
 {
-	struct vattr vat;
 	struct snapshot_expunge_ctx *c = cl;
 	struct inode *xp;
 
@@ -639,8 +637,7 @@ snapshot_expunge_selector(void *cl, stru
 	if (xvp == c->logvp)
 		return true;
 
-	if (VOP_GETATTR(xvp, &vat, c->l->l_cred) == 0 &&
-	vat.va_nlink > 0)
+	if (xp->i_nlink > 0)
 		return false;
 
 	if (ffs_checkfreefile(c->copy_fs, c->vp, xp->i_number))
@@ -664,7 +661,6 @@ snapshot_expunge(struct mount *mp, struc
 	daddr_t blkno, *blkp;
 	struct fs *fs = VFSTOUFS(mp)->um_fs;
 	struct inode *xp;
-	struct lwp *l = curlwp;
 	struct vnode *logvp = NULL, *xvp;
 	struct vnode_iterator *marker;
 	struct snapshot_expunge_ctx ctx;
@@ -688,7 +684,6 @@ snapshot_expunge(struct mount *mp, struc
 
 	vfs_vnode_iterator_init(mp, &marker);
 	ctx.logvp = logvp;
-	ctx.l = l;
 	ctx.vp = vp;
 	ctx.copy_fs = copy_fs;
 	while ((xvp = vfs_vnode_iterator_next(marker, snapshot_expunge_selector,



CVS commit: src/sys/ufs/ffs

2022-04-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Apr 16 07:59:46 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_snapshot.c

Log Message:
Take the link count from the inode.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/ufs/ffs/ffs_snapshot.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2022-03-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 12 15:36:53 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs: Fix 64-bit inode integer truncation.

Reported-by: syzbot+1ae93e092d532582b...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.373 src/sys/ufs/ffs/ffs_vfsops.c:1.374
--- src/sys/ufs/ffs/ffs_vfsops.c:1.373	Sat Sep 18 03:05:20 2021
+++ src/sys/ufs/ffs/ffs_vfsops.c	Sat Mar 12 15:36:53 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vfsops.c,v 1.373 2021/09/18 03:05:20 christos Exp $	*/
+/*	$NetBSD: ffs_vfsops.c,v 1.374 2022/03/12 15:36:53 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.373 2021/09/18 03:05:20 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.374 2022/03/12 15:36:53 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -190,7 +190,7 @@ static const struct ufs_ops ffs_ufsops =
 };
 
 static int
-ffs_checkrange(struct mount *mp, uint32_t ino)
+ffs_checkrange(struct mount *mp, ino_t ino)
 {
 	struct fs *fs = VFSTOUFS(mp)->um_fs;
 



CVS commit: src/sys/ufs/ffs

2022-03-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 12 15:36:53 UTC 2022

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
ffs: Fix 64-bit inode integer truncation.

Reported-by: syzbot+1ae93e092d532582b...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:50 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_extattr.c

Log Message:
ffs: fix the creation of device nodes on file systems with ACLs enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ffs/ffs_extattr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:50 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_extattr.c

Log Message:
ffs: fix the creation of device nodes on file systems with ACLs enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/ffs/ffs_extattr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_extattr.c
diff -u src/sys/ufs/ffs/ffs_extattr.c:1.7 src/sys/ufs/ffs/ffs_extattr.c:1.8
--- src/sys/ufs/ffs/ffs_extattr.c:1.7	Sat Sep  5 16:30:13 2020
+++ src/sys/ufs/ffs/ffs_extattr.c	Tue Dec 14 11:06:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_extattr.c,v 1.7 2020/09/05 16:30:13 riastradh Exp $	*/
+/*	$NetBSD: ffs_extattr.c,v 1.8 2021/12/14 11:06:50 chs Exp $	*/
 
 /*-
  * SPDX-License-Identifier: (BSD-2-Clause-FreeBSD AND BSD-3-Clause)
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.7 2020/09/05 16:30:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_extattr.c,v 1.8 2021/12/14 11:06:50 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -587,8 +587,10 @@ ffs_openextattr(void *v)
 	if (fs->fs_magic == FS_UFS1_MAGIC)
 		return (EOPNOTSUPP);
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	return (ffs_open_ea(ap->a_vp, ap->a_cred));
 }
@@ -612,8 +614,10 @@ ffs_closeextattr(void *v)
 	if (fs->fs_magic == FS_UFS1_MAGIC)
 		return (EOPNOTSUPP);
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	if (ap->a_commit && (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY))
 		return (EROFS);
@@ -649,8 +653,10 @@ ffs_getextattr(void *v)
 	unsigned easize;
 	int error, ealen;
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace,
 	ap->a_cred, VREAD);
@@ -892,8 +898,10 @@ ffs_deleteextattr(void *v)
 	u_char *eae;
 	void *tmp;
 
+#ifdef __FreeBSD__
 	if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK)
 		return (EOPNOTSUPP);
+#endif
 
 	if (strlen(ap->a_name) == 0)
 		return (EINVAL);



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:12 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_vnops.c

Log Message:
ffs: support extattrs (and thus ACLs) on fifos.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ffs/ffs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_vnops.c
diff -u src/sys/ufs/ffs/ffs_vnops.c:1.137 src/sys/ufs/ffs/ffs_vnops.c:1.138
--- src/sys/ufs/ffs/ffs_vnops.c:1.137	Sun Jul 18 23:57:15 2021
+++ src/sys/ufs/ffs/ffs_vnops.c	Tue Dec 14 11:06:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_vnops.c,v 1.137 2021/07/18 23:57:15 dholland Exp $	*/
+/*	$NetBSD: ffs_vnops.c,v 1.138 2021/12/14 11:06:12 chs Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.137 2021/07/18 23:57:15 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.138 2021/12/14 11:06:12 chs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -212,9 +212,11 @@ const struct vnodeopv_entry_desc ffs_fif
 	{ &vop_reclaim_desc, ffs_reclaim },		/* reclaim */
 	{ &vop_lock_desc, genfs_lock },			/* lock */
 	{ &vop_unlock_desc, genfs_unlock },		/* unlock */
+	{ &vop_bmap_desc, ufs_bmap },			/* bmap */
 	{ &vop_strategy_desc, ffsext_strategy },	/* strategy */
 	{ &vop_print_desc, ufs_print },			/* print */
 	{ &vop_islocked_desc, genfs_islocked },		/* islocked */
+	{ &vop_pathconf_desc, ufs_pathconf },		/* pathconf */
 	{ &vop_bwrite_desc, vn_bwrite },		/* bwrite */
 	{ &vop_openextattr_desc, ffs_openextattr },	/* openextattr */
 	{ &vop_closeextattr_desc, ffs_closeextattr },	/* closeextattr */



CVS commit: src/sys/ufs/ffs

2021-12-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Tue Dec 14 11:06:12 UTC 2021

Modified Files:
src/sys/ufs/ffs: ffs_vnops.c

Log Message:
ffs: support extattrs (and thus ACLs) on fifos.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ffs/ffs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:53:29 UTC 2019

Modified Files:
src/sys/ufs/ffs: ffs_subr.c

Log Message:
Avoid unportable shift base -1 in ffs_subr.c

Cast the start variable before the modulo opration to unsigned int.

Detected with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ffs/ffs_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2019-05-27 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May 28 03:53:29 UTC 2019

Modified Files:
src/sys/ufs/ffs: ffs_subr.c

Log Message:
Avoid unportable shift base -1 in ffs_subr.c

Cast the start variable before the modulo opration to unsigned int.

Detected with kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ffs/ffs_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ffs/ffs_subr.c
diff -u src/sys/ufs/ffs/ffs_subr.c:1.50 src/sys/ufs/ffs/ffs_subr.c:1.51
--- src/sys/ufs/ffs/ffs_subr.c:1.50	Wed Jul  4 02:02:15 2018
+++ src/sys/ufs/ffs/ffs_subr.c	Tue May 28 03:53:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_subr.c,v 1.50 2018/07/04 02:02:15 kamil Exp $	*/
+/*	$NetBSD: ffs_subr.c,v 1.51 2019/05/28 03:53:28 kamil Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -36,7 +36,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.50 2018/07/04 02:02:15 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.51 2019/05/28 03:53:28 kamil Exp $");
 
 #include 
 
@@ -313,7 +313,7 @@ ffs_clusteracct(struct fs *fs, struct cg
 		end = ufs_rw32(cgp->cg_nclusterblks, needswap);
 	mapp = &freemapp[start / NBBY];
 	map = *mapp++;
-	bit = 1U << (start % NBBY);
+	bit = 1U << ((unsigned int)start % NBBY);
 	for (i = start; i < end; i++) {
 		if ((map & bit) == 0)
 			break;
@@ -334,7 +334,7 @@ ffs_clusteracct(struct fs *fs, struct cg
 		end = -1;
 	mapp = &freemapp[start / NBBY];
 	map = *mapp--;
-	bit = 1U << (start % NBBY);
+	bit = 1U << ((unsigned int)start % NBBY);
 	for (i = start; i > end; i--) {
 		if ((map & bit) == 0)
 			break;



Re: CVS commit: src/sys/ufs/ffs

2017-08-20 Thread coypu
On Sun, Aug 20, 2017 at 12:51:39PM +, Maya Rashish wrote:
> - panic("%s: dup alloc ino=%" PRId64 " on %s: mode %x/%x "
> + panic("%s: dup alloc ino=%" PRId64 " on %s: mode %o/%o "

Can I do this in a panic message btw?


Re: CVS commit: src/sys/ufs/ffs

2016-05-08 Thread Maxime Villard

Le 07/05/2016 23:01, David Holland a écrit :

On Sat, May 07, 2016 at 11:59:09AM +, Maxime Villard wrote:
  > Modified Files:
  >  src/sys/ufs/ffs: ffs_subr.c
  >
  > Log Message:
  > uaf

  : -   if ((*bpp)->b_blkno >= 0 && (error = fscow_run(*bpp, false)) != 0)
  : +   if ((*bpp)->b_blkno >= 0 && (error = fscow_run(*bpp, false)) != 0) {
  :brelse(*bpp, BC_INVAL);
  : +   *bpp = NULL;
  : +   }

If this makes any difference it means that the caller (of ffs_getblk)
is using the returned buffer even if the function fails, which is
wrong.

Please don't commit changes that mask bugs elsewhere... but in any
case please provide more information about what "uaf" you found and
where it really happens, so it can be fixed properly.



http://nxr.netbsd.org/xref/src/sys/ufs/ffs/ffs_alloc.c#1278

If you think the design is wrong, feel free to fix it.



Re: CVS commit: src/sys/ufs/ffs

2016-05-07 Thread David Holland
On Sat, May 07, 2016 at 11:59:09AM +, Maxime Villard wrote:
 > Modified Files:
 >  src/sys/ufs/ffs: ffs_subr.c
 > 
 > Log Message:
 > uaf

 : -   if ((*bpp)->b_blkno >= 0 && (error = fscow_run(*bpp, false)) != 0)
 : +   if ((*bpp)->b_blkno >= 0 && (error = fscow_run(*bpp, false)) != 0) {
 :brelse(*bpp, BC_INVAL);
 : +   *bpp = NULL;
 : +   }

If this makes any difference it means that the caller (of ffs_getblk)
is using the returned buffer even if the function fails, which is
wrong.

Please don't commit changes that mask bugs elsewhere... but in any
case please provide more information about what "uaf" you found and
where it really happens, so it can be fixed properly.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/ufs/ffs

2016-05-07 Thread Alistair Crooks
pea

(Please Expand Acronyms)

Thx,
agc

On 7 May 2016 at 04:59, Maxime Villard  wrote:
> Module Name:src
> Committed By:   maxv
> Date:   Sat May  7 11:59:09 UTC 2016
>
> Modified Files:
> src/sys/ufs/ffs: ffs_subr.c
>
> Log Message:
> uaf
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ffs/ffs_subr.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>


Re: CVS commit: src/sys/ufs/ffs

2015-10-22 Thread Joerg Sonnenberger
On Thu, Oct 22, 2015 at 11:31:31AM +, Maxime Villard wrote:
> Module Name:  src
> Committed By: maxv
> Date: Thu Oct 22 11:31:31 UTC 2015
> 
> Modified Files:
>   src/sys/ufs/ffs: ffs_vfsops.c
> 
> Log Message:
> Fix PR 50070. From hannken@.

In the future, please write that problem you actually fixed, not just
some random number.

Joerg


Re: CVS commit: src/sys/ufs/ffs

2015-02-24 Thread David Holland
On Mon, Feb 23, 2015 at 01:38:54PM +, Maxime Villard wrote:
 > Modified Files:
 >  src/sys/ufs/ffs: ffs_vfsops.c
 > 
 > Log Message:
 > Small changes:
 >  - instead of always calling DPRINTF with __func__, put __func__ directly
 >in the macro
 >  - ffs_mountfs(): rename fsblockloc -> fs_sblockloc, initialize fs_sbsize
 >to zero
 > No real functional change

Those two really should have been committed separately though.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/ufs/ffs

2015-02-15 Thread Christos Zoulas
In article <26607.1424011...@splode.eterna.com.au>,
matthew green   wrote:
>
>> > Also, I think you might want to keep the print when the
>> > checksum is wrong.
>> 
>> If we keep this print, then we keep a lot of other prints. So we don't
>keep it.
>
>i don't follow.
>
>usually these messages are the only real indication of what is
>actually wrong, and they aren't log spew problems.
>
>what are you trying to solve by removing them?  and what is this
>list of "lot of other prints"?  each one should be considered on
>its own pros/cons.

I agree, the printfs are VERY useful. They are the only indication
to what's wrong when mount returns EINVAL. If you are mounting a filesystem
and it does not work, you usually end up putting them back :-)

christos



re: CVS commit: src/sys/ufs/ffs

2015-02-15 Thread matthew green

> > Also, I think you might want to keep the print when the
> > checksum is wrong.
> 
> If we keep this print, then we keep a lot of other prints. So we don't keep 
> it.

i don't follow.

usually these messages are the only real indication of what is
actually wrong, and they aren't log spew problems.

what are you trying to solve by removing them?  and what is this
list of "lot of other prints"?  each one should be considered on
its own pros/cons.


.mrg.


Re: CVS commit: src/sys/ufs/ffs

2015-02-15 Thread Maxime Villard
Le 14/02/2015 20:21, David Holland a écrit :
> On Sat, Feb 14, 2015 at 08:07:39AM +, Maxime Villard wrote:
>  > Modified Files:
>  >src/sys/ufs/ffs: ffs_appleufs.c
>  > 
>  > Log Message:
>  > ffs_appleufs_validate():
>  >  - remove superfluous printfs
>  >  - ensure ul_namelen!=0, otherwise the kernel accesses ul_name[-1] and
>  >overwrites the previous field in the structure.
> 
> Did you test this?

It is the only change I didn't test. This change was superficial anyway.

Verily, I didn't understand what this function was supposed to do: it is never
called with n!=NULL, and the misleading comment plus the negative index
convinced me it was just dead.

> It is almost certain that this bit:
> 
> *n = *o;
> -   n->ul_checksum = 0;
> n->ul_checksum = ffs_appleufs_cksum(n);
> 
> breaks it.

Yes, you are right. I thought it was another misleading instruction.

> Also, I think you might want to keep the print when the
> checksum is wrong.
> 

If we keep this print, then we keep a lot of other prints. So we don't keep it.

Thanks!


Re: CVS commit: src/sys/ufs/ffs

2015-02-14 Thread David Holland
On Sat, Feb 14, 2015 at 08:07:39AM +, Maxime Villard wrote:
 > Modified Files:
 >  src/sys/ufs/ffs: ffs_appleufs.c
 > 
 > Log Message:
 > ffs_appleufs_validate():
 >  - remove superfluous printfs
 >  - ensure ul_namelen!=0, otherwise the kernel accesses ul_name[-1] and
 >overwrites the previous field in the structure.

Did you test this? It is almost certain that this bit:

*n = *o;
-   n->ul_checksum = 0;
n->ul_checksum = ffs_appleufs_cksum(n);

breaks it. Also, I think you might want to keep the print when the
checksum is wrong.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/ufs/ffs

2014-07-11 Thread David Holland
On Fri, Jul 11, 2014 at 12:17:29PM -0400, Christos Zoulas wrote:
 > Modified Files:
 >  src/sys/ufs/ffs: ffs_wapbl.c
 > 
 > Log Message:
 > move the flag setting higher to avoid KASSERT (dholland)

unfortunately... I don't think that's right either. I'm not sure what
might happen if it sets the flag before beginning the transaction...

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/ufs/ffs

2014-07-11 Thread David Holland
On Thu, Jul 10, 2014 at 11:15:54AM -0400, Christos Zoulas wrote:
 > Modified Files:
 >  src/sys/ufs/ffs: ffs_wapbl.c
 > 
 > Log Message:
 > CID 975226: hande error from UFS_WAPBL_BEGIN

That won't work; AFAICT, if that UFS_WAPBL_BEGIN fails you need to do
fs->fs_flags |= FS_DOWAPBL before calling ffs_wapbl_stop or it'll
assert.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/ufs/ffs

2011-04-23 Thread Erik Fair

On Apr 23, 2011, at 00:36, Juergen Hannken-Illjes wrote:

> Module Name:  src
> Committed By: hannken
> Date: Sat Apr 23 07:36:02 UTC 2011
> 
> Modified Files:
>   src/sys/ufs/ffs: ffs_balloc.c
> 
> Log Message:
> Try to keep snapshot indirect blocks contiguous.
> 
> This speeds up snapshot creation by a factor of ~3 and reduces
> the file system suspension time by a factor of ~5.

This definitely sounds like a pullup candidate for netbsd-5.

Erik 



Re: CVS commit: src/sys/ufs/ffs

2010-08-09 Thread Antti Kantee
On Mon Aug 09 2010 at 17:59:08 +0200, Christoph Egger wrote:
> > Tested by compiling sys/rump with CPPFLAGS+=-DMAXPHYS=32768 (all
> > tests in tests/fs still pass).  I don't know how we're going to
> > translate this into an easy regression test, though.  Maybe with
> > a hacked newfs?
> 
> No. What you need is dd, /dev/zero, some disk space, vnconfig, newfs, mount, 
> umount and rm in this order
> to have an easy regression test. :)

That's not a very optimal approach for two reaons:
1) it requires a host with MAXPHYS < 64k unnecessarily limiting
   testing of MI code to a handful of setups.  I don't test my MI changes
   on a xen domu, and I assume there are others, the anita runs being
   the most important example.
2) in case the test produces a useful result (i.e. fails), your test
   host will have panicked.


Re: CVS commit: src/sys/ufs/ffs

2010-08-09 Thread Christoph Egger

> Module Name:  src
> Committed By: pooka
> Date: Mon Aug  9 15:50:13 UTC 2010
> 
> Modified Files:
>   src/sys/ufs/ffs: ffs_vfsops.c
> 
> Log Message:
> Return error if we try to mount a file system with block size > MAXBSIZE.
> 
> Note: there is a billion ways to make the kernel panic by trying
> to mount a garbage file system and I don't imagine we'll ever get
> close to fixing even half of them.  However, for this one failing
> gracefully is a bonus since Xen DomU only does 32k MAXBSIZE and
> the 64k MAXBSIZE file systems are out there (PR port-xen/43727).
> 
> Tested by compiling sys/rump with CPPFLAGS+=-DMAXPHYS=32768 (all
> tests in tests/fs still pass).  I don't know how we're going to
> translate this into an easy regression test, though.  Maybe with
> a hacked newfs?

No. What you need is dd, /dev/zero, some disk space, vnconfig, newfs, mount, 
umount and rm in this order
to have an easy regression test. :)

Christoph


CVS commit: src/sys/ufs/ffs

2010-02-23 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Feb 23 20:41:41 UTC 2010

Modified Files:
src/sys/ufs/ffs: ffs_wapbl.c

Log Message:
Replace individual queries for partition information with
new helper function.
Use this information to query physical sector sizes for WAPBL
instead of hardcoded defaults.
No longer limits physical sector sizes to 512 bytes.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/ffs/ffs_wapbl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2010-02-21 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Feb 21 13:55:58 UTC 2010

Modified Files:
src/sys/ufs/ffs: ffs_alloc.c

Log Message:
For the UVM_PAGE_TRKOWN test do not require that the relevant pages
must exist.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/ufs/ffs/ffs_alloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2010-02-10 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Feb 11 00:06:16 UTC 2010

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
There is no code left that uses disk size data, so don't query it.
This also failed when querying the simulated block device from mfs.
Fixes PR kern/42782.


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2010-02-05 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Feb  5 20:03:36 UTC 2010

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Correct addressing of superblock updates.


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2010-01-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 31 10:54:10 UTC 2010

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c fs.h

Log Message:
Fix block shift to work with different device block sizes.

Unlike other filesystems this has some side issues because
the shift values are stored in the superblock and because
userland utitlies share the same fsbtodb macros.

-> the kernel now ignores the value stored in the superblock.
-> the macro adaption is only done for defined(_KERNEL) code.


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/sys/ufs/ffs/ffs_vfsops.c
cvs rdiff -u -r1.54 -r1.55 src/sys/ufs/ffs/fs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/ufs/ffs

2010-01-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 31 10:50:23 UTC 2010

Modified Files:
src/sys/ufs/ffs: ffs_vfsops.c

Log Message:
Replace individual queries for partition information with
new helper function.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/sys/ufs/ffs/ffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.