From 15430057b36bca4b765fdb8e5ca56c5cc5e54982 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Tue, 17 Jul 2018 04:43:58 +0000 Subject: [PATCH] Add needed locking for um_flags added in -r335808. While here document required locking details in ufsmount structure. Reported by: kib Reviewed by: kib --- sys/ufs/ffs/ffs_suspend.c | 4 +++ sys/ufs/ufs/ufsmount.h | 61 ++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/sys/ufs/ffs/ffs_suspend.c b/sys/ufs/ffs/ffs_suspend.c index 3b21897d20da..153f726a5ae9 100644 --- a/sys/ufs/ffs/ffs_suspend.c +++ b/sys/ufs/ffs/ffs_suspend.c @@ -210,7 +210,9 @@ ffs_susp_suspend(struct mount *mp) if ((error = vfs_write_suspend(mp, VS_SKIP_UNMOUNT)) != 0) return (error); + UFS_LOCK(ump); ump->um_flags |= UM_WRITESUSPENDED; + UFS_UNLOCK(ump); return (0); } @@ -255,7 +257,9 @@ ffs_susp_dtor(void *data) vfs_write_resume(mp, 0); vfs_unbusy(mp); + UFS_LOCK(ump); ump->um_flags &= ~UM_WRITESUSPENDED; + UFS_UNLOCK(ump); sx_xunlock(&ffs_susp_lock); } diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 57fe67a392b2..1958b02f6abb 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -64,31 +64,44 @@ struct inodedep; TAILQ_HEAD(inodedeplst, inodedep); LIST_HEAD(bmsafemaphd, bmsafemap); -/* This structure describes the UFS specific mount structure data. */ +/* + * This structure describes the UFS specific mount structure data. + * The function operators are used to support different versions of + * UFS (UFS1, UFS2, etc). + * + * Lock reference: + * a - atomic operations + * c - set at allocation then constant until freed + * i - ufsmount interlock (UFS_LOCK / UFS_UNLOCK) + * q - associated quota file is locked + * r - ref to parent mount structure is held (vfs_busy / vfs_unbusy) + * u - managed by user process fsck_ufs + */ struct ufsmount { - struct mount *um_mountp; /* filesystem vfs structure */ - struct cdev *um_dev; /* device mounted */ - struct g_consumer *um_cp; - struct bufobj *um_bo; /* Buffer cache object */ - struct vnode *um_devvp; /* block device mounted vnode */ - u_long um_fstype; /* type of filesystem */ - struct fs *um_fs; /* pointer to superblock */ - struct ufs_extattr_per_mount um_extattr; /* extended attrs */ - u_long um_nindir; /* indirect ptrs per block */ - u_long um_bptrtodb; /* indir ptr to disk block */ - u_long um_seqinc; /* inc between seq blocks */ - struct mtx um_lock; /* Protects ufsmount & fs */ - pid_t um_fsckpid; /* PID permitted fsck sysctls */ - struct mount_softdeps *um_softdep; /* softdep mgmt structure */ - struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ - struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */ - time_t um_btime[MAXQUOTAS]; /* block quota time limit */ - time_t um_itime[MAXQUOTAS]; /* inode quota time limit */ - char um_qflags[MAXQUOTAS]; /* quota specific flags */ - int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */ - u_int um_flags; /* filesystem flags */ - u_int um_trim_inflight; /* outstanding trim count */ - struct taskqueue *um_trim_tq; /* trim request queue */ + struct mount *um_mountp; /* (r) filesystem vfs struct */ + struct cdev *um_dev; /* (r) device mounted */ + struct g_consumer *um_cp; /* (r) GEOM access point */ + struct bufobj *um_bo; /* (r) Buffer cache object */ + struct vnode *um_devvp; /* (r) blk dev mounted vnode */ + u_long um_fstype; /* (c) type of filesystem */ + struct fs *um_fs; /* (r) pointer to superblock */ + struct ufs_extattr_per_mount um_extattr; /* (c) extended attrs */ + u_long um_nindir; /* (c) indirect ptrs per blk */ + u_long um_bptrtodb; /* (c) indir disk block ptr */ + u_long um_seqinc; /* (c) inc between seq blocks */ + struct mtx um_lock; /* (c) Protects ufsmount & fs */ + pid_t um_fsckpid; /* (u) PID can do fsck sysctl */ + struct mount_softdeps *um_softdep; /* (c) softdep mgmt structure */ + struct vnode *um_quotas[MAXQUOTAS]; /* (q) pointer to quota files */ + struct ucred *um_cred[MAXQUOTAS]; /* (q) quota file access cred */ + time_t um_btime[MAXQUOTAS]; /* (q) block quota time limit */ + time_t um_itime[MAXQUOTAS]; /* (q) inode quota time limit */ + char um_qflags[MAXQUOTAS]; /* (i) quota specific flags */ + int64_t um_savedmaxfilesize; /* (c) track maxfilesize */ + u_int um_flags; /* (i) filesystem flags */ + u_int um_trim_inflight; /* (a) outstanding trim count */ + struct taskqueue *um_trim_tq; /* (c) trim request queue */ + /* (c) - below function ptrs */ int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, int, struct buf **); int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);