From 4fce16e4c9370d91a8b88d2cb2402f6e83dddee5 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Mon, 20 Oct 2014 18:00:50 +0000 Subject: [PATCH] Provide vfs suspension support only for filesystems which need it, take two. nullfs and unionfs need to request suspension if underlying filesystem(s) use it. Utilize mnt_kern_flag for this purpose. This is a fixup for 273271. No strong objections from: kib Pointy hat to: mjg MFC after: 2 weeks --- sys/fs/nullfs/null_vfsops.c | 2 ++ sys/fs/tmpfs/tmpfs_vfsops.c | 10 +--------- sys/fs/unionfs/union_vfsops.c | 7 +++++++ sys/kern/vfs_vnops.c | 2 +- sys/sys/mount.h | 11 ++++++----- sys/ufs/ffs/ffs_vfsops.c | 2 +- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index 80824a5f714a..fd3d385a6142 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -198,6 +198,8 @@ nullfs_mount(struct mount *mp) MNTK_EXTENDED_SHARED); } mp->mnt_kern_flag |= MNTK_LOOKUP_EXCL_DOTDOT; + mp->mnt_kern_flag |= lowerrootvp->v_mount->mnt_kern_flag & + MNTK_SUSPENDABLE; MNT_IUNLOCK(mp); mp->mnt_data = xmp; vfs_getnewfsid(mp); diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index f0bb96bcf194..4777234715eb 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -255,6 +255,7 @@ tmpfs_mount(struct mount *mp) MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_SUSPENDABLE; MNT_IUNLOCK(mp); mp->mnt_data = tmp; @@ -426,14 +427,6 @@ tmpfs_sync(struct mount *mp, int waitfor) return (0); } -/* - * A stub created so that vfs does vn_start_write for this filesystem - */ -static void -tmpfs_susp_clean(struct mount *mp) -{ -} - /* * tmpfs vfs operations. */ @@ -445,6 +438,5 @@ struct vfsops tmpfs_vfsops = { .vfs_statfs = tmpfs_statfs, .vfs_fhtovp = tmpfs_fhtovp, .vfs_sync = tmpfs_sync, - .vfs_susp_clean = tmpfs_susp_clean, }; VFS_SET(tmpfs_vfsops, tmpfs, VFCF_JAIL); diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index c60b02c27940..e4b9fb50681d 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -297,6 +297,13 @@ unionfs_domount(struct mount *mp) if ((ump->um_lowervp->v_mount->mnt_flag & MNT_LOCAL) && (ump->um_uppervp->v_mount->mnt_flag & MNT_LOCAL)) mp->mnt_flag |= MNT_LOCAL; + + /* + * Check mnt_kern_flag + */ + if ((ump->um_lowervp->v_mount->mnt_flag & MNTK_SUSPENDABLE) || + (ump->um_uppervp->v_mount->mnt_flag & MNTK_SUSPENDABLE)) + mp->mnt_kern_flag |= MNTK_SUSPENDABLE; MNT_IUNLOCK(mp); /* diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 7a72137cae36..b3e1c3bf45cf 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1576,7 +1576,7 @@ static bool vn_suspendable_mp(struct mount *mp) { - return (mp->mnt_op->vfs_susp_clean != NULL); + return ((mp->mnt_kern_flag & MNTK_SUSPENDABLE) != 0); } static bool diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 633c6dbd2c71..c4e1145d809d 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -361,7 +361,7 @@ void __mnt_vnode_markerfree_active(struct vnode **mvp, struct mount *); #define MNTK_SUSPEND 0x08000000 /* request write suspension */ #define MNTK_SUSPEND2 0x04000000 /* block secondary writes */ #define MNTK_SUSPENDED 0x10000000 /* write operations are suspended */ -#define MNTK_UNUSED25 0x20000000 /* --available-- */ +#define MNTK_SUSPENDABLE 0x20000000 /* writes can be suspended */ #define MNTK_LOOKUP_SHARED 0x40000000 /* FS supports shared lock lookups */ #define MNTK_NOKNOTE 0x80000000 /* Don't send KNOTEs from VOP hooks */ @@ -754,10 +754,11 @@ vfs_statfs_t __vfs_statfs; _rc; }) #define VFS_SUSP_CLEAN(MP) do { \ - MPASS(*(MP)->mnt_op->vfs_susp_clean != NULL); \ - VFS_PROLOGUE(MP); \ - (*(MP)->mnt_op->vfs_susp_clean)(MP); \ - VFS_EPILOGUE(MP); \ + if (*(MP)->mnt_op->vfs_susp_clean != NULL) { \ + VFS_PROLOGUE(MP); \ + (*(MP)->mnt_op->vfs_susp_clean)(MP); \ + VFS_EPILOGUE(MP); \ + } \ } while (0) #define VFS_RECLAIM_LOWERVP(MP, VP) do { \ diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index d532e1b30c3d..a047ef4667a0 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1055,7 +1055,7 @@ ffs_mountfs(devvp, mp, td) */ MNT_ILOCK(mp); mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_EXTENDED_SHARED | - MNTK_NO_IOPF | MNTK_UNMAPPED_BUFS; + MNTK_NO_IOPF | MNTK_UNMAPPED_BUFS | MNTK_SUSPENDABLE; MNT_IUNLOCK(mp); #ifdef UFS_EXTATTR #ifdef UFS_EXTATTR_AUTOSTART