Source-Changes-HG archive

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

[src/trunk]: src Initial addition of tmpfs, an efficient memory file-system. ...



details:   https://anonhg.NetBSD.org/src/rev/ccea4dd82566
branches:  trunk
changeset: 584175:ccea4dd82566
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Sat Sep 10 19:20:48 2005 +0000

description:
Initial addition of tmpfs, an efficient memory file-system.  This project
was developed as part of Google's Summer of Code 2005 program.  This
change adds the kernel code, the mount_tmpfs utility, a regression test
suite and does all other related changes to integrate these.

The file-system is still *experimental*.  Therefore, it is disabled by
default in all kernels.  However, as typically done, a commented-out
entry is added in them to ease its setup.

Note that I haven't commited the required mountd(8) changes to be able
to export tmpfs file-systems because NFS support is still very unstable
and because, before enabling it, I'd like to do some other changes.

OK'ed by my project mentor, William Studenmund (wrstuden@).

diffstat:

 distrib/sets/lists/base/mi           |     3 +-
 distrib/sets/lists/comp/mi           |     4 +-
 distrib/sets/lists/man/mi            |     4 +-
 doc/CHANGES                          |     4 +-
 regress/sys/fs/Makefile              |     4 +-
 regress/sys/fs/tmpfs/Makefile        |    38 +
 regress/sys/fs/tmpfs/h_funcs.subr    |   160 +++
 regress/sys/fs/tmpfs/h_tools.c       |   173 ++++
 regress/sys/fs/tmpfs/t_create        |    90 ++
 regress/sys/fs/tmpfs/t_devices       |    67 +
 regress/sys/fs/tmpfs/t_dots          |    60 +
 regress/sys/fs/tmpfs/t_exec          |    59 +
 regress/sys/fs/tmpfs/t_id_gen        |    70 +
 regress/sys/fs/tmpfs/t_link          |    87 ++
 regress/sys/fs/tmpfs/t_mkdir         |    96 ++
 regress/sys/fs/tmpfs/t_mknod         |    69 +
 regress/sys/fs/tmpfs/t_mount         |    69 +
 regress/sys/fs/tmpfs/t_pipes         |    59 +
 regress/sys/fs/tmpfs/t_read_write    |    65 +
 regress/sys/fs/tmpfs/t_readdir       |    86 ++
 regress/sys/fs/tmpfs/t_remove        |    65 +
 regress/sys/fs/tmpfs/t_rename        |   110 ++
 regress/sys/fs/tmpfs/t_rmdir         |    90 ++
 regress/sys/fs/tmpfs/t_setattr       |    87 ++
 regress/sys/fs/tmpfs/t_sizes         |    87 ++
 regress/sys/fs/tmpfs/t_sockets       |    54 +
 regress/sys/fs/tmpfs/t_statvfs       |    59 +
 regress/sys/fs/tmpfs/t_symlink       |    68 +
 regress/sys/fs/tmpfs/t_times         |    97 ++
 regress/sys/fs/tmpfs/t_trail_slash   |    58 +
 regress/sys/fs/tmpfs/t_truncate      |    61 +
 regress/sys/fs/tmpfs/t_vnode_leak    |    57 +
 sbin/Makefile                        |     3 +-
 sbin/mount_tmpfs/Makefile            |    14 +
 sbin/mount_tmpfs/mount_tmpfs.8       |   107 ++
 sbin/mount_tmpfs/mount_tmpfs.c       |   376 ++++++++
 share/man/man9/Makefile              |     4 +-
 share/man/man9/tmpfs.9               |   905 +++++++++++++++++++++
 sys/arch/acorn26/conf/GENERIC        |     3 +-
 sys/arch/acorn32/conf/GENERIC        |     5 +-
 sys/arch/alpha/conf/GENERIC          |     3 +-
 sys/arch/amd64/conf/GENERIC          |     5 +-
 sys/arch/amiga/conf/GENERIC          |     5 +-
 sys/arch/arc/conf/GENERIC            |     5 +-
 sys/arch/bebox/conf/GENERIC          |     5 +-
 sys/arch/cats/conf/GENERIC           |     3 +-
 sys/arch/cesfic/conf/GENERIC         |     3 +-
 sys/arch/cobalt/conf/GENERIC         |     5 +-
 sys/arch/dreamcast/conf/GENERIC      |     3 +-
 sys/arch/hp300/conf/GENERIC          |     5 +-
 sys/arch/hp700/conf/GENERIC          |     5 +-
 sys/arch/hpcmips/conf/GENERIC        |     5 +-
 sys/arch/hpcsh/conf/GENERIC          |     3 +-
 sys/arch/i386/conf/DISKLESS          |     3 +-
 sys/arch/i386/conf/GENERIC           |     5 +-
 sys/arch/i386/conf/GENERIC.MPACPI    |     5 +-
 sys/arch/i386/conf/GENERIC_LAPTOP    |     5 +-
 sys/arch/i386/conf/GENERIC_TINY      |     3 +-
 sys/arch/i386/conf/INSTALL           |     3 +-
 sys/arch/i386/conf/INSTALL_LAPTOP    |     3 +-
 sys/arch/i386/conf/INSTALL_SMALL     |     3 +-
 sys/arch/i386/conf/INSTALL_TINY      |     3 +-
 sys/arch/i386/conf/INSTALL_XENU      |     3 +-
 sys/arch/i386/conf/IOPENER           |     5 +-
 sys/arch/i386/conf/LAMB              |     3 +-
 sys/arch/i386/conf/NET4501           |     5 +-
 sys/arch/i386/conf/SWINGER           |     5 +-
 sys/arch/i386/conf/VIRTUALPC         |     5 +-
 sys/arch/i386/conf/XEN0              |     3 +-
 sys/arch/i386/conf/XENU              |     3 +-
 sys/arch/ibmnws/conf/GENERIC         |     3 +-
 sys/arch/iyonix/conf/GENERIC         |     3 +-
 sys/arch/luna68k/conf/GENERIC        |     5 +-
 sys/arch/mac68k/conf/GENERIC         |     5 +-
 sys/arch/macppc/conf/GENERIC         |     5 +-
 sys/arch/mipsco/conf/GENERIC         |     3 +-
 sys/arch/mmeye/conf/GENERIC          |     5 +-
 sys/arch/mvme68k/conf/GENERIC        |     5 +-
 sys/arch/netwinder/conf/GENERIC      |     3 +-
 sys/arch/news68k/conf/GENERIC        |     5 +-
 sys/arch/newsmips/conf/GENERIC       |     5 +-
 sys/arch/next68k/conf/GENERIC        |     5 +-
 sys/arch/ofppc/conf/GENERIC          |     5 +-
 sys/arch/pc532/conf/GENERIC          |     5 +-
 sys/arch/pdp10/conf/GENERIC          |     5 +-
 sys/arch/pmax/conf/GENERIC           |     5 +-
 sys/arch/prep/conf/GENERIC           |     5 +-
 sys/arch/sbmips/conf/GENERIC         |     5 +-
 sys/arch/shark/conf/GENERIC          |     5 +-
 sys/arch/sparc/conf/GENERIC          |     5 +-
 sys/arch/sun2/conf/GENERIC           |     5 +-
 sys/arch/sun3/conf/GENERIC           |     5 +-
 sys/arch/vax/conf/GENERIC            |     5 +-
 sys/arch/x68k/conf/GENERIC           |     5 +-
 sys/compat/linux/common/linux_misc.c |     7 +-
 sys/conf/files                       |     3 +-
 sys/fs/Makefile                      |     4 +-
 sys/fs/tmpfs/files.tmpfs             |    10 +
 sys/fs/tmpfs/tmpfs.h                 |   349 ++++++++
 sys/fs/tmpfs/tmpfs_fifoops.c         |   148 +++
 sys/fs/tmpfs/tmpfs_fifoops.h         |   107 ++
 sys/fs/tmpfs/tmpfs_pool.c            |   210 ++++
 sys/fs/tmpfs/tmpfs_pool.h            |    99 ++
 sys/fs/tmpfs/tmpfs_specops.c         |   149 +++
 sys/fs/tmpfs/tmpfs_specops.h         |   107 ++
 sys/fs/tmpfs/tmpfs_subr.c            |  1115 ++++++++++++++++++++++++++
 sys/fs/tmpfs/tmpfs_vfsops.c          |   491 +++++++++++
 sys/fs/tmpfs/tmpfs_vnops.c           |  1435 ++++++++++++++++++++++++++++++++++
 sys/fs/tmpfs/tmpfs_vnops.h           |   106 ++
 sys/sys/mount.h                      |     3 +-
 sys/sys/vnode.h                      |     8 +-
 usr.bin/pmap/pmap.c                  |     5 +-
 112 files changed, 8052 insertions(+), 113 deletions(-)

