Re: svn commit: r230252 - head/sys/fs/tmpfs
On Fri, 13 Apr 2012 09:11:39 +0300 Jaakko Heinonen wrote: JH On 2012-01-23, Mikolaj Golub wrote: I see two issues with this patch: JH What do you think about this patch? I think it is much better than we have currently :-). JH %%% JH Index: sys/fs/tmpfs/tmpfs.h JH === JH --- sys/fs/tmpfs/tmpfs.h(revision 234201) JH +++ sys/fs/tmpfs/tmpfs.h(working copy) JH @@ -387,6 +387,9 @@ struct tmpfs_mount { JH * tmpfs_pool.c. */ JH uma_zone_ttm_dirent_pool; JH uma_zone_ttm_node_pool; JH + JH +/* Read-only status. */ JH +inttm_ronly; JH }; JH #define TMPFS_LOCK(tm) mtx_lock((tm)-allnode_lock) JH #define TMPFS_UNLOCK(tm) mtx_unlock((tm)-allnode_lock) JH Index: sys/fs/tmpfs/tmpfs_vfsops.c JH === JH --- sys/fs/tmpfs/tmpfs_vfsops.c(revision 234201) JH +++ sys/fs/tmpfs/tmpfs_vfsops.c(working copy) JH @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { JH NULL JH }; JH JH +static const char *tmpfs_updateopts[] = { JH +from, export, NULL JH +}; JH + JH /* - */ JH JH static int JH @@ -150,12 +154,13 @@ tmpfs_mount(struct mount *mp) JH return (EINVAL); JH JH if (mp-mnt_flag MNT_UPDATE) { JH -/* JH - * Only support update mounts for NFS export. JH - */ JH -if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) JH -return (0); JH -return (EOPNOTSUPP); JH +/* Only support update mounts for certain options. */ JH +if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) JH +return (EOPNOTSUPP); JH +if (vfs_flagopt(mp-mnt_optnew, ro, NULL, 0) != JH +((struct tmpfs_mount *)mp-mnt_data)-tm_ronly) JH +return (EOPNOTSUPP); JH +return (0); JH } JH JH vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); JH @@ -228,6 +233,7 @@ tmpfs_mount(struct mount *mp) JH tmpfs_node_ctor, tmpfs_node_dtor, JH tmpfs_node_init, tmpfs_node_fini, JH UMA_ALIGN_PTR, 0); JH +tmp-tm_ronly = (mp-mnt_flag MNT_RDONLY) != 0; JH JH /* Allocate the root node. */ JH error = tmpfs_alloc_node(tmp, VDIR, root_uid, JH %%% JH -- JH Jaakko -- Mikolaj Golub ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On 2012-01-23, Mikolaj Golub wrote: I see two issues with this patch: What do you think about this patch? %%% Index: sys/fs/tmpfs/tmpfs.h === --- sys/fs/tmpfs/tmpfs.h(revision 234201) +++ sys/fs/tmpfs/tmpfs.h(working copy) @@ -387,6 +387,9 @@ struct tmpfs_mount { * tmpfs_pool.c. */ uma_zone_t tm_dirent_pool; uma_zone_t tm_node_pool; + + /* Read-only status. */ + int tm_ronly; }; #define TMPFS_LOCK(tm) mtx_lock((tm)-allnode_lock) #define TMPFS_UNLOCK(tm) mtx_unlock((tm)-allnode_lock) Index: sys/fs/tmpfs/tmpfs_vfsops.c === --- sys/fs/tmpfs/tmpfs_vfsops.c (revision 234201) +++ sys/fs/tmpfs/tmpfs_vfsops.c (working copy) @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { NULL }; +static const char *tmpfs_updateopts[] = { + from, export, NULL +}; + /* - */ static int @@ -150,12 +154,13 @@ tmpfs_mount(struct mount *mp) return (EINVAL); if (mp-mnt_flag MNT_UPDATE) { - /* -* Only support update mounts for NFS export. -*/ - if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) - return (0); - return (EOPNOTSUPP); + /* Only support update mounts for certain options. */ + if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) + return (EOPNOTSUPP); + if (vfs_flagopt(mp-mnt_optnew, ro, NULL, 0) != + ((struct tmpfs_mount *)mp-mnt_data)-tm_ronly) + return (EOPNOTSUPP); + return (0); } vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); @@ -228,6 +233,7 @@ tmpfs_mount(struct mount *mp) tmpfs_node_ctor, tmpfs_node_dtor, tmpfs_node_init, tmpfs_node_fini, UMA_ALIGN_PTR, 0); + tmp-tm_ronly = (mp-mnt_flag MNT_RDONLY) != 0; /* Allocate the root node. */ error = tmpfs_alloc_node(tmp, VDIR, root_uid, %%% -- Jaakko ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On Mon, Jan 23, 2012 at 11:05:42PM +0200, Mikolaj Golub wrote: On Mon, 23 Jan 2012 17:34:57 +0200 Jaakko Heinonen wrote: JH On 2012-01-22, Mikolaj Golub wrote: Also, may be we should allow remounting ro (and may be some othe options) for tmpfs? JH Yes, the patch below does that. I suspect that flipping the MNT_RDONLY JH flag may be enough for tmpfs but I am not sure. I see two issues with this patch: 1) 'mount -u -o rw /mnt' does not upgrade to rw, although it returns success. 2) if you have a file open for write, after remounting ro you still can write to the file. The expected behaviour: remount fails with EBUSY if force option is not specified; after remounting with force writing to the fail fails with EIO. I think when remounting ro you should call vflush(), something like below: flags = WRITECLOSE; if (mp-mnt_flag MNT_FORCE) flags |= FORCECLOSE; error = vflush(mp, 0, flags, curthread); if (error != 0) return (error); MNT_ILOCK(mp); mp-mnt_flag |= MNT_RDONLY; MNT_IUNLOCK(mp); and when upgrading to rw reset MNT_RDONLY flag: MNT_ILOCK(mp); mp-mnt_flag = ~MNT_RDONLY; MNT_IUNLOCK(mp); I have no idea if something else is needed for tmpfs. Yes, this is needed but not enough. Since other writeable opens may happen during the vflush(), you might still end up with the mount point which is not safe to set MNT_RDONLY flag. FFS suspends the writes on the mp while doing remount. Other filesystems like tmpfs and nfs could also perform suspend during remounts and unmounts, but the complications are the atime and deferred inactivations. See ufs/ffs/ffs_snapshot.c:process_deferred_inactive(), the handling of IN_LAZYACCESS and ufs_inactive(). pgpEFP461j04d.pgp Description: PGP signature
Re: svn commit: r230252 - head/sys/fs/tmpfs
On 2012-01-23, Mikolaj Golub wrote: JH Yes, the patch below does that. I suspect that flipping the MNT_RDONLY JH flag may be enough for tmpfs but I am not sure. I see two issues with this patch: 1) 'mount -u -o rw /mnt' does not upgrade to rw, although it returns success. Argh, this is another nmount(2) bug. The update mount code automatically sets the MNT_RDONLY flag but doesn't unset it. However the string option always gets updated causing string options and flags to get out of sync. Flags covered by MNT_UPDATEMASK are unset automatically. I think when remounting ro you should call vflush(), something like below: Right. Thanks for looking at the patch! -- Jaakko ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On 2012-01-22, Mikolaj Golub wrote: Also, may be we should allow remounting ro (and may be some othe options) for tmpfs? Yes, the patch below does that. I suspect that flipping the MNT_RDONLY flag may be enough for tmpfs but I am not sure. JH %%% JH Index: sys/fs/tmpfs/tmpfs_vfsops.c JH === JH --- sys/fs/tmpfs/tmpfs_vfsops.c(revision 230328) JH +++ sys/fs/tmpfs/tmpfs_vfsops.c(working copy) JH @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { JH NULL JH }; JH JH +static const char *tmpfs_updateopts[] = { JH +from, export, NULL JH +}; JH + JH /* - */ JH JH static int JH @@ -150,12 +154,10 @@ tmpfs_mount(struct mount *mp) JH return (EINVAL); JH JH if (mp-mnt_flag MNT_UPDATE) { JH -/* JH - * Only support update mounts for NFS export. JH - */ JH -if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) JH -return (0); JH -return (EOPNOTSUPP); JH +/* Only support update mounts for certain options. */ JH +if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) JH +return (EOPNOTSUPP); JH +return (0); JH } JH JH vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); JH %%% -- Jaakko ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On Mon, 23 Jan 2012 17:34:57 +0200 Jaakko Heinonen wrote: JH On 2012-01-22, Mikolaj Golub wrote: Also, may be we should allow remounting ro (and may be some othe options) for tmpfs? JH Yes, the patch below does that. I suspect that flipping the MNT_RDONLY JH flag may be enough for tmpfs but I am not sure. I see two issues with this patch: 1) 'mount -u -o rw /mnt' does not upgrade to rw, although it returns success. 2) if you have a file open for write, after remounting ro you still can write to the file. The expected behaviour: remount fails with EBUSY if force option is not specified; after remounting with force writing to the fail fails with EIO. I think when remounting ro you should call vflush(), something like below: flags = WRITECLOSE; if (mp-mnt_flag MNT_FORCE) flags |= FORCECLOSE; error = vflush(mp, 0, flags, curthread); if (error != 0) return (error); MNT_ILOCK(mp); mp-mnt_flag |= MNT_RDONLY; MNT_IUNLOCK(mp); and when upgrading to rw reset MNT_RDONLY flag: MNT_ILOCK(mp); mp-mnt_flag = ~MNT_RDONLY; MNT_IUNLOCK(mp); I have no idea if something else is needed for tmpfs. JH %%% JH Index: sys/fs/tmpfs/tmpfs_vfsops.c JH === JH --- sys/fs/tmpfs/tmpfs_vfsops.c(revision 230328) JH +++ sys/fs/tmpfs/tmpfs_vfsops.c(working copy) JH @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { JH NULL JH }; JH JH +static const char *tmpfs_updateopts[] = { JH +from, export, NULL JH +}; JH + JH /* - */ JH JH static int JH @@ -150,12 +154,10 @@ tmpfs_mount(struct mount *mp) JH return (EINVAL); JH JH if (mp-mnt_flag MNT_UPDATE) { JH -/* JH - * Only support update mounts for NFS export. JH - */ JH -if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) JH -return (0); JH -return (EOPNOTSUPP); JH +/* Only support update mounts for certain options. */ JH +if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) JH +return (EOPNOTSUPP); JH +return (0); JH } JH JH vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); JH %%% JH -- JH Jaakko -- Mikolaj Golub ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On Tue, 17 Jan 2012 19:10:31 +0200 Jaakko Heinonen wrote: JH On 2012-01-17, Kevin Lo wrote: Return EOPNOTSUPP since we only support update mounts for NFS export. @@ -150,8 +150,12 @@ tmpfs_mount(struct mount *mp) return (EINVAL); if (mp-mnt_flag MNT_UPDATE) { +/* + * Only support update mounts for NFS export. + */ if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) return (0); +return (EOPNOTSUPP); } JH This doesn't look correct. As long as the option list includes the JH export option, all options are accepted. An example: JH # mount -u -o ro /mnt JH mount: tmpfs : Operation not supported JH # mount -u -o ro,export /mnt JH # There is no error but ro is still ignored, so this is only the issue with reporting. Note, the code for nullfs (as an example) looks the same. It could be fixed with vfs_filteropt(9), not sure if this is worth doing here though. -- Mikolaj Golub ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
Hi, On 2012-01-22, Mikolaj Golub wrote: JH # mount -u -o ro /mnt JH mount: tmpfs : Operation not supported JH # mount -u -o ro,export /mnt JH # There is no error but ro is still ignored, so this is only the issue with reporting. Note, the code for nullfs (as an example) looks the same. This is not true. ro is not ignored: # mount -t tmpfs tmpfs on /mnt (tmpfs, local) # mount -u -o ro /mnt mount: tmpfs: Operation not supported # mount -t tmpfs tmpfs on /mnt (tmpfs, local) # mount -u -o ro,export /mnt # mount -t tmpfs tmpfs on /mnt (tmpfs, local, read-only) It could be fixed with vfs_filteropt(9), not sure if this is worth doing here though. The problem with vfs_filteropt(9) is that it will allow some additional options (global_opts list in vfs_mount.c). However those options might already work sufficiently with update mount. Here is a mostly untested patch: %%% Index: sys/fs/tmpfs/tmpfs_vfsops.c === --- sys/fs/tmpfs/tmpfs_vfsops.c (revision 230328) +++ sys/fs/tmpfs/tmpfs_vfsops.c (working copy) @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { NULL }; +static const char *tmpfs_updateopts[] = { + from, export, NULL +}; + /* - */ static int @@ -150,12 +154,10 @@ tmpfs_mount(struct mount *mp) return (EINVAL); if (mp-mnt_flag MNT_UPDATE) { - /* -* Only support update mounts for NFS export. -*/ - if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) - return (0); - return (EOPNOTSUPP); + /* Only support update mounts for certain options. */ + if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) + return (EOPNOTSUPP); + return (0); } vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); %%% -- Jaakko ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
Jaakko Heinonen wrote: Hi, Hi Jaakko, On 2012-01-22, Mikolaj Golub wrote: JH # mount -u -o ro /mnt JH mount: tmpfs : Operation not supported JH # mount -u -o ro,export /mnt JH # There is no error but ro is still ignored, so this is only the issue with reporting. Note, the code for nullfs (as an example) looks the same. This is not true. ro is not ignored: # mount -t tmpfs tmpfs on /mnt (tmpfs, local) # mount -u -o ro /mnt mount: tmpfs: Operation not supported # mount -t tmpfs tmpfs on /mnt (tmpfs, local) # mount -u -o ro,export /mnt # mount -t tmpfs tmpfs on /mnt (tmpfs, local, read-only) It could be fixed with vfs_filteropt(9), not sure if this is worth doing here though. The problem with vfs_filteropt(9) is that it will allow some additional options (global_opts list in vfs_mount.c). However those options might already work sufficiently with update mount. Here is a mostly untested patch: %%% Index: sys/fs/tmpfs/tmpfs_vfsops.c === --- sys/fs/tmpfs/tmpfs_vfsops.c (revision 230328) +++ sys/fs/tmpfs/tmpfs_vfsops.c (working copy) @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { NULL }; +static const char *tmpfs_updateopts[] = { + from, export, NULL +}; + /* - */ static int @@ -150,12 +154,10 @@ tmpfs_mount(struct mount *mp) return (EINVAL); if (mp-mnt_flag MNT_UPDATE) { - /* - * Only support update mounts for NFS export. - */ - if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) - return (0); - return (EOPNOTSUPP); + /* Only support update mounts for certain options. */ + if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) + return (EOPNOTSUPP); + return (0); } vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); %%% Sorry for the late reply since I'm still off work for holidays (Chinese New Year). I'll report back in a few weeks. If you have a patch, please commit it, thanks a lot! Kevin ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On Sun, 22 Jan 2012 15:42:18 +0200 Jaakko Heinonen wrote: JH Hi, JH On 2012-01-22, Mikolaj Golub wrote: JH # mount -u -o ro /mnt JH mount: tmpfs : Operation not supported JH # mount -u -o ro,export /mnt JH # There is no error but ro is still ignored, so this is only the issue with reporting. Note, the code for nullfs (as an example) looks the same. JH This is not true. ro is not ignored: JH # mount -t tmpfs JH tmpfs on /mnt (tmpfs, local) JH # mount -u -o ro /mnt JH mount: tmpfs: Operation not supported JH # mount -t tmpfs JH tmpfs on /mnt (tmpfs, local) JH # mount -u -o ro,export /mnt JH # mount -t tmpfs JH tmpfs on /mnt (tmpfs, local, read-only) Sorry, yes I was wrong. vfs_domount_update() stores old MNT flags and applies new ones, then calls VFS_MOUNT(), and if it only fails it will restore the old flags. So nullfs has the same issue now although the bug is more difficult to expose as nullfs uses its own mount_nullfs, which currently does not support update option. Thus to trigger the bug someone has to use nmount(2). It could be fixed with vfs_filteropt(9), not sure if this is worth doing here though. JH The problem with vfs_filteropt(9) is that it will allow some additional JH options (global_opts list in vfs_mount.c). However those options might JH already work sufficiently with update mount. Here is a mostly untested JH patch: When I was looking at mount option interface it also looked for me a bit complicated :-), that is why I hoped we could just ignore the issue if it were just reporting an error... Also, may be we should allow remounting ro (and may be some othe options) for tmpfs? JH %%% JH Index: sys/fs/tmpfs/tmpfs_vfsops.c JH === JH --- sys/fs/tmpfs/tmpfs_vfsops.c(revision 230328) JH +++ sys/fs/tmpfs/tmpfs_vfsops.c(working copy) JH @@ -82,6 +82,10 @@ static const char *tmpfs_opts[] = { JH NULL JH }; JH JH +static const char *tmpfs_updateopts[] = { JH +from, export, NULL JH +}; JH + JH /* - */ JH JH static int JH @@ -150,12 +154,10 @@ tmpfs_mount(struct mount *mp) JH return (EINVAL); JH JH if (mp-mnt_flag MNT_UPDATE) { JH -/* JH - * Only support update mounts for NFS export. JH - */ JH -if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) JH -return (0); JH -return (EOPNOTSUPP); JH +/* Only support update mounts for certain options. */ JH +if (vfs_filteropt(mp-mnt_optnew, tmpfs_updateopts) != 0) JH +return (EOPNOTSUPP); JH +return (0); JH } JH JH vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); JH %%% JH -- JH Jaakko -- Mikolaj Golub ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r230252 - head/sys/fs/tmpfs
On 2012-01-17, Kevin Lo wrote: Return EOPNOTSUPP since we only support update mounts for NFS export. @@ -150,8 +150,12 @@ tmpfs_mount(struct mount *mp) return (EINVAL); if (mp-mnt_flag MNT_UPDATE) { + /* + * Only support update mounts for NFS export. + */ if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) return (0); + return (EOPNOTSUPP); } This doesn't look correct. As long as the option list includes the export option, all options are accepted. An example: # mount -u -o ro /mnt mount: tmpfs : Operation not supported # mount -u -o ro,export /mnt # -- Jaakko ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r230252 - head/sys/fs/tmpfs
Author: kevlo Date: Tue Jan 17 01:25:53 2012 New Revision: 230252 URL: http://svn.freebsd.org/changeset/base/230252 Log: Return EOPNOTSUPP since we only support update mounts for NFS export. Spotted by: trociny Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c == --- head/sys/fs/tmpfs/tmpfs_vfsops.cTue Jan 17 01:18:40 2012 (r230251) +++ head/sys/fs/tmpfs/tmpfs_vfsops.cTue Jan 17 01:25:53 2012 (r230252) @@ -150,8 +150,12 @@ tmpfs_mount(struct mount *mp) return (EINVAL); if (mp-mnt_flag MNT_UPDATE) { + /* +* Only support update mounts for NFS export. +*/ if (vfs_flagopt(mp-mnt_optnew, export, NULL, 0)) return (0); + return (EOPNOTSUPP); } vn_lock(mp-mnt_vnodecovered, LK_SHARED | LK_RETRY); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org