Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2018 22:24:41 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335808 - in head/sys/ufs: ffs ufs
Message-ID:  <201806292224.w5TMOfSi062643@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Fri Jun 29 22:24:41 2018
New Revision: 335808
URL: https://svnweb.freebsd.org/changeset/base/335808

Log:
  Create um_flags in the ufsmount structure to hold flags for a UFS filesystem.
  Convert integer structure flags to use um_flags:
  
  	int	um_candelete;			/* devvp supports TRIM */
  	int	um_writesuspended;		/* suspension in progress */
  
  become:
  
  #define UM_CANDELETE		0x00000001	/* devvp supports TRIM */
  #define UM_WRITESUSPENDED	0x00000002	/* suspension in progress */
  
  This is in preparation for adding other flags to indicate forcible
  unmount in progress after a disk failure and possibly forcible
  downgrade to read-only.
  
  No functional change intended.
  
  Sponsored by:	Netflix

Modified:
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_suspend.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ufs/ufsmount.h

Modified: head/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_alloc.c	Fri Jun 29 22:10:40 2018	(r335807)
+++ head/sys/ufs/ffs/ffs_alloc.c	Fri Jun 29 22:24:41 2018	(r335808)
@@ -495,7 +495,7 @@ ffs_reallocblks(ap)
 	 * optimization. Also skip if reallocblks has been disabled globally.
 	 */
 	ump = ap->a_vp->v_mount->mnt_data;
-	if (ump->um_candelete || doreallocblks == 0)
+	if (((ump->um_flags) & UM_CANDELETE) != 0 || doreallocblks == 0)
 		return (ENOSPC);
 
 	/*
@@ -2322,7 +2322,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, inum, vtype, de
 	 * Nothing to delay if TRIM is disabled, or the operation is
 	 * performed on the snapshot.
 	 */
-	if (!ump->um_candelete || devvp->v_type == VREG) {
+	if (((ump->um_flags) & UM_CANDELETE) == 0 || devvp->v_type == VREG) {
 		ffs_blkfree_cg(ump, fs, devvp, bno, size, inum, dephd);
 		return;
 	}

Modified: head/sys/ufs/ffs/ffs_suspend.c
==============================================================================
--- head/sys/ufs/ffs/ffs_suspend.c	Fri Jun 29 22:10:40 2018	(r335807)
+++ head/sys/ufs/ffs/ffs_suspend.c	Fri Jun 29 22:24:41 2018	(r335808)
@@ -78,7 +78,7 @@ ffs_susp_suspended(struct mount *mp)
 	sx_assert(&ffs_susp_lock, SA_LOCKED);
 
 	ump = VFSTOUFS(mp);
-	if (ump->um_writesuspended)
+	if ((ump->um_flags & UM_WRITESUSPENDED) != 0)
 		return (1);
 	return (0);
 }
@@ -210,7 +210,7 @@ ffs_susp_suspend(struct mount *mp)
 	if ((error = vfs_write_suspend(mp, VS_SKIP_UNMOUNT)) != 0)
 		return (error);
 
-	ump->um_writesuspended = 1;
+	ump->um_flags |= UM_WRITESUSPENDED;
 
 	return (0);
 }
@@ -255,7 +255,7 @@ ffs_susp_dtor(void *data)
 
 	vfs_write_resume(mp, 0);
 	vfs_unbusy(mp);
-	ump->um_writesuspended = 0;
+	ump->um_flags &= ~UM_WRITESUSPENDED;
 
 	sx_xunlock(&ffs_susp_lock);
 }

Modified: head/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vfsops.c	Fri Jun 29 22:10:40 2018	(r335807)
+++ head/sys/ufs/ffs/ffs_vfsops.c	Fri Jun 29 22:24:41 2018	(r335808)
@@ -770,6 +770,7 @@ ffs_mountfs(devvp, mp, td)
 	struct ucred *cred;
 	struct g_consumer *cp;
 	struct mount *nmp;
+	int candelete;
 
 	fs = NULL;
 	ump = NULL;
@@ -960,8 +961,10 @@ ffs_mountfs(devvp, mp, td)
 	if ((fs->fs_flags & FS_TRIM) != 0) {
 		len = sizeof(int);
 		if (g_io_getattr("GEOM::candelete", cp, &len,
-		    &ump->um_candelete) == 0) {
-			if (!ump->um_candelete)
+		    &candelete) == 0) {
+			if (candelete)
+				ump->um_flags |= UM_CANDELETE;
+			else
 				printf("WARNING: %s: TRIM flag on fs but disk "
 				    "does not support TRIM\n",
 				    mp->mnt_stat.f_mntonname);
@@ -969,9 +972,8 @@ ffs_mountfs(devvp, mp, td)
 			printf("WARNING: %s: TRIM flag on fs but disk does "
 			    "not confirm that it supports TRIM\n",
 			    mp->mnt_stat.f_mntonname);
-			ump->um_candelete = 0;
 		}
-		if (ump->um_candelete) {
+		if (((ump->um_flags) & UM_CANDELETE) != 0) {
 			ump->um_trim_tq = taskqueue_create("trim", M_WAITOK,
 			    taskqueue_thread_enqueue, &ump->um_trim_tq);
 			taskqueue_start_threads(&ump->um_trim_tq, 1, PVFS,

Modified: head/sys/ufs/ufs/ufsmount.h
==============================================================================
--- head/sys/ufs/ufs/ufsmount.h	Fri Jun 29 22:10:40 2018	(r335807)
+++ head/sys/ufs/ufs/ufsmount.h	Fri Jun 29 22:24:41 2018	(r335808)
@@ -86,10 +86,9 @@ struct ufsmount {
 	time_t	um_itime[MAXQUOTAS];		/* inode quota time limit */
 	char	um_qflags[MAXQUOTAS];		/* quota specific flags */
 	int64_t	um_savedmaxfilesize;		/* XXX - limit maxfilesize */
-	int	um_candelete;			/* devvp supports TRIM */
-	int	um_writesuspended;		/* suspension in progress */
-	u_int	um_trim_inflight;
-	struct taskqueue *um_trim_tq;
+	u_int	um_flags;			/* filesystem flags */
+	u_int	um_trim_inflight;		/* outstanding trim count */
+	struct	taskqueue *um_trim_tq;		/* trim request queue */
 	int	(*um_balloc)(struct vnode *, off_t, int, struct ucred *,
 		    int, struct buf **);
 	int	(*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);
@@ -103,6 +102,15 @@ struct ufsmount {
 	void	(*um_snapgone)(struct inode *);
 };
 
+/*
+ * filesystem flags
+ */
+#define UM_CANDELETE		0x00000001	/* devvp supports TRIM */
+#define UM_WRITESUSPENDED	0x00000002	/* suspension in progress */
+
+/*
+ * function prototypes
+ */
 #define	UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
 #define	UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
 #define	UFS_TRUNCATE(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806292224.w5TMOfSi062643>