From fe9b86cf0b7a453c772a2756389fda91c12c3fab Mon Sep 17 00:00:00 2001 From: kato Date: Sat, 27 Sep 1997 13:40:20 +0000 Subject: Clustered read and write are switched at mount-option level. 1. Clustered I/O is switched by the MNT_NOCLUSTERR and MNT_NOCLUSTERW bits of the mnt_flag. The sysctl variables, vfs.foo.doclusterread and vfs.foo.doclusterwrite are deleted. Only mount option can control clustered I/O from userland. 2. When foofs_mount mounts block device, foofs_mount checks D_CLUSTERR and D_CLUSTERW bits of the d_flags member in the block device switch table. If D_NOCLUSTERR / D_NOCLUSTERW are set, MNT_NOCLUSTERR / MNT_NOCLUSTERW bits will be set. In this case, MNT_NOCLUSTERR and MNT_NOCLUSTERW cannot be cleared from userland. 3. Vnode driver disables both clustered read and write. 4. Union filesystem disables clutered write. Reviewed by: bde --- sys/gnu/ext2fs/ext2_extern.h | 13 ------------- sys/gnu/ext2fs/ext2_readwrite.c | 4 ++-- sys/gnu/ext2fs/ext2_vfsops.c | 18 ++++++++++++++++-- sys/gnu/ext2fs/ext2_vnops.c | 11 ----------- 4 files changed, 18 insertions(+), 28 deletions(-) (limited to 'sys/gnu/ext2fs') diff --git a/sys/gnu/ext2fs/ext2_extern.h b/sys/gnu/ext2fs/ext2_extern.h index 277106b..4c32799 100644 --- a/sys/gnu/ext2fs/ext2_extern.h +++ b/sys/gnu/ext2fs/ext2_extern.h @@ -42,19 +42,6 @@ #ifndef _SYS_GNU_EXT2FS_EXT2_EXTERN_H_ #define _SYS_GNU_EXT2FS_EXT2_EXTERN_H_ -/* - * Sysctl values for the ext2fs filesystem. - */ -#define EXT2FS_CLUSTERREAD 1 /* cluster reading enabled */ -#define EXT2FS_CLUSTERWRITE 2 /* cluster writing enable */ -#define EXT2FS_MAXID 3 /* number of valid ext2fs ids */ - -#define EXT2FS_NAMES {\ - {0, 0}, \ - { "doclusterread", CTLTYPE_INT }, \ - { "doculsterwrite", CTLTYPE_INT }, \ -} - struct dinode; struct ext2_inode; struct inode; diff --git a/sys/gnu/ext2fs/ext2_readwrite.c b/sys/gnu/ext2fs/ext2_readwrite.c index e28cd0a..986bc14 100644 --- a/sys/gnu/ext2fs/ext2_readwrite.c +++ b/sys/gnu/ext2fs/ext2_readwrite.c @@ -112,7 +112,7 @@ READ(ap) if (lblktosize(fs, nextlbn) >= ip->i_size) error = bread(vp, lbn, size, NOCRED, &bp); - else if (ext2_doclusterread) + else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) error = cluster_read(vp, ip->i_size, lbn, size, NOCRED, uio->uio_resid, (ap->a_ioflag >> 16), &bp); @@ -277,7 +277,7 @@ WRITE(ap) if (ioflag & IO_SYNC) { (void)bwrite(bp); } else if (xfersize + blkoffset == fs->s_frag_size) { - if (ext2_doclusterwrite) { + if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) { #if defined(__FreeBSD__) bp->b_flags |= B_CLUSTEROK; #endif diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 7aef5f6..11d1b33 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -149,6 +149,10 @@ ext2_mountroot() bzero((char *)mp, (u_long)sizeof(struct mount)); mp->mnt_op = &ext2fs_vfsops; mp->mnt_flag = MNT_RDONLY; + if (bdevsw[major(rootdev)]->d_flags & D_NOCLUSTERR) + mp->mnt_flag |= MNT_NOCLUSTERR; + if (bdevsw[major(rootdev)]->d_flags & D_NOCLUSTERW) + mp->mnt_flag |= MNT_NOCLUSTERW; if (error = ext2_mountfs(rootvp, mp, p)) { bsd_free(mp, M_MOUNT); return (error); @@ -206,11 +210,17 @@ ext2_mount(mp, path, data, ndp, p) /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. + * Disallow clearing MNT_NOCLUSTERR and MNT_NOCLUSTERW flags, + * if block device requests. */ if (mp->mnt_flag & MNT_UPDATE) { ump = VFSTOUFS(mp); fs = ump->um_e2fs; error = 0; + if (bdevsw[major(ump->um_dev)]->d_flags & D_NOCLUSTERR) + mp->mnt_flag |= MNT_NOCLUSTERR; + if (bdevsw[major(ump->um_dev)]->d_flags & D_NOCLUSTERW) + mp->mnt_flag |= MNT_NOCLUSTERW; if (fs->s_rd_only == 0 && (mp->mnt_flag & MNT_RDONLY)) { flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) @@ -255,9 +265,13 @@ ext2_mount(mp, path, data, ndp, p) vrele(devvp); return (ENXIO); } - if ((mp->mnt_flag & MNT_UPDATE) == 0) + if ((mp->mnt_flag & MNT_UPDATE) == 0) { + if (bdevsw[major(devvp->v_rdev)]->d_flags & D_NOCLUSTERR) + mp->mnt_flag |= MNT_NOCLUSTERR; + if (bdevsw[major(devvp->v_rdev)]->d_flags & D_NOCLUSTERW) + mp->mnt_flag |= MNT_NOCLUSTERW; error = ext2_mountfs(devvp, mp, p); - else { + } else { if (devvp != ump->um_devvp) error = EINVAL; /* needs translation */ else diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c index 583164b..94fe0a7 100644 --- a/sys/gnu/ext2fs/ext2_vnops.c +++ b/sys/gnu/ext2fs/ext2_vnops.c @@ -237,17 +237,6 @@ static struct vnodeopv_desc ext2fs_fifoop_opv_desc = VNODEOP_SET(ext2fs_fifoop_opv_desc); #endif -/* - * Enabling cluster read/write operations. - */ -static int ext2_doclusterread = 1; -static int ext2_doclusterwrite = 1; -SYSCTL_NODE(_vfs, MOUNT_EXT2FS, ext2fs, CTLFLAG_RW, 0, "EXT2FS filesystem"); -SYSCTL_INT(_vfs_ext2fs, EXT2FS_CLUSTERREAD, doclusterread, - CTLFLAG_RW, &ext2_doclusterread, 0, ""); -SYSCTL_INT(_vfs_ext2fs, EXT2FS_CLUSTERWRITE, doclusterwrite, - CTLFLAG_RW, &ext2_doclusterwrite, 0, ""); - #include /* -- cgit v1.1