Module Name: src Committed By: christos Date: Wed Apr 30 01:33:51 UTC 2014
Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_mem.c tmpfs_vfsops.c Log Message: handle MNT_UPDATE To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.4 -r1.5 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.59 -r1.60 src/sys/fs/tmpfs/tmpfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/tmpfs/tmpfs.h diff -u src/sys/fs/tmpfs/tmpfs.h:1.48 src/sys/fs/tmpfs/tmpfs.h:1.49 --- src/sys/fs/tmpfs/tmpfs.h:1.48 Sat Nov 23 11:35:32 2013 +++ src/sys/fs/tmpfs/tmpfs.h Tue Apr 29 21:33:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.48 2013/11/23 16:35:32 rmind Exp $ */ +/* $NetBSD: tmpfs.h,v 1.49 2014/04/30 01:33:51 christos Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -279,6 +279,7 @@ void tmpfs_update(vnode_t *, unsigned); void tmpfs_mntmem_init(tmpfs_mount_t *, uint64_t); void tmpfs_mntmem_destroy(tmpfs_mount_t *); +int tmpfs_mntmem_set(tmpfs_mount_t *, uint64_t); size_t tmpfs_mem_info(bool); uint64_t tmpfs_bytes_max(tmpfs_mount_t *); Index: src/sys/fs/tmpfs/tmpfs_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.4 src/sys/fs/tmpfs/tmpfs_mem.c:1.5 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.4 Mon May 23 21:09:47 2011 +++ src/sys/fs/tmpfs/tmpfs_mem.c Tue Apr 29 21:33:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.4 2011/05/24 01:09:47 rmind Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $ */ /* * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.4 2011/05/24 01:09:47 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -65,6 +65,24 @@ tmpfs_mntmem_destroy(struct tmpfs_mount mutex_destroy(&mp->tm_acc_lock); } +int +tmpfs_mntmem_set(struct tmpfs_mount *mp, uint64_t memlimit) +{ + int error; + + mutex_enter(&mp->tm_acc_lock); + if (round_page(mp->tm_bytes_used) >= memlimit) + error = EBUSY; + else { + error = 0; + mp->tm_mem_limit = memlimit; + } + mutex_exit(&mp->tm_acc_lock); + return error; +} + + + /* * tmpfs_mem_info: return the number of available memory pages. * Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.59 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.60 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.59 Wed Apr 16 14:55:19 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Tue Apr 29 21:33:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.59 2014/04/16 18:55:19 maxv Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.60 2014/04/30 01:33:51 christos 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.59 2014/04/16 18:55:19 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.60 2014/04/30 01:33:51 christos Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -130,10 +130,6 @@ tmpfs_mount(struct mount *mp, const char return 0; } - if (mp->mnt_flag & MNT_UPDATE) { - /* TODO */ - return EOPNOTSUPP; - } /* Prohibit mounts if there is not enough memory. */ if (tmpfs_mem_info(true) < TMPFS_PAGES_RESERVED) @@ -155,6 +151,20 @@ tmpfs_mount(struct mount *mp, const char 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) + return EBUSY; + if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0) + return error; + tmp->tm_nodes_max = nodes; + root = tmp->tm_rooto + root->tn_uid = args->ta_root_uid; + root->tn_gid = args->ta_root_gid; + root->tn_mode = args->ta_root_mode; + return 0; + } + /* Allocate the tmpfs mount structure and fill it. */ tmp = kmem_zalloc(sizeof(tmpfs_mount_t), KM_SLEEP); if (tmp == NULL)