diffs (truncated from 9573 to 300 lines):

diff -r 959f5f0a40ec -r ccea4dd82566 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Sat Sep 10 19:15:44 2005 +0000
+++ b/distrib/sets/lists/base/mi        Sat Sep 10 19:20:48 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.569 2005/08/29 18:59:12 kleink Exp $
+# $NetBSD: mi,v 1.570 2005/09/10 19:20:48 jmmv Exp $
 .                                              base-sys-root
 ./altroot                                      base-sys-root
 ./bin                                          base-sys-root
@@ -159,6 +159,7 @@
 ./sbin/mount_procfs                            base-sysutil-root
 ./sbin/mount_ptyfs                             base-miscfs-root
 ./sbin/mount_smbfs                             base-smbfs-root
+./sbin/mount_tmpfs                             base-miscfs-root
 ./sbin/mount_ufs                               base-sysutil-root
 ./sbin/mount_umap                              base-miscfs-root
 ./sbin/mount_union                             base-miscfs-root
diff -r 959f5f0a40ec -r ccea4dd82566 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Sat Sep 10 19:15:44 2005 +0000
+++ b/distrib/sets/lists/comp/mi        Sat Sep 10 19:20:48 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.811 2005/08/29 05:40:17 taca Exp $
+#      $NetBSD: mi,v 1.812 2005/09/10 19:20:48 jmmv Exp $
 ./etc/mtree/set.comp                           comp-sys-root
 ./usr/bin/addr2line                            comp-debug-bin          bfd
 ./usr/bin/ar                                   comp-util-bin           bfd
