Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move lfs_getpages and lfs_putpages to their own file.
details: https://anonhg.NetBSD.org/src/rev/2280aa4300c0
branches: trunk
changeset: 329245:2280aa4300c0
user: dholland <dholland%NetBSD.org@localhost>
date: Fri May 16 09:34:03 2014 +0000
description:
Move lfs_getpages and lfs_putpages to their own file.
diffstat:
sys/modules/lfs/Makefile | 6 +-
sys/rump/fs/lib/liblfs/Makefile | 6 +-
sys/ufs/files.ufs | 3 +-
sys/ufs/lfs/lfs_pages.c | 893 ++++++++++++++++++++++++++++++++++++++++
sys/ufs/lfs/lfs_vnops.c | 791 +-----------------------------------
5 files changed, 903 insertions(+), 796 deletions(-)
diffs (truncated from 1773 to 300 lines):
diff -r 2988408f32ca -r 2280aa4300c0 sys/modules/lfs/Makefile
--- a/sys/modules/lfs/Makefile Fri May 16 08:59:24 2014 +0000
+++ b/sys/modules/lfs/Makefile Fri May 16 09:34:03 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2014/03/18 18:20:43 riastradh Exp $
+# $NetBSD: Makefile,v 1.7 2014/05/16 09:34:03 dholland Exp $
.include "../Makefile.inc"
@@ -10,8 +10,8 @@
CPPFLAGS+=#-DLFS_DIRHASH -DLFS_EI -DLFS_QUOTA -DLFS_QUOTA2
SRCS= lfs_vfsops.c lfs_vnops.c lfs_subr.c lfs_alloc.c lfs_balloc.c \
- lfs_bio.c lfs_cksum.c lfs_debug.c lfs_inode.c lfs_segment.c \
- lfs_rename.c lfs_syscalls.c lfs_itimes.c
+ lfs_bio.c lfs_cksum.c lfs_debug.c lfs_inode.c lfs_pages.c \
+ lfs_segment.c lfs_rename.c lfs_syscalls.c lfs_itimes.c
SRCS+= ulfs_bmap.c ulfs_dirhash.c ulfs_ihash.c ulfs_inode.c ulfs_lookup.c \
ulfs_snapshot.c ulfs_vfsops.c ulfs_vnops.c
diff -r 2988408f32ca -r 2280aa4300c0 sys/rump/fs/lib/liblfs/Makefile
--- a/sys/rump/fs/lib/liblfs/Makefile Fri May 16 08:59:24 2014 +0000
+++ b/sys/rump/fs/lib/liblfs/Makefile Fri May 16 09:34:03 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2014/03/18 18:20:44 riastradh Exp $
+# $NetBSD: Makefile,v 1.11 2014/05/16 09:34:03 dholland Exp $
#
.PATH: ${.CURDIR}/../../../../ufs/lfs
@@ -6,8 +6,8 @@
LIB= rumpfs_lfs
SRCS= lfs_alloc.c lfs_balloc.c lfs_bio.c lfs_cksum.c lfs_debug.c \
- lfs_inode.c lfs_itimes.c lfs_rename.c lfs_rfw.c lfs_segment.c \
- lfs_subr.c lfs_syscalls.c lfs_vfsops.c lfs_vnops.c
+ lfs_inode.c lfs_itimes.c lfs_pages.c lfs_rename.c lfs_rfw.c \
+ lfs_segment.c lfs_subr.c lfs_syscalls.c lfs_vfsops.c lfs_vnops.c
SRCS+= ulfs_bmap.c ulfs_dirhash.c ulfs_extattr.c ulfs_ihash.c \
ulfs_inode.c ulfs_lookup.c ulfs_quota.c ulfs_quota1.c \
diff -r 2988408f32ca -r 2280aa4300c0 sys/ufs/files.ufs
--- a/sys/ufs/files.ufs Fri May 16 08:59:24 2014 +0000
+++ b/sys/ufs/files.ufs Fri May 16 09:34:03 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.ufs,v 1.35 2014/05/08 08:21:53 hannken Exp $
+# $NetBSD: files.ufs,v 1.36 2014/05/16 09:34:03 dholland Exp $
deffs FFS
deffs EXT2FS
@@ -65,6 +65,7 @@
file ufs/lfs/lfs_debug.c lfs
file ufs/lfs/lfs_inode.c lfs
file ufs/lfs/lfs_itimes.c lfs
+file ufs/lfs/lfs_pages.c lfs
file ufs/lfs/lfs_rename.c lfs
file ufs/lfs/lfs_rfw.c lfs & lfs_kernel_rfw
file ufs/lfs/lfs_segment.c lfs
diff -r 2988408f32ca -r 2280aa4300c0 sys/ufs/lfs/lfs_pages.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ufs/lfs/lfs_pages.c Fri May 16 09:34:03 2014 +0000
@@ -0,0 +1,893 @@
+/* $NetBSD: lfs_pages.c,v 1.1 2014/05/16 09:34:03 dholland Exp $ */
+
+/*-
+ * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Konrad E. Schroder <perseant%hhhh.org@localhost>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 1986, 1989, 1991, 1993, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)lfs_vnops.c 8.13 (Berkeley) 6/10/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.1 2014/05/16 09:34:03 dholland Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#include "opt_uvm_page_trkown.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/resourcevar.h>
+#include <sys/kernel.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/buf.h>
+#include <sys/proc.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/pool.h>
+#include <sys/signalvar.h>
+#include <sys/kauth.h>
+#include <sys/syslog.h>
+#include <sys/fstrans.h>
+
+#include <miscfs/fifofs/fifo.h>
+#include <miscfs/genfs/genfs.h>
+#include <miscfs/specfs/specdev.h>
+
+#include <ufs/lfs/ulfs_inode.h>
+#include <ufs/lfs/ulfsmount.h>
+#include <ufs/lfs/ulfs_bswap.h>
+#include <ufs/lfs/ulfs_extern.h>
+
+#include <uvm/uvm.h>
+#include <uvm/uvm_pmap.h>
+#include <uvm/uvm_stat.h>
+#include <uvm/uvm_pager.h>
+
+#include <ufs/lfs/lfs.h>
+#include <ufs/lfs/lfs_kernel.h>
+#include <ufs/lfs/lfs_extern.h>
+
+extern pid_t lfs_writer_daemon;
+
+static int check_dirty(struct lfs *, struct vnode *, off_t, off_t, off_t, int, int, struct vm_page **);
+
+int
+lfs_getpages(void *v)
+{
+ struct vop_getpages_args /* {
+ struct vnode *a_vp;
+ voff_t a_offset;
+ struct vm_page **a_m;
+ int *a_count;
+ int a_centeridx;
+ vm_prot_t a_access_type;
+ int a_advice;
+ int a_flags;
+ } */ *ap = v;
+
+ if (VTOI(ap->a_vp)->i_number == LFS_IFILE_INUM &&
+ (ap->a_access_type & VM_PROT_WRITE) != 0) {
+ return EPERM;
+ }
+ if ((ap->a_access_type & VM_PROT_WRITE) != 0) {
+ mutex_enter(&lfs_lock);
+ LFS_SET_UINO(VTOI(ap->a_vp), IN_MODIFIED);
+ mutex_exit(&lfs_lock);
+ }
+
+ /*
+ * we're relying on the fact that genfs_getpages() always read in
+ * entire filesystem blocks.
+ */
+ return genfs_getpages(v);
+}
+
+/*
+ * Wait for a page to become unbusy, possibly printing diagnostic messages
+ * as well.
+ *
+ * Called with vp->v_interlock held; return with it held.
+ */
+static void
+wait_for_page(struct vnode *vp, struct vm_page *pg, const char *label)
+{
+ KASSERT(mutex_owned(vp->v_interlock));
+ if ((pg->flags & PG_BUSY) == 0)
+ return; /* Nothing to wait for! */
+
+#if defined(DEBUG) && defined(UVM_PAGE_TRKOWN)
+ static struct vm_page *lastpg;
+
+ if (label != NULL && pg != lastpg) {
+ if (pg->owner_tag) {
+ printf("lfs_putpages[%d.%d]: %s: page %p owner %d.%d [%s]\n",
+ curproc->p_pid, curlwp->l_lid, label,
+ pg, pg->owner, pg->lowner, pg->owner_tag);
+ } else {
+ printf("lfs_putpages[%d.%d]: %s: page %p unowned?!\n",
+ curproc->p_pid, curlwp->l_lid, label, pg);
+ }
+ }
+ lastpg = pg;
+#endif
+
+ pg->flags |= PG_WANTED;
+ UVM_UNLOCK_AND_WAIT(pg, vp->v_interlock, 0, "lfsput", 0);
+ mutex_enter(vp->v_interlock);
+}
+
+/*
+ * This routine is called by lfs_putpages() when it can't complete the
+ * write because a page is busy. This means that either (1) someone,
+ * possibly the pagedaemon, is looking at this page, and will give it up
+ * presently; or (2) we ourselves are holding the page busy in the
+ * process of being written (either gathered or actually on its way to
+ * disk). We don't need to give up the segment lock, but we might need
+ * to call lfs_writeseg() to expedite the page's journey to disk.
+ *
+ * Called with vp->v_interlock held; return with it held.
+ */
+/* #define BUSYWAIT */
+static void
+write_and_wait(struct lfs *fs, struct vnode *vp, struct vm_page *pg,
+ int seglocked, const char *label)
+{
+ KASSERT(mutex_owned(vp->v_interlock));
+#ifndef BUSYWAIT
+ struct inode *ip = VTOI(vp);
+ struct segment *sp = fs->lfs_sp;
+ int count = 0;
+
+ if (pg == NULL)
+ return;
+
+ while (pg->flags & PG_BUSY &&
+ pg->uobject == &vp->v_uobj) {
+ mutex_exit(vp->v_interlock);
+ if (sp->cbpp - sp->bpp > 1) {
+ /* Write gathered pages */
+ lfs_updatemeta(sp);
+ lfs_release_finfo(fs);
+ (void) lfs_writeseg(fs, sp);
+
+ /*
+ * Reinitialize FIP
+ */
+ KASSERT(sp->vp == vp);
+ lfs_acquire_finfo(fs, ip->i_number,
+ ip->i_gen);
+ }
+ ++count;
+ mutex_enter(vp->v_interlock);
+ wait_for_page(vp, pg, label);
+ }
+ if (label != NULL && count > 1) {
+ DLOG((DLOG_PAGE, "lfs_putpages[%d]: %s: %sn = %d\n",
+ curproc->p_pid, label, (count > 0 ? "looping, " : ""),
+ count));
+ }
+#else
+ preempt(1);
+#endif
+ KASSERT(mutex_owned(vp->v_interlock));
+}
+
+/*
+ * Make sure that for all pages in every block in the given range,
+ * either all are dirty or all are clean. If any of the pages
+ * we've seen so far are dirty, put the vnode on the paging chain,
+ * and mark it IN_PAGING.
+ *
+ * If checkfirst != 0, don't check all the pages but return at the
+ * first dirty page.
+ */
+static int
Home |
Main Index |
Thread Index |
Old Index