diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2014-10-19 06:59:33 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2014-10-19 06:59:33 +0000 |
commit | 020b8f17a092a1bca30f3ac6627ee98f0fffbc88 (patch) | |
tree | 36b9f8d68635bf0aae8d06720114cd76dfd5f5e8 /sys/kern/vfs_vnops.c | |
parent | 3fe93b946f6ab35be43e49bb46aa35a1d1dd3489 (diff) | |
download | src-020b8f17a092a1bca30f3ac6627ee98f0fffbc88.tar.gz src-020b8f17a092a1bca30f3ac6627ee98f0fffbc88.zip |
Provide vfs suspension support only for filesystems which need it.
Need is expressed by providing vfs_susp_clean function in vfsops.
Differential Revision: D952
Reviewed by: kib (previous version)
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=273271
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r-- | sys/kern/vfs_vnops.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index b86ffa726a29..7a72137cae36 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1572,6 +1572,25 @@ vn_closefile(fp, td) return (error); } +static bool +vn_suspendable_mp(struct mount *mp) +{ + + return (mp->mnt_op->vfs_susp_clean != NULL); +} + +static bool +vn_suspendable(struct vnode *vp, struct mount **mpp) +{ + + if (vp != NULL) + *mpp = vp->v_mount; + if (*mpp == NULL) + return (false); + + return (vn_suspendable_mp(*mpp)); +} + /* * Preparing to start a filesystem write operation. If the operation is * permitted, then we bump the count of operations in progress and @@ -1621,6 +1640,9 @@ vn_start_write(vp, mpp, flags) struct mount *mp; int error; + if (!vn_suspendable(vp, mpp)) + return (0); + error = 0; /* * If a vnode is provided, get and return the mount point that @@ -1667,6 +1689,9 @@ vn_start_secondary_write(vp, mpp, flags) struct mount *mp; int error; + if (!vn_suspendable(vp, mpp)) + return (0); + retry: if (vp != NULL) { if ((error = VOP_GETWRITEMOUNT(vp, mpp)) != 0) { @@ -1724,7 +1749,7 @@ void vn_finished_write(mp) struct mount *mp; { - if (mp == NULL) + if (mp == NULL || !vn_suspendable_mp(mp)) return; MNT_ILOCK(mp); MNT_REL(mp); @@ -1747,7 +1772,7 @@ void vn_finished_secondary_write(mp) struct mount *mp; { - if (mp == NULL) + if (mp == NULL || !vn_suspendable_mp(mp)) return; MNT_ILOCK(mp); MNT_REL(mp); @@ -1770,6 +1795,8 @@ vfs_write_suspend(struct mount *mp, int flags) { int error; + MPASS(vn_suspendable_mp(mp)); + MNT_ILOCK(mp); if (mp->mnt_susp_owner == curthread) { MNT_IUNLOCK(mp); @@ -1811,6 +1838,8 @@ void vfs_write_resume(struct mount *mp, int flags) { + MPASS(vn_suspendable_mp(mp)); + MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner")); @@ -1844,6 +1873,7 @@ vfs_write_suspend_umnt(struct mount *mp) { int error; + MPASS(vn_suspendable_mp(mp)); KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0, ("vfs_write_suspend_umnt: recursed")); |