@@ -5637,6 +5637,7 @@
 ./usr/share/man/cat9/tc_wmb.0                  comp-sys-catman         .cat
 ./usr/share/man/cat9/time.0                    comp-sys-catman         .cat
 ./usr/share/man/cat9/timeout.0                 comp-sys-catman         .cat
+./usr/share/man/cat9/tmpfs.0                   comp-sys-catman         .cat
 ./usr/share/man/cat9/todr.0                    comp-sys-catman         .cat
 ./usr/share/man/cat9/todr_getcal.0             comp-sys-catman         .cat
 ./usr/share/man/cat9/todr_gettime.0            comp-sys-catman         .cat
@@ -9540,6 +9541,7 @@
 ./usr/share/man/man9/tc_wmb.9                  comp-sys-man            .man
 ./usr/share/man/man9/time.9                    comp-sys-man            .man
 ./usr/share/man/man9/timeout.9                 comp-sys-man            .man
+./usr/share/man/man9/tmpfs.9                   comp-sys-man            .man
 ./usr/share/man/man9/todr.9                    comp-sys-man            .man
 ./usr/share/man/man9/todr_getcal.9             comp-sys-man            .man
 ./usr/share/man/man9/todr_gettime.9            comp-sys-man            .man
diff -r 959f5f0a40ec -r ccea4dd82566 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sat Sep 10 19:15:44 2005 +0000
+++ b/distrib/sets/lists/man/mi Sat Sep 10 19:20:48 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.821 2005/09/10 10:35:25 jmmv Exp $
+# $NetBSD: mi,v 1.822 2005/09/10 19:20:48 jmmv Exp $
 ./etc/mtree/set.man                            man-sys-root
 ./usr/share/info/am-utils.info                 man-amd-info            info
 ./usr/share/info/as.info                       man-computil-info       bfd,info
