Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/tmpfs Run vflush() when going from read/write to read...



details:   https://anonhg.NetBSD.org/src/rev/09e2df69ba72
branches:  trunk
changeset: 350930:09e2df69ba72
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Jan 27 10:47:54 2017 +0000

description:
Run vflush() when going from read/write to read only.

diffstat:

 sys/fs/tmpfs/tmpfs.h        |   5 ++++-
 sys/fs/tmpfs/tmpfs_vfsops.c |  22 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (76 lines):

diff -r 817e72b04d82 -r 09e2df69ba72 sys/fs/tmpfs/tmpfs.h
--- a/sys/fs/tmpfs/tmpfs.h      Fri Jan 27 10:47:13 2017 +0000
+++ b/sys/fs/tmpfs/tmpfs.h      Fri Jan 27 10:47:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs.h,v 1.52 2015/07/06 10:07:12 hannken Exp $       */
+/*     $NetBSD: tmpfs.h,v 1.53 2017/01/27 10:47:54 hannken Exp $       */
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -217,6 +217,9 @@
        uint64_t                tm_bytes_used;
        kmutex_t                tm_acc_lock;
 
+       /* Read-only indicator. */
+       bool                    tm_rdonly;
+
        /* Pointer to the root inode. */
        tmpfs_node_t *          tm_root;
 
diff -r 817e72b04d82 -r 09e2df69ba72 sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c       Fri Jan 27 10:47:13 2017 +0000
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c       Fri Jan 27 10:47:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland Exp $       */
+/*     $NetBSD: tmpfs_vfsops.c,v 1.69 2017/01/27 10:47:54 hannken 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.68 2016/08/26 21:44:24 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.69 2017/01/27 10:47:54 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -92,7 +92,7 @@
        struct vnode *vp;
        uint64_t memlimit;
        ino_t nodes;
-       int error;
+       int error, flags;
        bool set_memlimit;
        bool set_nodes;
 
@@ -160,6 +160,20 @@
                tmp = VFS_TO_TMPFS(mp);
                if (set_nodes && nodes < tmp->tm_nodes_cnt)
                        return EBUSY;
+               if (!tmp->tm_rdonly && (mp->mnt_flag & MNT_RDONLY)) {
+                       /* Changing from read/write to read-only. */
+                       flags = WRITECLOSE;
+                       if ((mp->mnt_flag & MNT_FORCE))
+                               flags |= FORCECLOSE;
+                       error = vflush(mp, NULL, flags);
+                       if (error)
+                               return error;
+                       tmp->tm_rdonly = true;
+               }
+               if (tmp->tm_rdonly && (mp->mnt_flag & IMNT_WANTRDWR)) {
+                       /* Changing from read-only to read/write. */
+                       tmp->tm_rdonly = false;
+               }
                if (set_memlimit) {
                        if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
                                return error;
@@ -178,6 +192,8 @@
        if (tmp == NULL)
                return ENOMEM;
 
+       if ((mp->mnt_flag & MNT_RDONLY))
+               tmp->tm_rdonly = true;
        tmp->tm_nodes_max = nodes;
        tmp->tm_nodes_cnt = 0;
        LIST_INIT(&tmp->tm_nodes);



Home | Main Index | Thread Index | Old Index