Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7]: src/sys/fs/tmpfs Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/e972ca0f6f71
branches:  netbsd-7
changeset: 799898:e972ca0f6f71
user:      snj <snj%NetBSD.org@localhost>
date:      Mon May 09 19:45:00 2016 +0000

description:
Pull up following revision(s) (requested by joerg in ticket #1163):
        sys/fs/tmpfs/tmpfs_vfsops.c: revision 1.66, 1.67
        sys/fs/tmpfs/tmpfs_vnops.c: revision 1.124
Only recheck size/node limits on update mounts, if there actually have
been specified.
--
Implement most of mount -ur functionality for tmpfs. Remaining issue is
the question who is responsible for syncing pending writes, but the
functionality is good enough for serving as read-only chroot base in
bulk builds.

diffstat:

 sys/fs/tmpfs/tmpfs_vfsops.c |  23 ++++++++++++++++-------
 sys/fs/tmpfs/tmpfs_vnops.c  |  14 ++++++++++++--
 2 files changed, 28 insertions(+), 9 deletions(-)

diffs (116 lines):

diff -r 903f58fbd5ec -r e972ca0f6f71 sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c       Mon May 09 19:40:44 2016 +0000
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c       Mon May 09 19:45:00 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $ */
+/*     $NetBSD: tmpfs_vfsops.c,v 1.63.2.1 2016/05/09 19:45:00 snj Exp $        */
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.63.2.1 2016/05/09 19:45:00 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -102,6 +102,8 @@
        uint64_t memlimit;
        ino_t nodes;
        int error;
+       bool set_memlimit;
+       bool set_nodes;
 
        if (args == NULL)
                return EINVAL;
@@ -146,26 +148,33 @@
        /* Get the memory usage limit for this file-system. */
        if (args->ta_size_max < PAGE_SIZE) {
                memlimit = UINT64_MAX;
+               set_memlimit = false;
        } else {
                memlimit = args->ta_size_max;
+               set_memlimit = true;
        }
        KASSERT(memlimit > 0);
 
        if (args->ta_nodes_max <= 3) {
                nodes = 3 + (memlimit / 1024);
+               set_nodes = false;
        } else {
                nodes = args->ta_nodes_max;
+               set_nodes = true;
        }
        nodes = MIN(nodes, INT_MAX);
        KASSERT(nodes >= 3);
 
        if (mp->mnt_flag & MNT_UPDATE) {
                tmp = VFS_TO_TMPFS(mp);
-               if (nodes < tmp->tm_nodes_cnt)
+               if (set_nodes && nodes < tmp->tm_nodes_cnt)
                        return EBUSY;
-               if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
-                       return error;
-               tmp->tm_nodes_max = nodes;
+               if (set_memlimit) {
+                       if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
+                               return error;
+               }
+               if (set_nodes)
+                       tmp->tm_nodes_max = nodes;
                root = tmp->tm_root;
                root->tn_uid = args->ta_root_uid;
                root->tn_gid = args->ta_root_gid;
@@ -205,7 +214,7 @@
        mp->mnt_stat.f_namemax = TMPFS_MAXNAMLEN;
        mp->mnt_fs_bshift = PAGE_SHIFT;
        mp->mnt_dev_bshift = DEV_BSHIFT;
-       mp->mnt_iflag |= IMNT_MPSAFE;
+       mp->mnt_iflag |= IMNT_MPSAFE | IMNT_CAN_RWTORO;
        vfs_getnewfsid(mp);
 
        error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
diff -r 903f58fbd5ec -r e972ca0f6f71 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Mon May 09 19:40:44 2016 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Mon May 09 19:45:00 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vnops.c,v 1.120.2.1 2014/12/22 02:05:08 msaitoh Exp $    */
+/*     $NetBSD: tmpfs_vnops.c,v 1.120.2.2 2016/05/09 19:45:00 snj Exp $        */
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120.2.1 2014/12/22 02:05:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120.2.2 2016/05/09 19:45:00 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -589,6 +589,11 @@
 
        KASSERT(VOP_ISLOCKED(vp));
 
+       if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
+               error = EROFS;
+               goto out;
+       }
+
        node = VP_TO_TMPFS_NODE(vp);
        oldsize = node->tn_size;
 
@@ -1267,6 +1272,11 @@
                return 0;
        }
 
+       if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) {
+               mutex_exit(vp->v_interlock);
+               return EROFS;
+       }
+
        node = VP_TO_TMPFS_NODE(vp);
        uobj = node->tn_spec.tn_reg.tn_aobj;
 



Home | Main Index | Thread Index | Old Index