kernel -- tmpfs: Mark tmpfs_write MPSAFE.
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Tue, 25 Jan 2011 04:52:54 +0000 (20:52 -0800)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Tue, 25 Jan 2011 04:52:54 +0000 (20:52 -0800)
Push down synchronization for tmpfs_write from VN to tmpfs. Note that
tmpfs_write still takes the MPlock.

sys/vfs/tmpfs/tmpfs_vfsops.c
sys/vfs/tmpfs/tmpfs_vnops.c

index 08c1c32..8465fb1 100644 (file)
@@ -270,6 +270,7 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
                             MNTK_IN_MPSAFE | MNTK_SG_MPSAFE;
 #endif
        mp->mnt_kern_flag |= MNTK_RD_MPSAFE | MNTK_GA_MPSAFE | MNTK_SG_MPSAFE;
+       mp->mnt_kern_flag |= MNTK_WR_MPSAFE;
        mp->mnt_kern_flag |= MNTK_NOMSYNC;
        mp->mnt_data = (qaddr_t)tmp;
        vfs_getnewfsid(mp);
index 2dd36a7..5ae3183 100644 (file)
@@ -516,6 +516,8 @@ tmpfs_write (struct vop_write_args *ap)
        if (vp->v_type != VREG)
                return (EINVAL);
 
+       lwkt_gettoken(&vp->v_mount->mnt_token);
+
        oldsize = node->tn_size;
        if (ap->a_ioflag & IO_APPEND)
                uio->uio_offset = node->tn_size;
@@ -524,15 +526,20 @@ tmpfs_write (struct vop_write_args *ap)
         * Check for illegal write offsets.
         */
        if (uio->uio_offset + uio->uio_resid >
-         VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize)
+         VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize) {
+               lwkt_reltoken(&vp->v_mount->mnt_token);
                return (EFBIG);
+       }
 
        if (vp->v_type == VREG && td != NULL) {
                error = kern_getrlimit(RLIMIT_FSIZE, &limit);
-               if (error != 0)
+               if (error != 0) {
+                       lwkt_reltoken(&vp->v_mount->mnt_token);
                        return error;
+               }
                if (uio->uio_offset + uio->uio_resid > limit.rlim_cur) {
                        ksignal(td->td_proc, SIGXFSZ);
+                       lwkt_reltoken(&vp->v_mount->mnt_token);
                        return (EFBIG);
                }
        }
@@ -647,6 +654,9 @@ tmpfs_write (struct vop_write_args *ap)
 done:
 
        tmpfs_knote(vp, kflags);
+
+
+       lwkt_reltoken(&vp->v_mount->mnt_token);
        return(error);
 }