@@ -1943,6 +1943,7 @@
 ./usr/share/man/cat8/mount_procfs.0            man-sysutil-catman      .cat
 ./usr/share/man/cat8/mount_ptyfs.0             man-sysutil-catman      .cat
 ./usr/share/man/cat8/mount_smbfs.0             man-smbfs-catman        .cat
+./usr/share/man/cat8/mount_tmpfs.0             man-sysutil-catman      .cat
 ./usr/share/man/cat8/mount_ufs.0               man-sysutil-catman      .cat
 ./usr/share/man/cat8/mount_umap.0              man-miscfs-catman       .cat
 ./usr/share/man/cat8/mount_union.0             man-miscfs-catman       .cat
@@ -4209,6 +4210,7 @@
 ./usr/share/man/man8/mount_procfs.8            man-sysutil-man         .man
 ./usr/share/man/man8/mount_ptyfs.8             man-miscfs-man          .man
 ./usr/share/man/man8/mount_smbfs.8             man-smbfs-man           .man
+./usr/share/man/man8/mount_tmpfs.8             man-sysutil-man         .man
 ./usr/share/man/man8/mount_ufs.8               man-sysutil-man         .man
 ./usr/share/man/man8/mount_umap.8              man-miscfs-man          .man
 ./usr/share/man/man8/mount_union.8             man-miscfs-man          .man
