CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Sat Apr 29 08:15:13 UTC 2023 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs: Assert no arithmetic overflow in directory node tn_size. Need >2^57 directory entries before this is a problem. If we created a million per second, this would take over 4000 years. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/fs/tmpfs/tmpfs_subr.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.116 src/sys/fs/tmpfs/tmpfs_subr.c:1.117 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.116 Sat Apr 29 08:13:27 2023 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sat Apr 29 08:15:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.116 2023/04/29 08:13:27 riastradh Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.117 2023/04/29 08:15:13 riastradh Exp $ */ /* * Copyright (c) 2005-2020 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.116 2023/04/29 08:13:27 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.117 2023/04/29 08:15:13 riastradh Exp $"); #include #include @@ -522,6 +522,7 @@ tmpfs_dir_attach(tmpfs_node_t *dnode, tm /* Insert the entry to the directory (parent of inode). */ TAILQ_INSERT_TAIL(>tn_spec.tn_dir.tn_dir, de, td_entries); + KASSERT(dnode->tn_size <= __type_max(off_t) - sizeof(tmpfs_dirent_t)); dnode->tn_size += sizeof(tmpfs_dirent_t); uvm_vnp_setsize(dvp, dnode->tn_size); @@ -580,6 +581,7 @@ tmpfs_dir_detach(tmpfs_node_t *dnode, tm dnode->tn_spec.tn_dir.tn_readdir_lastp = NULL; } TAILQ_REMOVE(>tn_spec.tn_dir.tn_dir, de, td_entries); + KASSERT(dnode->tn_size >= sizeof(tmpfs_dirent_t)); dnode->tn_size -= sizeof(tmpfs_dirent_t); tmpfs_dir_putseq(dnode, de);
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Sat Apr 29 08:15:13 UTC 2023 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs: Assert no arithmetic overflow in directory node tn_size. Need >2^57 directory entries before this is a problem. If we created a million per second, this would take over 4000 years. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Sat Apr 29 08:13:27 UTC 2023 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs: Refuse sizes that overflow round_page. Reported-by: syzbot+8dbeee84de15f86df...@syzkaller.appspotmail.com https://syzkaller.appspot.com/bug?id=4a27b9fe074f8d4b0afbe22969339b8dfdb157e8 To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/fs/tmpfs/tmpfs_subr.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.115 src/sys/fs/tmpfs/tmpfs_subr.c:1.116 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.115 Sat Apr 29 06:29:55 2023 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sat Apr 29 08:13:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.115 2023/04/29 06:29:55 riastradh Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.116 2023/04/29 08:13:27 riastradh Exp $ */ /* * Copyright (c) 2005-2020 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.115 2023/04/29 06:29:55 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.116 2023/04/29 08:13:27 riastradh Exp $"); #include #include @@ -907,6 +907,9 @@ tmpfs_reg_resize(struct vnode *vp, off_t KASSERT(vp->v_type == VREG); KASSERT(newsize >= 0); + if (newsize > __type_max(off_t) - PAGE_SIZE + 1) + return EFBIG; + oldsize = node->tn_size; oldpages = round_page(oldsize) >> PAGE_SHIFT; newpages = round_page(newsize) >> PAGE_SHIFT;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Sat Apr 29 08:13:27 UTC 2023 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs: Refuse sizes that overflow round_page. Reported-by: syzbot+8dbeee84de15f86df...@syzkaller.appspotmail.com https://syzkaller.appspot.com/bug?id=4a27b9fe074f8d4b0afbe22969339b8dfdb157e8 To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Sat Apr 29 06:29:55 UTC 2023 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c tmpfs_subr.c Log Message: tmpfs: Nix trailing whitespace. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.114 -r1.115 src/sys/fs/tmpfs/tmpfs_subr.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_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.13 src/sys/fs/tmpfs/tmpfs_mem.c:1.14 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.13 Thu Jun 11 19:20:46 2020 +++ src/sys/fs/tmpfs/tmpfs_mem.c Sat Apr 29 06:29:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.13 2020/06/11 19:20:46 ad Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.14 2023/04/29 06:29:55 riastradh Exp $ */ /* * Copyright (c) 2010, 2011, 2020 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.13 2020/06/11 19:20:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.14 2023/04/29 06:29:55 riastradh Exp $"); #include #include @@ -81,8 +81,6 @@ tmpfs_mntmem_set(struct tmpfs_mount *mp, return error; } - - /* * tmpfs_mem_info: return the number of available memory pages. * Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.114 src/sys/fs/tmpfs/tmpfs_subr.c:1.115 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.114 Wed Oct 20 03:08:17 2021 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sat Apr 29 06:29:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.114 2021/10/20 03:08:17 thorpej Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.115 2023/04/29 06:29:55 riastradh Exp $ */ /* * Copyright (c) 2005-2020 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.114 2021/10/20 03:08:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.115 2023/04/29 06:29:55 riastradh Exp $"); #include #include @@ -892,7 +892,7 @@ done: } /* - * tmpfs_reg_resize: resize the underlying UVM object associated with the + * tmpfs_reg_resize: resize the underlying UVM object associated with the * specified regular file. */ int
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Sat Apr 29 06:29:55 UTC 2023 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c tmpfs_subr.c Log Message: tmpfs: Nix trailing whitespace. No functional change intended. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.114 -r1.115 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Nov 10 10:54:14 UTC 2022 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Tmpfs_mount() uses tmpfs_unmount() for cleanup if set_statvfs_info() fails. This will not work as tmpfs_unmount() needs a suspended file system. Just call set_statvfs_info() before allocating the root vnode and add and use a common error exit label. Reported-by: syzbot+343f2bfea65a32ab4...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.77 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.78 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.77 Sat Apr 4 20:49:30 2020 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Thu Nov 10 10:54:14 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.77 2020/04/04 20:49:30 ad Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.78 2022/11/10 10:54:14 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.77 2020/04/04 20:49:30 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.78 2022/11/10 10:54:14 hannken Exp $"); #include #include @@ -196,6 +196,11 @@ tmpfs_mount(struct mount *mp, const char tmpfs_mntmem_init(tmp, memlimit); mp->mnt_data = tmp; + error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE, + mp->mnt_op->vfs_name, mp, curlwp); + if (error) + goto errout; + /* Allocate the root node. */ vattr_null(); va.va_type = VDIR; @@ -203,13 +208,8 @@ tmpfs_mount(struct mount *mp, const char va.va_uid = args->ta_root_uid; va.va_gid = args->ta_root_gid; error = vcache_new(mp, NULL, , NOCRED, NULL, ); - if (error) { - mp->mnt_data = NULL; - tmpfs_mntmem_destroy(tmp); - mutex_destroy(>tm_lock); - kmem_free(tmp, sizeof(*tmp)); - return error; - } + if (error) + goto errout; KASSERT(vp != NULL); root = VP_TO_TMPFS_NODE(vp); KASSERT(root != NULL); @@ -224,11 +224,14 @@ tmpfs_mount(struct mount *mp, const char tmp->tm_root = root; vrele(vp); - error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE, - mp->mnt_op->vfs_name, mp, curlwp); - if (error) { - (void)tmpfs_unmount(mp, MNT_FORCE); - } + return 0; + +errout: + mp->mnt_data = NULL; + tmpfs_mntmem_destroy(tmp); + mutex_destroy(>tm_lock); + kmem_free(tmp, sizeof(*tmp)); + return error; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Nov 10 10:54:14 UTC 2022 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Tmpfs_mount() uses tmpfs_unmount() for cleanup if set_statvfs_info() fails. This will not work as tmpfs_unmount() needs a suspended file system. Just call set_statvfs_info() before allocating the root vnode and add and use a common error exit label. Reported-by: syzbot+343f2bfea65a32ab4...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Wed Jun 1 08:42:38 UTC 2022 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_read: respect MNT_NOATIME. To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.149 src/sys/fs/tmpfs/tmpfs_vnops.c:1.150 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.149 Sun Mar 27 16:24:57 2022 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Wed Jun 1 08:42:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.149 2022/03/27 16:24:57 christos Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.150 2022/06/01 08:42:38 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.149 2022/03/27 16:24:57 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.150 2022/06/01 08:42:38 hannken Exp $"); #include #include @@ -555,7 +555,9 @@ tmpfs_read(void *v) UBC_READ | UBC_PARTIALOK | UBC_VNODE_FLAGS(vp)); } - tmpfs_update(vp, TMPFS_UPDATE_ATIME); + if ((vp->v_mount->mnt_flag & MNT_NOATIME) == 0) + tmpfs_update(vp, TMPFS_UPDATE_ATIME); + return error; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Wed Jun 1 08:42:38 UTC 2022 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_read: respect MNT_NOATIME. To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: thorpej Date: Wed Oct 20 14:28:21 UTC 2021 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Move a mis-placed KASSERT(). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/fs/tmpfs/tmpfs_rename.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_rename.c diff -u src/sys/fs/tmpfs/tmpfs_rename.c:1.11 src/sys/fs/tmpfs/tmpfs_rename.c:1.12 --- src/sys/fs/tmpfs/tmpfs_rename.c:1.11 Wed Oct 20 03:08:17 2021 +++ src/sys/fs/tmpfs/tmpfs_rename.c Wed Oct 20 14:28:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_rename.c,v 1.11 2021/10/20 03:08:17 thorpej Exp $ */ +/* $NetBSD: tmpfs_rename.c,v 1.12 2021/10/20 14:28:21 thorpej Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.11 2021/10/20 03:08:17 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.12 2021/10/20 14:28:21 thorpej Exp $"); #include #include @@ -402,11 +402,12 @@ tmpfs_gro_remove(struct mount *mp, kauth KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE); KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE); + KASSERT((*dep)->td_node == VP_TO_TMPFS_NODE(vp)); + tmpfs_dir_detach(dnode, *dep); tmpfs_free_dirent(VFS_TO_TMPFS(mp), *dep); tmpfs_update(dvp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME); - KASSERT((*dep)->td_node == VP_TO_TMPFS_NODE(vp)); *tvp_nlinkp = VP_TO_TMPFS_NODE(vp)->tn_links; return 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: thorpej Date: Wed Oct 20 14:28:21 UTC 2021 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Move a mis-placed KASSERT(). To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/fs/tmpfs/tmpfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: chs Date: Sun Dec 13 19:22:02 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Disable use of UBC_FAULTBUSY in tmpfs_write() for now, which brings back zeroing of all new tmpfs data pages. The existing code that enables this optimization skips the zeroing in numerous cases where it is needed, resulting in corrupted files and data leaks from the page's previous identity. To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.144 src/sys/fs/tmpfs/tmpfs_vnops.c:1.145 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.144 Sat Sep 5 16:30:12 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sun Dec 13 19:22:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.144 2020/09/05 16:30:12 riastradh Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.145 2020/12/13 19:22:02 chs Exp $ */ /* * Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.144 2020/09/05 16:30:12 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.145 2020/12/13 19:22:02 chs Exp $"); #include #include @@ -616,12 +616,19 @@ tmpfs_write(void *v) * of PG_BUSY and the vnode lock). */ ubc_flags = UBC_WRITE | UBC_VNODE_FLAGS(vp); +#if 0 + /* + * XXX disable use of UBC_FAULTBUSY for now, this check is insufficient + * because it does not zero uninitialized parts of pages in all of + * the cases where zeroing is needed. + */ if (uio->uio_offset >= oldsize && ((uio->uio_offset & (PAGE_SIZE - 1)) == 0 || ((vp->v_vflag & VV_MAPPED) == 0 && trunc_page(uio->uio_offset) == trunc_page(oldsize { ubc_flags |= UBC_FAULTBUSY; } +#endif uobj = node->tn_spec.tn_reg.tn_aobj; error = 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: chs Date: Sun Dec 13 19:22:02 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Disable use of UBC_FAULTBUSY in tmpfs_write() for now, which brings back zeroing of all new tmpfs data pages. The existing code that enables this optimization skips the zeroing in numerous cases where it is needed, resulting in corrupted files and data leaks from the page's previous identity. To generate a diff of this commit: cvs rdiff -u -r1.144 -r1.145 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sun May 24 20:08:26 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_write(): use UBC_FAULTBUSY when extending files, if possible, to avoid zeroing of newly allocated pages & fault processing. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sun May 24 20:08:26 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_write(): use UBC_FAULTBUSY when extending files, if possible, to avoid zeroing of newly allocated pages & fault processing. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.141 src/sys/fs/tmpfs/tmpfs_vnops.c:1.142 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.141 Tue May 19 22:22:15 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sun May 24 20:08:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.141 2020/05/19 22:22:15 ad Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.142 2020/05/24 20:08:26 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.141 2020/05/19 22:22:15 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.142 2020/05/24 20:08:26 ad Exp $"); #include #include @@ -573,7 +573,7 @@ tmpfs_write(void *v) tmpfs_node_t *node; struct uvm_object *uobj; off_t oldsize; - int error; + int error, ubc_flags; KASSERT(VOP_ISLOCKED(vp)); @@ -603,6 +603,26 @@ tmpfs_write(void *v) goto out; } + /* + * If we're extending the file and have data to write that would + * not leave an un-zeroed hole, we can avoid fault processing and + * zeroing of pages on allocation. + * + * Don't do this if the file is mapped and we need to touch an + * existing page, because writing a mapping of the file into itself + * could cause a deadlock on PG_BUSY. + * + * New pages will not become visible until finished here (because + * of PG_BUSY and the vnode lock). + */ + ubc_flags = UBC_WRITE | UBC_VNODE_FLAGS(vp); + if (uio->uio_offset >= oldsize && + ((uio->uio_offset & (PAGE_SIZE - 1)) == 0 || + ((vp->v_vflag & VV_MAPPED) == 0 && + trunc_page(uio->uio_offset) == trunc_page(oldsize { + ubc_flags |= UBC_FAULTBUSY; + } + uobj = node->tn_spec.tn_reg.tn_aobj; error = 0; while (error == 0 && uio->uio_resid > 0) { @@ -613,7 +633,7 @@ tmpfs_write(void *v) break; } error = ubc_uiomove(uobj, uio, len, IO_ADV_DECODE(ioflag), - UBC_WRITE | UBC_VNODE_FLAGS(vp)); + ubc_flags); } if (error) { (void)tmpfs_reg_resize(vp, oldsize);
Re: CVS commit: src/sys/fs/tmpfs
On Tue, May 19, 2020 at 11:09:07PM +, Andrew Doran wrote: > vnode locks are not held during getpages/putpages. ^ for fault handling, anyway. for read/write they are held by the caller to ubc_uiomove(). Andrew
Re: CVS commit: src/sys/fs/tmpfs
On Sun, May 17, 2020 at 11:49:52PM +, m...@netbsd.org wrote: > On Sun, May 17, 2020 at 09:47:50PM +, m...@netbsd.org wrote: > > On Sun, May 17, 2020 at 07:39:15PM +, Andrew Doran wrote: > > > Module Name: src > > > Committed By: ad > > > Date: Sun May 17 19:39:15 UTC 2020 > > > > > > Modified Files: > > > src/sys/fs/tmpfs: tmpfs.h tmpfs_subr.c tmpfs_vnops.c > > > > > > Log Message: > > > PR kern/55268: tmpfs is slow > > > > > > tmpfs_getpages(): ...implement lazy update of atime/mtime. > > > > > > > I'm confused about how this makes sense. Can you elaborate? > > Presumably RAM is as fast as other RAM. > > riastradh responded to this elsewhere: avoid atomic ops Right, also to: - avoid taking a mutex to serialize the update to the time fields in the tmpfs node. vnode locks are not held during getpages/putpages. the vmobjlock is held here and often read-held so there can be lots of concurrent access. - avoid doing a writeback on the tmpfs_node, which if it's heavily shared (consider for example ld.so or libc.so) involves lots of cache coherency overhead. - avoid querying the clock. Andrew
Re: CVS commit: src/sys/fs/tmpfs
On Sun, May 17, 2020 at 09:47:50PM +, m...@netbsd.org wrote: > On Sun, May 17, 2020 at 07:39:15PM +, Andrew Doran wrote: > > Module Name:src > > Committed By: ad > > Date: Sun May 17 19:39:15 UTC 2020 > > > > Modified Files: > > src/sys/fs/tmpfs: tmpfs.h tmpfs_subr.c tmpfs_vnops.c > > > > Log Message: > > PR kern/55268: tmpfs is slow > > > > tmpfs_getpages(): ...implement lazy update of atime/mtime. > > > > I'm confused about how this makes sense. Can you elaborate? > Presumably RAM is as fast as other RAM. riastradh responded to this elsewhere: avoid atomic ops thanks
Re: CVS commit: src/sys/fs/tmpfs
On Sun, May 17, 2020 at 07:39:15PM +, Andrew Doran wrote: > Module Name: src > Committed By: ad > Date: Sun May 17 19:39:15 UTC 2020 > > Modified Files: > src/sys/fs/tmpfs: tmpfs.h tmpfs_subr.c tmpfs_vnops.c > > Log Message: > PR kern/55268: tmpfs is slow > > tmpfs_getpages(): ...implement lazy update of atime/mtime. > I'm confused about how this makes sense. Can you elaborate? Presumably RAM is as fast as other RAM.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sun May 17 19:43:31 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Minor correction to previous. To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.139 src/sys/fs/tmpfs/tmpfs_vnops.c:1.140 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.139 Sun May 17 19:39:15 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sun May 17 19:43:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.139 2020/05/17 19:39:15 ad Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.140 2020/05/17 19:43:31 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.139 2020/05/17 19:39:15 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.140 2020/05/17 19:43:31 ad Exp $"); #include #include @@ -1201,7 +1201,7 @@ tmpfs_getpages(void *v) * VI_DEADCHECK is set with vmobjlock held. */ iflag = atomic_load_relaxed(>v_iflag); - if (__predict_false((iflag & VI_DEADCHECK) != 0) { + if (__predict_false((iflag & VI_DEADCHECK) != 0)) { mutex_enter(vp->v_interlock); error = vdead_check(vp, VDEAD_NOWAIT); mutex_exit(vp->v_interlock);
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sun May 17 19:43:31 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Minor correction to previous. To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sun May 17 19:39:15 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_subr.c tmpfs_vnops.c Log Message: PR kern/55268: tmpfs is slow tmpfs_getpages(): handle the PGO_LOCKED case and implement lazy update of atime/mtime. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.111 -r1.112 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.138 -r1.139 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sun May 17 19:39:15 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_subr.c tmpfs_vnops.c Log Message: PR kern/55268: tmpfs is slow tmpfs_getpages(): handle the PGO_LOCKED case and implement lazy update of atime/mtime. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.111 -r1.112 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.138 -r1.139 src/sys/fs/tmpfs/tmpfs_vnops.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.55 src/sys/fs/tmpfs/tmpfs.h:1.56 --- src/sys/fs/tmpfs/tmpfs.h:1.55 Thu Apr 19 21:50:09 2018 +++ src/sys/fs/tmpfs/tmpfs.h Sun May 17 19:39:15 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: tmpfs.h,v 1.55 2018/04/19 21:50:09 christos Exp $ */ +/* $NetBSD: tmpfs.h,v 1.56 2020/05/17 19:39:15 ad Exp $ */ /* - * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. + * Copyright (c) 2005, 2006, 2007, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -112,10 +112,12 @@ typedef struct tmpfs_node { mode_t tn_mode; int tn_flags; nlink_t tn_links; + unsigned tn_tflags; struct timespec tn_atime; struct timespec tn_mtime; struct timespec tn_ctime; struct timespec tn_birthtime; + kmutex_t tn_timelock; /* Head of byte-level lock list (used by tmpfs_advlock). */ struct lockf * tn_lockf; @@ -274,6 +276,8 @@ int tmpfs_chtimes(vnode_t *, const stru const struct timespec *, const struct timespec *, int, kauth_cred_t, lwp_t *); void tmpfs_update(vnode_t *, unsigned); +void tmpfs_update_locked(vnode_t *, unsigned); +void tmpfs_update_lazily(vnode_t *, unsigned); /* * Prototypes for tmpfs_mem.c. Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.111 src/sys/fs/tmpfs/tmpfs_subr.c:1.112 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.111 Sat May 16 18:31:49 2020 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sun May 17 19:39:15 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: tmpfs_subr.c,v 1.111 2020/05/16 18:31:49 christos Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.112 2020/05/17 19:39:15 ad Exp $ */ /* - * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. + * Copyright (c) 2005-2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.111 2020/05/16 18:31:49 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.112 2020/05/17 19:39:15 ad Exp $"); #include #include @@ -230,10 +230,12 @@ tmpfs_newvnode(struct mount *mp, struct node->tn_flags = 0; node->tn_lockf = NULL; + node->tn_tflags = 0; vfs_timestamp(>tn_atime); node->tn_birthtime = node->tn_atime; node->tn_ctime = node->tn_atime; node->tn_mtime = node->tn_atime; + mutex_init(>tn_timelock, MUTEX_DEFAULT, IPL_NONE); if (dvp == NULL) { KASSERT(vap->va_uid != VNOVAL && vap->va_gid != VNOVAL); @@ -350,6 +352,7 @@ tmpfs_free_node(tmpfs_mount_t *tmp, tmpf KASSERT(node->tn_vnode == NULL); KASSERT(node->tn_links == 0); + mutex_destroy(>tn_timelock); tmpfs_node_put(tmp, node); } @@ -1167,29 +1170,35 @@ tmpfs_chtimes(vnode_t *vp, const struct if (error) return error; + mutex_enter(>tn_timelock); if (atime->tv_sec != VNOVAL) { + atomic_and_uint(>tn_tflags, ~TMPFS_UPDATE_ATIME); node->tn_atime = *atime; } if (mtime->tv_sec != VNOVAL) { + atomic_and_uint(>tn_tflags, ~TMPFS_UPDATE_MTIME); node->tn_mtime = *mtime; } if (btime->tv_sec != VNOVAL) { node->tn_birthtime = *btime; } + mutex_exit(>tn_timelock); VN_KNOTE(vp, NOTE_ATTRIB); return 0; } /* - * tmpfs_update: update the timestamps as indicated by the flags. + * tmpfs_update_locked: update the timestamps as indicated by the flags. */ void -tmpfs_update(vnode_t *vp, unsigned tflags) +tmpfs_update_locked(vnode_t *vp, unsigned tflags) { tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); struct timespec nowtm; - if (tflags == 0) { + KASSERT(mutex_owned(>tn_timelock)); + + if ((tflags |= atomic_swap_uint(>tn_tflags, 0)) == 0) { return; } vfs_timestamp(); @@ -1204,3 +1213,36 @@ tmpfs_update(vnode_t *vp, unsigned tflag node->tn_ctime = nowtm; } } + +/* + * tmpfs_update: update the timestamps as indicated by the flags. + */ +void +tmpfs_update(vnode_t *vp, unsigned tflags) +{ + tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); + + if ((tflags | atomic_load_relaxed(>tn_tflags)) == 0) { + return; + } + + mutex_enter(>tn_timelock); + tmpfs_update_locked(vp, tflags); + mutex_exit(>tn_timelock); +} + +/* + * tmpfs_update_lazily: schedule a deferred timestamp update. + */ +void +tmpfs_update_lazily(vnode_t *vp, unsigned tflags) +{ + tmpfs_node_t *node = VP_TO_TMPFS_NODE(vp); +
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Fri May 15 22:15:43 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: PR kern/55268: tmpfs is slow Enter dotdot into the namecache. To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.136 src/sys/fs/tmpfs/tmpfs_vnops.c:1.137 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.136 Thu Apr 23 21:47:08 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Fri May 15 22:15:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.136 2020/04/23 21:47:08 ad Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.137 2020/05/15 22:15:43 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.136 2020/04/23 21:47:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.137 2020/05/15 22:15:43 ad Exp $"); #include #include @@ -202,11 +202,11 @@ tmpfs_lookup(void *v) pnode = dnode->tn_spec.tn_dir.tn_parent; if (pnode == NULL) { error = ENOENT; - goto out; + goto done; } error = vcache_get(dvp->v_mount, , sizeof(pnode), vpp); - goto out; + goto done; } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { /* * Lookup of "." case.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Fri May 15 22:15:43 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: PR kern/55268: tmpfs is slow Enter dotdot into the namecache. To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:39:36 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_inactive(): do like other file systems and truncate the file if it has been deleted. Otherwise VFS will try to write cached data "back to disc", which in the case of a UAO means needless page deactivations and the resulting TLB shootdowns. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.134 src/sys/fs/tmpfs/tmpfs_vnops.c:1.135 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.134 Sun Feb 23 15:46:40 2020 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sat Mar 14 13:39:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.134 2020/02/23 15:46:40 ad Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.134 2020/02/23 15:46:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $"); #include #include @@ -1040,6 +1040,7 @@ tmpfs_inactive(void *v) } */ *ap = v; vnode_t *vp = ap->a_vp; tmpfs_node_t *node; + int error = 0; KASSERT(VOP_ISLOCKED(vp)); @@ -1049,12 +1050,21 @@ tmpfs_inactive(void *v) * Mark node as dead by setting its generation to zero. */ atomic_and_32(>tn_gen, ~TMPFS_NODE_GEN_MASK); + + /* + * If the file has been deleted, truncate it, otherwise VFS + * will quite rightly try to write back dirty data, which in + * the case of tmpfs/UAO means needless page deactivations. + */ + if (vp->v_type == VREG) { + error = tmpfs_reg_resize(vp, 0); + } *ap->a_recycle = true; } else { *ap->a_recycle = false; } - return 0; + return error; } int
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:39:36 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_inactive(): do like other file systems and truncate the file if it has been deleted. Otherwise VFS will try to write cached data "back to disc", which in the case of a UAO means needless page deactivations and the resulting TLB shootdowns. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:37:49 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_reg_resize(): do nothing if newsize == oldsize. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: ad Date: Sat Mar 14 13:37:49 UTC 2020 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: tmpfs_reg_resize(): do nothing if newsize == oldsize. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/fs/tmpfs/tmpfs_subr.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.106 src/sys/fs/tmpfs/tmpfs_subr.c:1.107 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.106 Sun Feb 23 15:46:40 2020 +++ src/sys/fs/tmpfs/tmpfs_subr.c Sat Mar 14 13:37:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.106 2020/02/23 15:46:40 ad Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.107 2020/03/14 13:37:49 ad Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.106 2020/02/23 15:46:40 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.107 2020/03/14 13:37:49 ad Exp $"); #include #include @@ -914,6 +914,10 @@ tmpfs_reg_resize(struct vnode *vp, off_t newpages = round_page(newsize) >> PAGE_SHIFT; KASSERT(oldpages == node->tn_spec.tn_reg.tn_aobj_pages); + if (newsize == oldsize) { + return 0; + } + if (newpages > oldpages) { /* Increase the used-memory counter if getting extra pages. */ if (!tmpfs_mem_incr(tmp, (newpages - oldpages) << PAGE_SHIFT)) {
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Tue Dec 3 04:59:05 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Omit obsolete comment and needless __diagused marker. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/fs/tmpfs/tmpfs_rename.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_rename.c diff -u src/sys/fs/tmpfs/tmpfs_rename.c:1.9 src/sys/fs/tmpfs/tmpfs_rename.c:1.10 --- src/sys/fs/tmpfs/tmpfs_rename.c:1.9 Sun Jul 14 05:58:44 2019 +++ src/sys/fs/tmpfs/tmpfs_rename.c Tue Dec 3 04:59:05 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_rename.c,v 1.9 2019/07/14 05:58:44 maxv Exp $ */ +/* $NetBSD: tmpfs_rename.c,v 1.10 2019/12/03 04:59:05 riastradh Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.9 2019/07/14 05:58:44 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.10 2019/12/03 04:59:05 riastradh Exp $"); #include #include @@ -425,7 +425,7 @@ tmpfs_gro_lookup(struct mount *mp, struc { struct tmpfs_dirent *dirent, **dep_ret = de_ret; struct vnode *vp; - int error __diagused; + int error; (void)mp; KASSERT(mp != NULL); @@ -444,11 +444,6 @@ tmpfs_gro_lookup(struct mount *mp, struc return error; KASSERT(vp != NULL); - /* - * XXX Once namei is fixed, we can change the genfs_rename - * protocol so that we have to lock vp here. - */ - *dep_ret = dirent; *vp_ret = vp; return 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: riastradh Date: Tue Dec 3 04:59:05 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Omit obsolete comment and needless __diagused marker. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/fs/tmpfs/tmpfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: mrg Date: Fri Oct 4 12:34:40 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: remove an always false check and its' "This can never happen?" comment. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.74 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.75 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.74 Tue Jan 1 10:06:54 2019 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Fri Oct 4 12:34:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.74 2019/01/01 10:06:54 hannken Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.75 2019/10/04 12:34:40 mrg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.74 2019/01/01 10:06:54 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.75 2019/10/04 12:34:40 mrg Exp $"); #include #include @@ -132,10 +132,6 @@ tmpfs_mount(struct mount *mp, const char if (args->ta_root_uid == VNOVAL || args->ta_root_gid == VNOVAL) return EINVAL; - /* This can never happen? */ - if ((args->ta_root_mode & ALLPERMS) == VNOVAL) - return EINVAL; - /* Get the memory usage limit for this file-system. */ if (args->ta_size_max < PAGE_SIZE) { memlimit = UINT64_MAX;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: mrg Date: Fri Oct 4 12:34:40 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: remove an always false check and its' "This can never happen?" comment. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Sun Jul 14 05:58:44 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Fix uninitialized variable: if 'tvp' is NULL, '*tdep' is not initialized. This could have caused the KASSERT to wrongfully fire. ok riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/fs/tmpfs/tmpfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Sun Jul 14 05:58:44 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Fix uninitialized variable: if 'tvp' is NULL, '*tdep' is not initialized. This could have caused the KASSERT to wrongfully fire. ok riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/fs/tmpfs/tmpfs_rename.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_rename.c diff -u src/sys/fs/tmpfs/tmpfs_rename.c:1.8 src/sys/fs/tmpfs/tmpfs_rename.c:1.9 --- src/sys/fs/tmpfs/tmpfs_rename.c:1.8 Mon Jul 6 10:24:59 2015 +++ src/sys/fs/tmpfs/tmpfs_rename.c Sun Jul 14 05:58:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_rename.c,v 1.8 2015/07/06 10:24:59 wiz Exp $ */ +/* $NetBSD: tmpfs_rename.c,v 1.9 2019/07/14 05:58:44 maxv Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.8 2015/07/06 10:24:59 wiz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.9 2019/07/14 05:58:44 maxv Exp $"); #include #include @@ -282,7 +282,7 @@ tmpfs_gro_rename(struct mount *mp, kauth KASSERT(tcnp != NULL); KASSERT(tdep != NULL); KASSERT(fdep != tdep); - KASSERT((*fdep) != (*tdep)); + KASSERT((tvp == NULL) || (*fdep) != (*tdep)); KASSERT((*fdep) != NULL); KASSERT((*fdep)->td_node == VP_TO_TMPFS_NODE(fvp)); KASSERT((tvp == NULL) || ((*tdep) != NULL));
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Sat Jul 13 14:24:37 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: Remove the roundups, they are incorrect and cause memcmp to wrongfully fail because of uninitialized bytes at the end of the buffers. ok rmind@ To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/fs/tmpfs/tmpfs_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Sat Jul 13 14:24:37 UTC 2019 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: Remove the roundups, they are incorrect and cause memcmp to wrongfully fail because of uninitialized bytes at the end of the buffers. ok rmind@ To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/fs/tmpfs/tmpfs_mem.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_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.9 src/sys/fs/tmpfs/tmpfs_mem.c:1.10 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.9 Mon Aug 22 23:07:36 2016 +++ src/sys/fs/tmpfs/tmpfs_mem.c Sat Jul 13 14:24:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.9 2016/08/22 23:07:36 skrll Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.10 2019/07/13 14:24:37 maxv Exp $ */ /* * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.9 2016/08/22 23:07:36 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.10 2019/07/13 14:24:37 maxv Exp $"); #include #include @@ -234,8 +234,8 @@ tmpfs_strname_free(struct tmpfs_mount *m bool tmpfs_strname_neqlen(struct componentname *fcnp, struct componentname *tcnp) { - const size_t fln = roundup2(fcnp->cn_namelen, TMPFS_NAME_QUANTUM); - const size_t tln = roundup2(tcnp->cn_namelen, TMPFS_NAME_QUANTUM); + const size_t fln = fcnp->cn_namelen; + const size_t tln = tcnp->cn_namelen; return (fln != tln) || memcmp(fcnp->cn_nameptr, tcnp->cn_nameptr, fln); }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: christos Date: Thu Aug 9 08:43:56 UTC 2018 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: FIx performance regression from rmind@: Just from a very quick look, it seems like a regression introduced with the vcache changes: the MP-safe flag is set too late and not inherited by the root vnode. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: christos Date: Thu Aug 9 08:43:56 UTC 2018 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: FIx performance regression from rmind@: Just from a very quick look, it seems like a regression introduced with the vcache changes: the MP-safe flag is set too late and not inherited by the root vnode. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.72 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.73 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.72 Wed May 31 22:45:13 2017 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Thu Aug 9 04:43:56 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.72 2017/06/01 02:45:13 chs Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.73 2018/08/09 08:43:56 christos Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.72 2017/06/01 02:45:13 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.73 2018/08/09 08:43:56 christos Exp $"); #include #include @@ -182,6 +182,13 @@ tmpfs_mount(struct mount *mp, const char return 0; } + mp->mnt_flag |= MNT_LOCAL; + mp->mnt_stat.f_namemax = TMPFS_MAXNAMLEN; + mp->mnt_fs_bshift = PAGE_SHIFT; + mp->mnt_dev_bshift = DEV_BSHIFT; + mp->mnt_iflag |= IMNT_MPSAFE | IMNT_CAN_RWTORO; + vfs_getnewfsid(mp); + /* Allocate the tmpfs mount structure and fill it. */ tmp = kmem_zalloc(sizeof(tmpfs_mount_t), KM_SLEEP); tmp->tm_nodes_max = nodes; @@ -220,13 +227,6 @@ tmpfs_mount(struct mount *mp, const char tmp->tm_root = root; vrele(vp); - mp->mnt_flag |= MNT_LOCAL; - mp->mnt_stat.f_namemax = TMPFS_MAXNAMLEN; - mp->mnt_fs_bshift = PAGE_SHIFT; - mp->mnt_dev_bshift = DEV_BSHIFT; - mp->mnt_iflag |= IMNT_MPSAFE | IMNT_CAN_RWTORO; - vfs_getnewfsid(mp); - error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE, mp->mnt_op->vfs_name, mp, curlwp); if (error) {
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:09:26 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Protect tmpfs_getpages() against reclaiming vnodes. To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:09:26 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Protect tmpfs_getpages() against reclaiming vnodes. To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.129 src/sys/fs/tmpfs/tmpfs_vnops.c:1.130 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.129 Wed Jan 11 12:12:32 2017 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Thu Mar 30 09:09:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $"); #include #include @@ -1165,9 +1165,6 @@ tmpfs_getpages(void *v) KASSERT(vp->v_type == VREG); KASSERT(mutex_owned(vp->v_interlock)); - node = VP_TO_TMPFS_NODE(vp); - uobj = node->tn_spec.tn_reg.tn_aobj; - /* * Currently, PGO_PASTEOF is not supported. */ @@ -1184,6 +1181,12 @@ tmpfs_getpages(void *v) if ((flags & PGO_LOCKED) != 0) return EBUSY; + if (vdead_check(vp, VDEAD_NOWAIT) != 0) + return ENOENT; + + node = VP_TO_TMPFS_NODE(vp); + uobj = node->tn_spec.tn_reg.tn_aobj; + if ((flags & PGO_NOTIMESTAMP) == 0) { u_int tflags = 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Fri Jan 27 10:47:54 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_vfsops.c Log Message: Run vflush() when going from read/write to read only. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.68 -r1.69 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.52 src/sys/fs/tmpfs/tmpfs.h:1.53 --- src/sys/fs/tmpfs/tmpfs.h:1.52 Mon Jul 6 10:07:12 2015 +++ src/sys/fs/tmpfs/tmpfs.h Fri Jan 27 10:47:54 2017 @@ -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 @@ typedef struct tmpfs_mount { 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; Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.68 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.69 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.68 Fri Aug 26 21:44:24 2016 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Fri Jan 27 10:47:54 2017 @@ -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 -__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 #include @@ -92,7 +92,7 @@ tmpfs_mount(struct mount *mp, const char struct vnode *vp; uint64_t memlimit; ino_t nodes; - int error; + int error, flags; bool set_memlimit; bool set_nodes; @@ -160,6 +160,20 @@ tmpfs_mount(struct mount *mp, const char 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 @@ tmpfs_mount(struct mount *mp, const char 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(>tm_nodes);
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Fri Jan 27 10:47:54 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_vfsops.c Log Message: Run vflush() when going from read/write to read only. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.68 -r1.69 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.
Re: CVS commit: src/sys/fs/tmpfs
On Wed, Jan 11, 2017 at 09:12:33PM +, David Holland wrote: > On Wed, Jan 11, 2017 at 12:12:33PM +, Joerg Sonnenberger wrote: > > Modified Files: > >src/sys/fs/tmpfs: tmpfs_vnops.c > > > > Log Message: > > Remove RO check in tmpfs_putpages for now, the syncer doesn't like the > > error code. > > Either removing it is wrong or it should be changed to KASSERT :-) So the problem is that the syncer will unconditionally call putpages e.g. on umount. It might need a two stage approach for dealing with dirty mmapped pages to implement properly, but for the use cases of read-only tmpfs I have (and likely others), it doesn't really matter. E.g. if you want to build multiple build chroots without paying for the extreme locking penalty of nullfs. Joerg
Re: CVS commit: src/sys/fs/tmpfs
On Wed, Jan 11, 2017 at 12:12:33PM +, Joerg Sonnenberger wrote: > Modified Files: > src/sys/fs/tmpfs: tmpfs_vnops.c > > Log Message: > Remove RO check in tmpfs_putpages for now, the syncer doesn't like the > error code. Either removing it is wrong or it should be changed to KASSERT :-) -- David A. Holland dholl...@netbsd.org
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: joerg Date: Wed Jan 11 12:12:32 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Remove RO check in tmpfs_putpages for now, the syncer doesn't like the error code. To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.128 src/sys/fs/tmpfs/tmpfs_vnops.c:1.129 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.128 Sat Aug 20 12:37:08 2016 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Wed Jan 11 12:12:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.128 2016/08/20 12:37:08 hannken Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.128 2016/08/20 12:37:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $"); #include #include @@ -1246,11 +1246,6 @@ tmpfs_putpages(void *v) 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;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: joerg Date: Wed Jan 11 12:12:32 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Remove RO check in tmpfs_putpages for now, the syncer doesn't like the error code. To generate a diff of this commit: cvs rdiff -u -r1.128 -r1.129 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Wed Jan 4 10:06:43 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Change tmpfs_chsize() to update mtime etc. even if "length == node->tn_size". Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)" To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/fs/tmpfs/tmpfs_subr.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.101 src/sys/fs/tmpfs/tmpfs_subr.c:1.102 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.101 Thu Oct 29 16:19:44 2015 +++ src/sys/fs/tmpfs/tmpfs_subr.c Wed Jan 4 10:06:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.101 2015/10/29 16:19:44 leot Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.102 2017/01/04 10:06:43 hannken Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.101 2015/10/29 16:19:44 leot Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.102 2017/01/04 10:06:43 hannken Exp $"); #include #include @@ -1125,12 +1125,10 @@ tmpfs_chsize(vnode_t *vp, u_quad_t size, if (length < 0) { return EINVAL; } - if (node->tn_size == length) { - return 0; - } /* Note: tmpfs_reg_resize() will raise NOTE_EXTEND and NOTE_ATTRIB. */ - if ((error = tmpfs_reg_resize(vp, length)) != 0) { + if (node->tn_size != length && + (error = tmpfs_reg_resize(vp, length)) != 0) { return error; } tmpfs_update(vp, TMPFS_UPDATE_CTIME | TMPFS_UPDATE_MTIME);
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Wed Jan 4 10:06:43 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Change tmpfs_chsize() to update mtime etc. even if "length == node->tn_size". Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)" To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: dholland Date: Fri Aug 26 21:44:24 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: In the event that loading the root vnode fails, bail out of tmpfs_mount instead of crashing. Came up in PR 51436, where kmem issues caused internal allocations to wrongly fail. However, that could happen for real sometime (e.g. probably if you tried to mount a new tmpfs when the system was very low on memory, or possibly for other reasons entirely) and crashing isn't the ticket. (This is not a fix for PR 51436) To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: dholland Date: Fri Aug 26 21:44:24 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: In the event that loading the root vnode fails, bail out of tmpfs_mount instead of crashing. Came up in PR 51436, where kmem issues caused internal allocations to wrongly fail. However, that could happen for real sometime (e.g. probably if you tried to mount a new tmpfs when the system was very low on memory, or possibly for other reasons entirely) and crashing isn't the ticket. (This is not a fix for PR 51436) To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.67 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.68 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.67 Sat Mar 12 08:51:13 2016 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Fri Aug 26 21:44:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland Exp $"); #include #include @@ -193,8 +193,16 @@ tmpfs_mount(struct mount *mp, const char va.va_uid = args->ta_root_uid; va.va_gid = args->ta_root_gid; error = vcache_new(mp, NULL, , NOCRED, ); + if (error) { + mp->mnt_data = NULL; + tmpfs_mntmem_destroy(tmp); + mutex_destroy(>tm_lock); + kmem_free(tmp, sizeof(*tmp)); + return error; + } + KASSERT(vp != NULL); root = VP_TO_TMPFS_NODE(vp); - KASSERT(error == 0 && root != NULL); + KASSERT(root != NULL); /* * Parent of the root inode is itself. Also, root inode has no
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: skrll Date: Mon Aug 22 23:07:36 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: Two fixes from rmind - tmpfs_node_get: restore (decrement) the node count on the error path. - tmpfs_bytes_max: save the value of uvmexp.freetarg (since it is unlocked/racy). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/fs/tmpfs/tmpfs_mem.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_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.8 src/sys/fs/tmpfs/tmpfs_mem.c:1.9 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.8 Fri Jun 13 11:57:48 2014 +++ src/sys/fs/tmpfs/tmpfs_mem.c Mon Aug 22 23:07:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.8 2014/06/13 11:57:48 pooka Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.9 2016/08/22 23:07:36 skrll Exp $ */ /* * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.8 2014/06/13 11:57:48 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_mem.c,v 1.9 2016/08/22 23:07:36 skrll Exp $"); #include #include @@ -116,12 +116,13 @@ uint64_t tmpfs_bytes_max(struct tmpfs_mount *mp) { psize_t freepages = tmpfs_mem_info(false); + int freetarg = uvmexp.freetarg; // XXX unlocked uint64_t avail_mem; - if (freepages < uvmexp.freetarg) { + if (freepages < freetarg) { freepages = 0; } else { - freepages -= uvmexp.freetarg; + freepages -= freetarg; } avail_mem = round_page(mp->tm_bytes_used) + (freepages << PAGE_SHIFT); return MIN(mp->tm_mem_limit, avail_mem); @@ -187,6 +188,7 @@ tmpfs_node_get(struct tmpfs_mount *mp) return NULL; } if (!tmpfs_mem_incr(mp, sizeof(struct tmpfs_node))) { + atomic_dec_uint(>tm_nodes_cnt); return NULL; } return pool_get(_node_pool, PR_WAITOK);
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: skrll Date: Mon Aug 22 23:07:36 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: Two fixes from rmind - tmpfs_node_get: restore (decrement) the node count on the error path. - tmpfs_bytes_max: save the value of uvmexp.freetarg (since it is unlocked/racy). To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/fs/tmpfs/tmpfs_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Sat Mar 12 12:21:37 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Backout previous - need coffee first To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Sat Mar 12 12:21:37 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Backout previous - need coffee first To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.126 src/sys/fs/tmpfs/tmpfs_vnops.c:1.127 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.126 Sat Mar 12 11:45:59 2016 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sat Mar 12 12:21:37 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.126 2016/03/12 11:45:59 martin Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.127 2016/03/12 12:21:37 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.126 2016/03/12 11:45:59 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.127 2016/03/12 12:21:37 martin Exp $"); #include #include @@ -567,7 +567,7 @@ tmpfs_write(void *v) const int ioflag = ap->a_ioflag; tmpfs_node_t *node; struct uvm_object *uobj; - off_t oldsize __diagused; + off_t oldsize; int error; KASSERT(VOP_ISLOCKED(vp));
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Sat Mar 12 11:45:59 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Mark a variable as __diagused. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.125 src/sys/fs/tmpfs/tmpfs_vnops.c:1.126 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.125 Sat Mar 12 10:51:00 2016 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sat Mar 12 11:45:59 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.125 2016/03/12 10:51:00 kardel Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.126 2016/03/12 11:45:59 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.125 2016/03/12 10:51:00 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.126 2016/03/12 11:45:59 martin Exp $"); #include #include @@ -567,7 +567,7 @@ tmpfs_write(void *v) const int ioflag = ap->a_ioflag; tmpfs_node_t *node; struct uvm_object *uobj; - off_t oldsize; + off_t oldsize __diagused; int error; KASSERT(VOP_ISLOCKED(vp));
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Sat Mar 12 11:45:59 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Mark a variable as __diagused. To generate a diff of this commit: cvs rdiff -u -r1.125 -r1.126 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: kardel Date: Sat Mar 12 10:51:01 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: do no access uninitialized variables in KASSERTs - fixes build To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.124 src/sys/fs/tmpfs/tmpfs_vnops.c:1.125 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.124 Sat Mar 12 08:51:13 2016 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sat Mar 12 10:51:00 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.124 2016/03/12 08:51:13 joerg Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.125 2016/03/12 10:51:00 kardel Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.124 2016/03/12 08:51:13 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.125 2016/03/12 10:51:00 kardel Exp $"); #include #include @@ -572,14 +572,14 @@ tmpfs_write(void *v) KASSERT(VOP_ISLOCKED(vp)); + node = VP_TO_TMPFS_NODE(vp); + oldsize = node->tn_size; + if ((vp->v_mount->mnt_flag & MNT_RDONLY) != 0) { error = EROFS; goto out; } - node = VP_TO_TMPFS_NODE(vp); - oldsize = node->tn_size; - if (uio->uio_offset < 0 || vp->v_type != VREG) { error = EINVAL; goto out;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: kardel Date: Sat Mar 12 10:51:01 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: do no access uninitialized variables in KASSERTs - fixes build To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: joerg Date: Sat Mar 12 08:51:13 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c tmpfs_vnops.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.123 -r1.124 src/sys/fs/tmpfs/tmpfs_vnops.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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.66 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.67 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.66 Sat Mar 12 08:45:23 2016 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Sat Mar 12 08:51:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.66 2016/03/12 08:45:23 joerg Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.66 2016/03/12 08:45:23 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.67 2016/03/12 08:51:13 joerg Exp $"); #include #include @@ -210,7 +210,7 @@ tmpfs_mount(struct mount *mp, const char 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, Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.123 src/sys/fs/tmpfs/tmpfs_vnops.c:1.124 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.123 Mon Jul 6 10:07:12 2015 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sat Mar 12 08:51:13 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.123 2015/07/06 10:07:12 hannken Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.124 2016/03/12 08:51:13 joerg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.123 2015/07/06 10:07:12 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.124 2016/03/12 08:51:13 joerg Exp $"); #include #include @@ -572,6 +572,11 @@ tmpfs_write(void *v) 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; @@ -1242,6 +1247,11 @@ tmpfs_putpages(void *v) 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;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: joerg Date: Sat Mar 12 08:51:13 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c tmpfs_vnops.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.123 -r1.124 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: joerg Date: Sat Mar 12 08:45:23 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Only recheck size/node limits on update mounts, if there actually have been specified. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.65 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.66 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.65 Mon Jul 6 10:07:12 2015 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Sat Mar 12 08:45:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.65 2015/07/06 10:07:12 hannken Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.66 2016/03/12 08:45:23 joerg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.65 2015/07/06 10:07:12 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.66 2016/03/12 08:45:23 joerg Exp $"); #include #include @@ -93,6 +93,8 @@ tmpfs_mount(struct mount *mp, const char uint64_t memlimit; ino_t nodes; int error; + bool set_memlimit; + bool set_nodes; if (args == NULL) return EINVAL; @@ -137,26 +139,33 @@ tmpfs_mount(struct mount *mp, const char /* 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;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: joerg Date: Sat Mar 12 08:45:23 UTC 2016 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Only recheck size/node limits on update mounts, if there actually have been specified. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: leot Date: Thu Oct 29 16:19:44 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Make sure that nde->td_node is NULL for asserts. Thanks and from Mindaugas Rasiukevicius. Fixes PR kern/50381. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: leot Date: Thu Oct 29 16:19:44 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Make sure that nde->td_node is NULL for asserts. Thanks and from Mindaugas Rasiukevicius. Fixes PR kern/50381. To generate a diff of this commit: cvs rdiff -u -r1.100 -r1.101 src/sys/fs/tmpfs/tmpfs_subr.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.100 src/sys/fs/tmpfs/tmpfs_subr.c:1.101 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.100 Tue Jul 7 09:30:24 2015 +++ src/sys/fs/tmpfs/tmpfs_subr.c Thu Oct 29 16:19:44 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.100 2015/07/07 09:30:24 justin Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.101 2015/10/29 16:19:44 leot Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.100 2015/07/07 09:30:24 justin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.101 2015/10/29 16:19:44 leot Exp $"); #include #include @@ -459,6 +459,7 @@ tmpfs_alloc_dirent(tmpfs_mount_t *tmp, c nde->td_namelen = len; memcpy(nde->td_name, name, len); nde->td_seq = TMPFS_DIRSEQ_NONE; + nde->td_node = NULL; /* for asserts */ *de = nde; return 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: justin Date: Tue Jul 7 09:30:24 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: This enum is likely to be made unsigned by the compiler, so the assertion will not work and clang objects with -Wtautological-constant-out-of-range-compare To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/fs/tmpfs/tmpfs_subr.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.99 src/sys/fs/tmpfs/tmpfs_subr.c:1.100 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.99 Mon Jul 6 10:07:12 2015 +++ src/sys/fs/tmpfs/tmpfs_subr.c Tue Jul 7 09:30:24 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.99 2015/07/06 10:07:12 hannken Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.100 2015/07/07 09:30:24 justin Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.99 2015/07/06 10:07:12 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.100 2015/07/07 09:30:24 justin Exp $); #include sys/param.h #include sys/cprng.h @@ -222,7 +222,7 @@ tmpfs_newvnode(struct mount *mp, struct } while (node-tn_gen == 0); /* Generic initialization. */ - KASSERT(vap-va_type != VNOVAL); + KASSERT((int)vap-va_type != VNOVAL); node-tn_type = vap-va_type; node-tn_size = 0; node-tn_flags = 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: justin Date: Tue Jul 7 09:30:24 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: This enum is likely to be made unsigned by the compiler, so the assertion will not work and clang objects with -Wtautological-constant-out-of-range-compare To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Mon Jul 6 10:05:50 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_vfsops.c Log Message: Use VFS_PROTOS() for tmpfs. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.63 -r1.64 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Mon Jul 6 10:07:12 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_rename.c tmpfs_subr.c tmpfs_vfsops.c tmpfs_vnops.c Log Message: Change tmpfs to vcache. - Use tmpfs node address as key. - Remove tn_vlock, field tn_vnode now protected by vcache. - Add a hold count to tmpfs node to prevent nodes from disappearing while tmpfs_fhtovp() trys to vcache_get() them. Last holder destroys reclaimed nodes. - Remove the now unneeded parent unlock/lock for lookup of '..'. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.6 -r1.7 src/sys/fs/tmpfs/tmpfs_rename.c cvs rdiff -u -r1.98 -r1.99 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.122 -r1.123 src/sys/fs/tmpfs/tmpfs_vnops.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.51 src/sys/fs/tmpfs/tmpfs.h:1.52 --- src/sys/fs/tmpfs/tmpfs.h:1.51 Mon Jul 6 10:05:50 2015 +++ src/sys/fs/tmpfs/tmpfs.h Mon Jul 6 10:07:12 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.51 2015/07/06 10:05:50 hannken Exp $ */ +/* $NetBSD: tmpfs.h,v 1.52 2015/07/06 10:07:12 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -72,7 +72,7 @@ TAILQ_HEAD(tmpfs_dir, tmpfs_dirent); * a particular type. * * All fields are protected by vnode lock. The vnode association itself - * is protected by tmpfs_node_t::tn_vlock. + * is protected by vcache. */ typedef struct tmpfs_node { LIST_ENTRY(tmpfs_node) tn_entries; @@ -88,9 +88,11 @@ typedef struct tmpfs_node { * tn_vnode. It may be NULL when the node is unused (that is, * no vnode has been allocated or it has been reclaimed). */ - kmutex_t tn_vlock; vnode_t * tn_vnode; + /* Prevent node from being reclaimed. */ + uint32_t tn_holdcount; + /* Directory entry. Only a hint, since hard link can have multiple. */ tmpfs_dirent_t * tn_dirent_hint; @@ -188,16 +190,12 @@ CTASSERT(TMPFS_MAXNAMLEN UINT16_MAX); #define TMPFS_UPDATE_CTIME 0x04 /* - * Bits indicating vnode reclamation and whiteout use for the directory. + * Bits indicating whiteout use for the directory. * We abuse tmpfs_node_t::tn_gen for that. */ -#define TMPFS_RECLAIMING_BIT (1U 31) -#define TMPFS_WHITEOUT_BIT (1U 30) +#define TMPFS_WHITEOUT_BIT (1U 31) #define TMPFS_NODE_GEN_MASK (TMPFS_WHITEOUT_BIT - 1) -#define TMPFS_NODE_RECLAIMING(node) \ -(((node)-tn_gen TMPFS_RECLAIMING_BIT) != 0) - #define TMPFS_NODE_GEN(node) \ ((node)-tn_gen TMPFS_NODE_GEN_MASK) @@ -205,6 +203,12 @@ CTASSERT(TMPFS_MAXNAMLEN UINT16_MAX); #define TMPFS_NODE_WHITEOUT ((tmpfs_node_t *)-1) /* + * Bit indicating this node must be reclaimed when holdcount reaches zero. + * Ored into tmpfs_node_t::tn_holdcount. + */ +#define TMPFS_NODE_RECLAIMED (1U 30) + +/* * Internal representation of a tmpfs mount point. */ typedef struct tmpfs_mount { @@ -242,15 +246,11 @@ typedef struct tmpfs_fid { * Prototypes for tmpfs_subr.c. */ -int tmpfs_alloc_node(tmpfs_mount_t *, enum vtype, uid_t, gid_t, - mode_t, char *, dev_t, tmpfs_node_t **); void tmpfs_free_node(tmpfs_mount_t *, tmpfs_node_t *); int tmpfs_construct_node(vnode_t *, vnode_t **, struct vattr *, struct componentname *, char *); -int tmpfs_vnode_get(struct mount *, tmpfs_node_t *, vnode_t **); - int tmpfs_alloc_dirent(tmpfs_mount_t *, const char *, uint16_t, tmpfs_dirent_t **); void tmpfs_free_dirent(tmpfs_mount_t *, tmpfs_dirent_t *); Index: src/sys/fs/tmpfs/tmpfs_rename.c diff -u src/sys/fs/tmpfs/tmpfs_rename.c:1.6 src/sys/fs/tmpfs/tmpfs_rename.c:1.7 --- src/sys/fs/tmpfs/tmpfs_rename.c:1.6 Sat Nov 23 16:35:32 2013 +++ src/sys/fs/tmpfs/tmpfs_rename.c Mon Jul 6 10:07:12 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_rename.c,v 1.6 2013/11/23 16:35:32 rmind Exp $ */ +/* $NetBSD: tmpfs_rename.c,v 1.7 2015/07/06 10:07:12 hannken Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_rename.c,v 1.6 2013/11/23 16:35:32 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_rename.c,v 1.7 2015/07/06 10:07:12 hannken Exp $); #include sys/param.h #include sys/errno.h @@ -425,7 +425,7 @@ tmpfs_gro_lookup(struct mount *mp, struc { struct tmpfs_dirent *dirent, **dep_ret = de_ret; struct vnode *vp; - int error; + int error __diagused; (void)mp; KASSERT(mp != NULL); @@ -439,27 +439,15 @@ tmpfs_gro_lookup(struct mount *mp, struc if (dirent == NULL) return ENOENT; - mutex_enter(dirent-td_node-tn_vlock); - error = tmpfs_vnode_get(mp, dirent-td_node, vp); - /* Note: tmpfs_vnode_get always releases dirent-td_node-tn_vlock. */ + error = vcache_get(mp, dirent-td_node, sizeof(dirent-td_node), vp); if
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Mon Jul 6 10:07:12 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_rename.c tmpfs_subr.c tmpfs_vfsops.c tmpfs_vnops.c Log Message: Change tmpfs to vcache. - Use tmpfs node address as key. - Remove tn_vlock, field tn_vnode now protected by vcache. - Add a hold count to tmpfs node to prevent nodes from disappearing while tmpfs_fhtovp() trys to vcache_get() them. Last holder destroys reclaimed nodes. - Remove the now unneeded parent unlock/lock for lookup of '..'. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.6 -r1.7 src/sys/fs/tmpfs/tmpfs_rename.c cvs rdiff -u -r1.98 -r1.99 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.64 -r1.65 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.122 -r1.123 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: wiz Date: Mon Jul 6 10:24:59 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Fix typo in comment. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/fs/tmpfs/tmpfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: wiz Date: Mon Jul 6 10:24:59 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs_rename.c Log Message: Fix typo in comment. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/fs/tmpfs/tmpfs_rename.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_rename.c diff -u src/sys/fs/tmpfs/tmpfs_rename.c:1.7 src/sys/fs/tmpfs/tmpfs_rename.c:1.8 --- src/sys/fs/tmpfs/tmpfs_rename.c:1.7 Mon Jul 6 10:07:12 2015 +++ src/sys/fs/tmpfs/tmpfs_rename.c Mon Jul 6 10:24:59 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_rename.c,v 1.7 2015/07/06 10:07:12 hannken Exp $ */ +/* $NetBSD: tmpfs_rename.c,v 1.8 2015/07/06 10:24:59 wiz Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_rename.c,v 1.7 2015/07/06 10:07:12 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_rename.c,v 1.8 2015/07/06 10:24:59 wiz Exp $); #include sys/param.h #include sys/errno.h @@ -446,7 +446,7 @@ tmpfs_gro_lookup(struct mount *mp, struc /* * XXX Once namei is fixed, we can change the genfs_rename - * protocol so that we have to lock vp her. + * protocol so that we have to lock vp here. */ *dep_ret = dirent;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Mon Jul 6 10:05:50 UTC 2015 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_vfsops.c Log Message: Use VFS_PROTOS() for tmpfs. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.63 -r1.64 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.50 src/sys/fs/tmpfs/tmpfs.h:1.51 --- src/sys/fs/tmpfs/tmpfs.h:1.50 Sat Jun 7 09:54:34 2014 +++ src/sys/fs/tmpfs/tmpfs.h Mon Jul 6 10:05:50 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.50 2014/06/07 09:54:34 martin Exp $ */ +/* $NetBSD: tmpfs.h,v 1.51 2015/07/06 10:05:50 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -160,6 +160,8 @@ typedef struct tmpfs_node { #if defined(_KERNEL) +VFS_PROTOS(tmpfs); + LIST_HEAD(tmpfs_node_list, tmpfs_node); #define TMPFS_MAXNAMLEN 255 Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.64 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63 Tue Jun 10 16:10:59 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Mon Jul 6 10:05:50 2015 @@ -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.64 2015/07/06 10:05:50 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.63 2014/06/10 16:10:59 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.64 2015/07/06 10:05:50 hannken Exp $); #include sys/param.h #include sys/types.h @@ -62,20 +62,7 @@ MODULE(MODULE_CLASS_VFS, tmpfs, NULL); struct pool tmpfs_dirent_pool; struct pool tmpfs_node_pool; -static int tmpfs_mount(struct mount *, const char *, void *, size_t *); -static int tmpfs_start(struct mount *, int); -static int tmpfs_unmount(struct mount *, int); -static int tmpfs_root(struct mount *, vnode_t **); -static int tmpfs_vget(struct mount *, ino_t, vnode_t **); -static int tmpfs_fhtovp(struct mount *, struct fid *, vnode_t **); -static int tmpfs_vptofh(struct vnode *, struct fid *, size_t *); -static int tmpfs_statvfs(struct mount *, struct statvfs *); -static int tmpfs_sync(struct mount *, int, kauth_cred_t); -static void tmpfs_init(void); -static void tmpfs_done(void); -static int tmpfs_snapshot(struct mount *, vnode_t *, struct timespec *); - -static void +void tmpfs_init(void) { @@ -85,7 +72,7 @@ tmpfs_init(void) tmpfs_node, pool_allocator_nointr, IPL_NONE); } -static void +void tmpfs_done(void) { @@ -93,7 +80,7 @@ tmpfs_done(void) pool_destroy(tmpfs_node_pool); } -static int +int tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len) { struct tmpfs_args *args = data; @@ -216,14 +203,14 @@ tmpfs_mount(struct mount *mp, const char return error; } -static int +int tmpfs_start(struct mount *mp, int flags) { return 0; } -static int +int tmpfs_unmount(struct mount *mp, int mntflags) { tmpfs_mount_t *tmp = VFS_TO_TMPFS(mp); @@ -280,7 +267,7 @@ tmpfs_unmount(struct mount *mp, int mntf return 0; } -static int +int tmpfs_root(struct mount *mp, vnode_t **vpp) { tmpfs_node_t *node = VFS_TO_TMPFS(mp)-tm_root; @@ -289,14 +276,14 @@ tmpfs_root(struct mount *mp, vnode_t **v return tmpfs_vnode_get(mp, node, vpp); } -static int +int tmpfs_vget(struct mount *mp, ino_t ino, vnode_t **vpp) { return EOPNOTSUPP; } -static int +int tmpfs_fhtovp(struct mount *mp, struct fid *fhp, vnode_t **vpp) { tmpfs_mount_t *tmp = VFS_TO_TMPFS(mp); @@ -332,7 +319,7 @@ tmpfs_fhtovp(struct mount *mp, struct fi return 0; } -static int +int tmpfs_vptofh(vnode_t *vp, struct fid *fhp, size_t *fh_size) { tmpfs_fid_t tfh; @@ -354,7 +341,7 @@ tmpfs_vptofh(vnode_t *vp, struct fid *fh return 0; } -static int +int tmpfs_statvfs(struct mount *mp, struct statvfs *sbp) { tmpfs_mount_t *tmp; @@ -384,14 +371,14 @@ tmpfs_statvfs(struct mount *mp, struct s return 0; } -static int +int tmpfs_sync(struct mount *mp, int waitfor, kauth_cred_t uc) { return 0; } -static int +int tmpfs_snapshot(struct mount *mp, vnode_t *vp, struct timespec *ctime) {
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: gson Date: Mon Sep 8 14:49:47 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c tmpfs_vnops.c Log Message: Store symlinks without a NUL terminator so that lstat(2) returns the correct length. Fixes the tmpfs part of PR kern/48864. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.120 -r1.121 src/sys/fs/tmpfs/tmpfs_vnops.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_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.96 src/sys/fs/tmpfs/tmpfs_subr.c:1.97 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.96 Thu Jan 23 10:13:56 2014 +++ src/sys/fs/tmpfs/tmpfs_subr.c Mon Sep 8 14:49:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.96 2014/01/23 10:13:56 hannken Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.97 2014/09/08 14:49:46 gson Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -74,7 +74,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.96 2014/01/23 10:13:56 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_subr.c,v 1.97 2014/09/08 14:49:46 gson Exp $); #include sys/param.h #include sys/cprng.h @@ -185,7 +185,6 @@ tmpfs_alloc_node(tmpfs_mount_t *tmp, enu } KASSERT(nnode-tn_size MAXPATHLEN); - nnode-tn_size++; /* include the NUL terminator */ nnode-tn_spec.tn_lnk.tn_link = tmpfs_strname_alloc(tmp, nnode-tn_size); Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.120 src/sys/fs/tmpfs/tmpfs_vnops.c:1.121 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.120 Fri Jul 25 08:20:52 2014 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Mon Sep 8 14:49:46 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.120 2014/07/25 08:20:52 dholland Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.121 2014/09/08 14:49:46 gson 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 2014/07/25 08:20:52 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.121 2014/09/08 14:49:46 gson Exp $); #include sys/param.h #include sys/dirent.h @@ -1036,7 +1036,7 @@ tmpfs_readlink(void *v) /* Note: readlink(2) returns the path without NUL terminator. */ if (node-tn_size 0) { error = uiomove(node-tn_spec.tn_lnk.tn_link, - MIN(node-tn_size - 1, uio-uio_resid), uio); + MIN(node-tn_size, uio-uio_resid), uio); } else { error = 0; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: gson Date: Mon Sep 8 14:49:47 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c tmpfs_vnops.c Log Message: Store symlinks without a NUL terminator so that lstat(2) returns the correct length. Fixes the tmpfs part of PR kern/48864. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/fs/tmpfs/tmpfs_subr.c cvs rdiff -u -r1.120 -r1.121 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: pooka Date: Fri Jun 13 11:57:48 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: use psize_t for physical memory calculation To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/fs/tmpfs/tmpfs_mem.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_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.7 src/sys/fs/tmpfs/tmpfs_mem.c:1.8 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.7 Tue Jun 10 15:44:27 2014 +++ src/sys/fs/tmpfs/tmpfs_mem.c Fri Jun 13 11:57:48 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.7 2014/06/10 15:44:27 martin Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.8 2014/06/13 11:57:48 pooka 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.7 2014/06/10 15:44:27 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_mem.c,v 1.8 2014/06/13 11:57:48 pooka Exp $); #include sys/param.h #include sys/atomic.h @@ -115,7 +115,7 @@ tmpfs_mem_info(bool total) uint64_t tmpfs_bytes_max(struct tmpfs_mount *mp) { - size_t freepages = tmpfs_mem_info(false); + psize_t freepages = tmpfs_mem_info(false); uint64_t avail_mem; if (freepages uvmexp.freetarg) { @@ -123,8 +123,7 @@ tmpfs_bytes_max(struct tmpfs_mount *mp) } else { freepages -= uvmexp.freetarg; } - avail_mem = round_page(mp-tm_bytes_used) - + ((uint64_t)freepages PAGE_SHIFT); + avail_mem = round_page(mp-tm_bytes_used) + (freepages PAGE_SHIFT); return MIN(mp-tm_mem_limit, avail_mem); }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: pooka Date: Fri Jun 13 11:57:48 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: use psize_t for physical memory calculation To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/fs/tmpfs/tmpfs_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Tue Jun 10 15:44:27 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: Make sure to expand freepages to 64bit before shifting to byte values - on rump we may have all our virtual address space free. Pointed out by pooka@. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/fs/tmpfs/tmpfs_mem.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_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.6 src/sys/fs/tmpfs/tmpfs_mem.c:1.7 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.6 Sat Jun 7 09:54:34 2014 +++ src/sys/fs/tmpfs/tmpfs_mem.c Tue Jun 10 15:44:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.6 2014/06/07 09:54:34 martin Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.7 2014/06/10 15:44:27 martin 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.6 2014/06/07 09:54:34 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_mem.c,v 1.7 2014/06/10 15:44:27 martin Exp $); #include sys/param.h #include sys/atomic.h @@ -123,7 +123,8 @@ tmpfs_bytes_max(struct tmpfs_mount *mp) } else { freepages -= uvmexp.freetarg; } - avail_mem = round_page(mp-tm_bytes_used) + (freepages PAGE_SHIFT); + avail_mem = round_page(mp-tm_bytes_used) + + ((uint64_t)freepages PAGE_SHIFT); return MIN(mp-tm_mem_limit, avail_mem); }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Tue Jun 10 16:10:59 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Check for invalid mount arguments early and gracefully fail the mount. Spotted by pooka@ To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.62 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.63 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.62 Sat Jun 7 09:54:34 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Tue Jun 10 16:10:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin 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.62 2014/06/07 09:54:34 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin Exp $); #include sys/param.h #include sys/types.h @@ -135,6 +135,14 @@ tmpfs_mount(struct mount *mp, const char if (tmpfs_mem_info(true) uvmexp.freetarg) return EINVAL; + /* Check for invalid uid and gid arguments */ + if (args-ta_root_uid == VNOVAL || args-ta_root_gid == VNOVAL) + return EINVAL; + + /* This can never happen? */ + if ((args-ta_root_mode ALLPERMS) == VNOVAL) + return EINVAL; + /* Get the memory usage limit for this file-system. */ if (args-ta_size_max PAGE_SIZE) { memlimit = UINT64_MAX;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Tue Jun 10 15:44:27 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_mem.c Log Message: Make sure to expand freepages to 64bit before shifting to byte values - on rump we may have all our virtual address space free. Pointed out by pooka@. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/fs/tmpfs/tmpfs_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Tue Jun 10 16:10:59 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Check for invalid mount arguments early and gracefully fail the mount. Spotted by pooka@ To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Sat Jun 7 09:54:34 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_mem.c tmpfs_vfsops.c Log Message: Remove the hardcoded 4 MB free kernel memory limit and replace it by uvmexp.freetarg, as discussed on tech-kern. Main purpose is to make tmpfs usable (as far as possible) on small memory machines. This is a bit experimental, but we need to give it some real world exposure to see how well it works. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.5 -r1.6 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.61 -r1.62 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.49 src/sys/fs/tmpfs/tmpfs.h:1.50 --- src/sys/fs/tmpfs/tmpfs.h:1.49 Wed Apr 30 01:33:51 2014 +++ src/sys/fs/tmpfs/tmpfs.h Sat Jun 7 09:54:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.49 2014/04/30 01:33:51 christos Exp $ */ +/* $NetBSD: tmpfs.h,v 1.50 2014/06/07 09:54:34 martin Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -307,13 +307,6 @@ bool tmpfs_strname_neqlen(struct compon KASSERT((node)-tn_size % sizeof(tmpfs_dirent_t) == 0); /* - * Memory management stuff. - */ - -/* Amount of memory pages to reserve for the system. */ -#define TMPFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE) - -/* * Routines to convert VFS structures to tmpfs internal ones. */ Index: src/sys/fs/tmpfs/tmpfs_mem.c diff -u src/sys/fs/tmpfs/tmpfs_mem.c:1.5 src/sys/fs/tmpfs/tmpfs_mem.c:1.6 --- src/sys/fs/tmpfs/tmpfs_mem.c:1.5 Wed Apr 30 01:33:51 2014 +++ src/sys/fs/tmpfs/tmpfs_mem.c Sat Jun 7 09:54:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_mem.c,v 1.5 2014/04/30 01:33:51 christos Exp $ */ +/* $NetBSD: tmpfs_mem.c,v 1.6 2014/06/07 09:54:34 martin 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.5 2014/04/30 01:33:51 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_mem.c,v 1.6 2014/06/07 09:54:34 martin Exp $); #include sys/param.h #include sys/atomic.h @@ -89,7 +89,7 @@ tmpfs_mntmem_set(struct tmpfs_mount *mp, * = If 'total' is true, then return _total_ amount of pages. * = If false, then return the amount of _free_ memory pages. * - * Remember to remove TMPFS_PAGES_RESERVED from the returned value to avoid + * Remember to remove uvmexp.freetarg from the returned value to avoid * excessive memory usage. */ size_t @@ -118,10 +118,10 @@ tmpfs_bytes_max(struct tmpfs_mount *mp) size_t freepages = tmpfs_mem_info(false); uint64_t avail_mem; - if (freepages TMPFS_PAGES_RESERVED) { + if (freepages uvmexp.freetarg) { freepages = 0; } else { - freepages -= TMPFS_PAGES_RESERVED; + freepages -= uvmexp.freetarg; } avail_mem = round_page(mp-tm_bytes_used) + (freepages PAGE_SHIFT); return MIN(mp-tm_mem_limit, avail_mem); Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.61 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.62 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.61 Wed Apr 30 01:59:30 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Sat Jun 7 09:54:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.61 2014/04/30 01:59:30 christos Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin 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.61 2014/04/30 01:59:30 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.62 2014/06/07 09:54:34 martin Exp $); #include sys/param.h #include sys/types.h @@ -132,7 +132,7 @@ tmpfs_mount(struct mount *mp, const char /* Prohibit mounts if there is not enough memory. */ - if (tmpfs_mem_info(true) TMPFS_PAGES_RESERVED) + if (tmpfs_mem_info(true) uvmexp.freetarg) return EINVAL; /* Get the memory usage limit for this file-system. */
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: martin Date: Sat Jun 7 09:54:34 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_mem.c tmpfs_vfsops.c Log Message: Remove the hardcoded 4 MB free kernel memory limit and replace it by uvmexp.freetarg, as discussed on tech-kern. Main purpose is to make tmpfs usable (as far as possible) on small memory machines. This is a bit experimental, but we need to give it some real world exposure to see how well it works. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.5 -r1.6 src/sys/fs/tmpfs/tmpfs_mem.c cvs rdiff -u -r1.61 -r1.62 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Mon May 26 19:12:07 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_mknod: it is not our responsibility to call vput() on the directory vnode, so remove it (and ensure *vpp is NULL while here). To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.118 src/sys/fs/tmpfs/tmpfs_vnops.c:1.119 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.118 Thu Feb 27 16:51:38 2014 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Mon May 26 19:12:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.118 2014/02/27 16:51:38 hannken Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.119 2014/05/26 19:12:07 rmind 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.118 2014/02/27 16:51:38 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.119 2014/05/26 19:12:07 rmind Exp $); #include sys/param.h #include sys/dirent.h @@ -343,7 +343,7 @@ tmpfs_mknod(void *v) enum vtype vt = vap-va_type; if (vt != VBLK vt != VCHR vt != VFIFO) { - vput(dvp); + *vpp = NULL; return EINVAL; } return tmpfs_construct_node(dvp, vpp, vap, cnp, NULL);
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: rmind Date: Mon May 26 19:12:07 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: tmpfs_mknod: it is not our responsibility to call vput() on the directory vnode, so remove it (and ensure *vpp is NULL while here). To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
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)
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: christos Date: Wed Apr 30 01:59:30 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: fix typo To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.60 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.61 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.60 Tue Apr 29 21:33:51 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Tue Apr 29 21:59:30 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.60 2014/04/30 01:33:51 christos Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.61 2014/04/30 01:59:30 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.60 2014/04/30 01:33:51 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.61 2014/04/30 01:59:30 christos Exp $); #include sys/param.h #include sys/types.h @@ -158,7 +158,7 @@ tmpfs_mount(struct mount *mp, const char if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0) return error; tmp-tm_nodes_max = nodes; - root = tmp-tm_rooto + root = tmp-tm_root; root-tn_uid = args-ta_root_uid; root-tn_gid = args-ta_root_gid; root-tn_mode = args-ta_root_mode;
CVS commit: src/sys/fs/tmpfs
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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: christos Date: Wed Apr 30 01:59:30 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: fix typo To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Mon Feb 17 20:16:52 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Adapt my previous patch differently. read(2) wants EISDIR when the object is a directory. Which also means that tmpfs_read() was returning a wrong error code when dealing with non-regular vnodes. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.116 src/sys/fs/tmpfs/tmpfs_vnops.c:1.117 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.116 Sun Feb 16 12:54:07 2014 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Mon Feb 17 20:16:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.116 2014/02/16 12:54:07 maxv Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.117 2014/02/17 20:16:52 maxv 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.116 2014/02/16 12:54:07 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.117 2014/02/17 20:16:52 maxv Exp $); #include sys/param.h #include sys/dirent.h @@ -534,6 +534,9 @@ tmpfs_read(void *v) KASSERT(VOP_ISLOCKED(vp)); + if (vp-v_type == VDIR) { + return EISDIR; + } if (uio-uio_offset 0 || vp-v_type != VREG) { return EINVAL; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Mon Feb 17 20:16:52 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Adapt my previous patch differently. read(2) wants EISDIR when the object is a directory. Which also means that tmpfs_read() was returning a wrong error code when dealing with non-regular vnodes. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Sun Feb 16 12:54:07 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Fix tmpfs_read()'s return value; it should return EINVAL. Now consistent with tmpfs_write(). ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.115 src/sys/fs/tmpfs/tmpfs_vnops.c:1.116 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.115 Fri Feb 7 15:29:22 2014 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Sun Feb 16 12:54:07 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.115 2014/02/07 15:29:22 hannken Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.116 2014/02/16 12:54:07 maxv 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.115 2014/02/07 15:29:22 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.116 2014/02/16 12:54:07 maxv Exp $); #include sys/param.h #include sys/dirent.h @@ -534,10 +534,7 @@ tmpfs_read(void *v) KASSERT(VOP_ISLOCKED(vp)); - if (vp-v_type != VREG) { - return EISDIR; - } - if (uio-uio_offset 0) { + if (uio-uio_offset 0 || vp-v_type != VREG) { return EINVAL; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: maxv Date: Sun Feb 16 12:54:07 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Fix tmpfs_read()'s return value; it should return EINVAL. Now consistent with tmpfs_write(). ok christos@ To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Feb 6 16:18:38 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Remove an annoying printf. And to answer the question: VFS_VGET() gets used by NFS V3 server for readdirplus. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 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_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.56 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.57 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.56 Sat Jan 4 12:36:49 2014 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Thu Feb 6 16:18:38 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.56 2014/01/04 12:36:49 hannken Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.57 2014/02/06 16:18:38 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.56 2014/01/04 12:36:49 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vfsops.c,v 1.57 2014/02/06 16:18:38 hannken Exp $); #include sys/param.h #include sys/types.h @@ -272,7 +272,6 @@ static int tmpfs_vget(struct mount *mp, ino_t ino, vnode_t **vpp) { - printf(tmpfs_vget called; need for it unknown yet\n); return EOPNOTSUPP; }
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Feb 6 16:18:38 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c Log Message: Remove an annoying printf. And to answer the question: VFS_VGET() gets used by NFS V3 server for readdirplus. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 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.
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: pedro Date: Fri Jan 10 16:42:38 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Prevent a diagnostic assertion in tmpfs_rmdir() from being triggered through an rmdir on .. by moving it so it happens after the check for empty directories; OK rmind@. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/fs/tmpfs/tmpfs_vnops.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_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.111 src/sys/fs/tmpfs/tmpfs_vnops.c:1.112 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.111 Fri Jan 3 09:53:12 2014 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Fri Jan 10 16:42:38 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.111 2014/01/03 09:53:12 hannken Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.112 2014/01/10 16:42:38 pedro 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.111 2014/01/03 09:53:12 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: tmpfs_vnops.c,v 1.112 2014/01/10 16:42:38 pedro Exp $); #include sys/param.h #include sys/dirent.h @@ -837,7 +837,6 @@ tmpfs_rmdir(void *v) KASSERT(VOP_ISLOCKED(dvp)); KASSERT(VOP_ISLOCKED(vp)); - KASSERT(node-tn_spec.tn_dir.tn_parent == dnode); /* * Directories with more than two entries ('.' and '..') cannot be @@ -861,6 +860,8 @@ tmpfs_rmdir(void *v) KASSERT(error == 0); } + KASSERT(node-tn_spec.tn_dir.tn_parent == dnode); + /* Lookup the directory entry (check the cached hint first). */ de = tmpfs_dir_cached(node); if (de == NULL) {
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: pedro Date: Fri Jan 10 16:42:38 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Prevent a diagnostic assertion in tmpfs_rmdir() from being triggered through an rmdir on .. by moving it so it happens after the check for empty directories; OK rmind@. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/fs/tmpfs
J. Hannken-Illjes hann...@eis.cs.tu-bs.de wrote: On Jan 8, 2014, at 5:11 PM, pedro martelletto pe...@netbsd.org wrote: Module Name:src Committed By: pedro Date: Wed Jan 8 16:11:04 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Allocate direntp on the stack in tmpfs_dir_getdents(), thus saving calls to kmem_zalloc() and kmem_free(); OK rmind@. From OpenBSD. Is it really a good idea to allocate 528 bytes on the kernel stack? File systems nest and already use much stack space. It is harmless in this case since we get a few or more pages for the stack. Looks better to use a pool_cache. It is worth to create a separate pool_cache(9) only if the allocations can potentially be very intensive. -- Mindaugas
Re: CVS commit: src/sys/fs/tmpfs
On Jan 8, 2014, at 5:11 PM, pedro martelletto pe...@netbsd.org wrote: Module Name: src Committed By: pedro Date: Wed Jan 8 16:11:04 UTC 2014 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Allocate direntp on the stack in tmpfs_dir_getdents(), thus saving calls to kmem_zalloc() and kmem_free(); OK rmind@. From OpenBSD. Is it really a good idea to allocate 528 bytes on the kernel stack? File systems nest and already use much stack space. Looks better to use a pool_cache. -- J. Hannken-Illjes - hann...@eis.cs.tu-bs.de - TU Braunschweig (Germany)