kernel -- tmpfs: Make tmpfs_read() MPSAFE.
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Wed, 12 Jan 2011 05:46:31 +0000 (21:46 -0800)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Wed, 12 Jan 2011 05:46:31 +0000 (21:46 -0800)
tmpfs_read() no longer takes the MPlock or per-mount token via the VOP
callbacks. It obtains the mount token itself around the uncached read path.

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

index aa40277..f5e4778 100644 (file)
@@ -269,6 +269,7 @@ tmpfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
        mp->mnt_kern_flag |= MNTK_RD_MPSAFE | MNTK_WR_MPSAFE | MNTK_GA_MPSAFE  |
                             MNTK_IN_MPSAFE | MNTK_SG_MPSAFE;
 #endif
+       mp->mnt_kern_flag |= MNTK_RD_MPSAFE;
        mp->mnt_kern_flag |= MNTK_NOMSYNC;
        mp->mnt_data = (qaddr_t)tmp;
        vfs_getnewfsid(mp);
index c73dda9..8c7836b 100644 (file)
@@ -450,12 +450,15 @@ tmpfs_read (struct vop_read_args *ap)
                bp = getcacheblk(vp, base_offset, BSIZE);
                if (bp == NULL)
                {
+                       lwkt_gettoken(&vp->v_mount->mnt_token);
                        error = bread(vp, base_offset, BSIZE, &bp);
                        if (error) {
                                brelse(bp);
+                               lwkt_reltoken(&vp->v_mount->mnt_token);
                                kprintf("tmpfs_read bread error %d\n", error);
                                break;
                        }
+                       lwkt_reltoken(&vp->v_mount->mnt_token);
                }
 
                /*