diff -r 959f5f0a40ec -r ccea4dd82566 doc/CHANGES
--- a/doc/CHANGES       Sat Sep 10 19:15:44 2005 +0000
+++ b/doc/CHANGES       Sat Sep 10 19:20:48 2005 +0000
@@ -1,4 +1,4 @@
-LIST OF CHANGES FROM LAST RELEASE:                     <$Revision: 1.517 $>
+LIST OF CHANGES FROM LAST RELEASE:                     <$Revision: 1.518 $>
 
 
 [Note: This file does not mention every change made to the NetBSD source tree.
@@ -97,3 +97,5 @@
                GENERIC_LAPTOP and XEN0 kernels. [rpaulo 20050909]
        amd64: WSDISPLAY_SCROLLSUPPORT enabled in GENERIC kernel.
                [rpaulo 20050909]
+       kernel: Add tmpfs file-system. [jmmv 20050910]
+       mount_tmpfs(8): Add utility to mount a tmpfs file-system.
diff -r 959f5f0a40ec -r ccea4dd82566 regress/sys/fs/Makefile
--- a/regress/sys/fs/Makefile   Sat Sep 10 19:15:44 2005 +0000
+++ b/regress/sys/fs/Makefile   Sat Sep 10 19:20:48 2005 +0000
@@ -1,5 +1,5 @@
-#      $NetBSD: Makefile,v 1.3 2004/10/03 12:35:15 yamt Exp $
+#      $NetBSD: Makefile,v 1.4 2005/09/10 19:20:48 jmmv Exp $
 
-SUBDIR= mkdir getdents
+SUBDIR= mkdir getdents tmpfs
 
 .include <bsd.subdir.mk>
diff -r 959f5f0a40ec -r ccea4dd82566 regress/sys/fs/tmpfs/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/sys/fs/tmpfs/Makefile     Sat Sep 10 19:20:48 2005 +0000
@@ -0,0 +1,38 @@
+#      $NetBSD: Makefile,v 1.1 2005/09/10 19:20:51 jmmv Exp $
+
+tests= t_mount
+tests+=        t_statvfs
+tests+=        t_mkdir
+tests+=        t_vnode_leak
+tests+=        t_setattr
+tests+=        t_rmdir
+tests+=        t_id_gen
+tests+=        t_trail_slash
+tests+=        t_dots
+tests+=        t_create
+tests+=        t_remove
+tests+=        t_link
+tests+=        t_rename
+tests+=        t_read_write
+tests+=        t_exec
+tests+=        t_truncate
+tests+=        t_sizes
+tests+=        t_times
+tests+=        t_symlink
+tests+=        t_mknod
+tests+=        t_devices
+tests+=        t_pipes
+tests+=        t_sockets
+tests+=        t_readdir
+
+regress: ${tests}
+.for t in      ${tests}
+       @./${t} ${TEST_ARGS}
+.endfor
+
+PROG=  h_tools
+NOMAN= # defined
+
+t_sizes t_sockets t_statvfs: h_tools
+
+.include <bsd.prog.mk>
diff -r 959f5f0a40ec -r ccea4dd82566 regress/sys/fs/tmpfs/h_funcs.subr
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/sys/fs/tmpfs/h_funcs.subr Sat Sep 10 19:20:48 2005 +0000
@@ -0,0 +1,160 @@
+#!/bin/sh
+#
+# $NetBSD: h_funcs.subr,v 1.1 2005/09/10 19:20:51 jmmv Exp $
+#
+# Copyright (c) 2005 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Julio M. Merino Vidal.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+#        This product includes software developed by the NetBSD
+#        Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+#    contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+#
+# Helper functions for tests written in shell script.
+#
+
+Prog_Name=${0##*/}
+Src_Dir=$(pwd)
+Unprived_User=
+Verbose=1
+Work_Dir=$(pwd)/tmp
+
+# -------------------------------------------------------------------------
+
+# die
+#
+#      Called by tests when a command fails unexpectedly.  Terminates
+#      execution and tries to clean up the mount point.
+#
+die() {
+       if [ -d ${Work_Dir} ]; then
+               cd ${Src_Dir}
+               umount ${Work_Dir}
+               rmdir ${Work_Dir}
+       fi
+       [ ${Verbose} -eq 2 ] && err "Test ended unexpectedly"
+       [ ${Verbose} -eq 1 ] && echo " failed."
+       exit 1
+}
+
+# -------------------------------------------------------------------------
+
+# err message
+#
+#      Shows the given error message and terminates the program.
+#
+err() {
+       echo "${Prog_Name}: $*" 1>&2
+       exit 1
+}
+
+# -------------------------------------------------------------------------
+
+# test_mount [args]
+#
+#      Mounts tmpfs over ${Work_Dir} and changes the current directory
+#      to the mount point.  Optional arguments may be passed to the
+#      mount command.
+#
+test_mount() {
+       mkdir ${Work_Dir} || die
+       if [ $# -gt 0 ]; then
+               mount -t tmpfs "$@" tmpfs ${Work_Dir} || die
+       else
+               mount -t tmpfs tmpfs ${Work_Dir} || die
+       fi
+       cd ${Work_Dir}
+}
+
+# -------------------------------------------------------------------------
+
+# test_name message
+#
+#      Prints a message about what a test is going to do.
+#
+test_name() {
+       [ ${Verbose} -gt 1 ] && echo "    $*..."
+}
+
+# -------------------------------------------------------------------------
+
+# test_unmount
+#
+#      Unmounts the file-system mounted by test_mount.
+#
+test_unmount() {
+       cd -
+       umount ${Work_Dir} || die
+       rmdir ${Work_Dir} || die
+}
+
+# -------------------------------------------------------------------------
+
+main() {
+       local args
+
+       [ $(id -un) = root ] || err "Must be run as root"
+
+       args=$(getopt u:v:w: $*)
+       if [ $? -ne 0 ]; then
+               echo "Usage: ${Prog_Name} [-u unprived_user] [-v level] " \
+                   "[-w root_dir]" 1>&2
+               return 1
+       fi
+       set -- ${args}
+       while [ $# -gt 0 ]; do
+               case "$1" in
+                       -u)
+                               Unprived_User="$2"; shift
+                               ;;
+                       -v)
+                               Verbose="$2"; shift
+                               ;;
+                       -w)
+                               Work_Dir="$2"; shift
+                               ;;
+                       --)
+                               shift; break
+                               ;;
+               esac
+               shift
+       done
+
+       [ ${Verbose} -eq 1 ] && echo -n "${Prog_Name}:"
+       [ ${Verbose} -eq 2 ] && echo "${Prog_Name}: Running tests"
+       test_run
+       [ ${Verbose} -eq 1 ] && echo " ok."
+       [ ${Verbose} -eq 2 ] && echo "${Prog_Name}: All tests were successful"
+
+       return 0
+}
+
+main "$@"
diff -r 959f5f0a40ec -r ccea4dd82566 regress/sys/fs/tmpfs/h_tools.c



Home | Main Index | Thread Index | Old Index