Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys add a genfs method to allow a file system to limit the r...
details: https://anonhg.NetBSD.org/src/rev/dfee63faa805
branches: trunk
changeset: 319398:dfee63faa805
user: chs <chs%NetBSD.org@localhost>
date: Mon May 28 21:04:37 2018 +0000
description:
add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call. needed by ZFS.
diffstat:
sys/fs/efs/efs_genfs.c | 5 +++--
sys/fs/msdosfs/msdosfs_denode.c | 5 +++--
sys/fs/nilfs/nilfs_vfsops.c | 5 +++--
sys/fs/puffs/puffs_vfsops.c | 5 +++--
sys/fs/sysvbfs/sysvbfs.c | 5 +++--
sys/fs/udf/udf_subr.c | 5 +++--
sys/fs/v7fs/v7fs_extern.c | 5 +++--
sys/miscfs/genfs/genfs_io.c | 40 +++++++++++++++++++++++++++++++++++++---
sys/miscfs/genfs/genfs_node.h | 6 +++++-
sys/nfs/nfs_node.c | 5 +++--
sys/ufs/chfs/chfs_vfsops.c | 3 ++-
sys/ufs/ext2fs/ext2fs_vfsops.c | 5 +++--
sys/ufs/ffs/ffs_vfsops.c | 5 +++--
sys/ufs/lfs/lfs_vfsops.c | 5 +++--
14 files changed, 77 insertions(+), 27 deletions(-)
diffs (truncated from 415 to 300 lines):
diff -r ccd490be2889 -r dfee63faa805 sys/fs/efs/efs_genfs.c
--- a/sys/fs/efs/efs_genfs.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/efs/efs_genfs.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efs_genfs.c,v 1.1 2007/06/29 23:30:28 rumble Exp $ */
+/* $NetBSD: efs_genfs.c,v 1.2 2018/05/28 21:04:37 chs Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_genfs.c,v 1.1 2007/06/29 23:30:28 rumble Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efs_genfs.c,v 1.2 2018/05/28 21:04:37 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -42,6 +42,7 @@
.gop_size = genfs_size,
.gop_alloc = efs_gop_alloc,
.gop_write = genfs_gop_write,
+ .gop_putrange = genfs_gop_putrange,
};
int
diff -r ccd490be2889 -r dfee63faa805 sys/fs/msdosfs/msdosfs_denode.c
--- a/sys/fs/msdosfs/msdosfs_denode.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/msdosfs/msdosfs_denode.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_denode.c,v 1.56 2017/05/26 14:34:19 riastradh Exp $ */
+/* $NetBSD: msdosfs_denode.c,v 1.57 2018/05/28 21:04:37 chs Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.56 2017/05/26 14:34:19 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.57 2018/05/28 21:04:37 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -125,6 +125,7 @@
.gop_alloc = msdosfs_gop_alloc,
.gop_write = genfs_gop_write,
.gop_markupdate = msdosfs_gop_markupdate,
+ .gop_putrange = genfs_gop_putrange,
};
MALLOC_DECLARE(M_MSDOSFSFAT);
diff -r ccd490be2889 -r dfee63faa805 sys/fs/nilfs/nilfs_vfsops.c
--- a/sys/fs/nilfs/nilfs_vfsops.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/nilfs/nilfs_vfsops.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.23 2017/02/17 08:31:24 hannken Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.24 2018/05/28 21:04:37 chs Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vfsops.c,v 1.23 2017/02/17 08:31:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vfsops.c,v 1.24 2018/05/28 21:04:37 chs Exp $");
#endif /* not lint */
@@ -148,6 +148,7 @@
.gop_alloc = nilfs_gop_alloc,
.gop_write = genfs_gop_write_rwmap,
.gop_markupdate = nilfs_gop_markupdate,
+ .gop_putrange = genfs_gop_putrange,
};
/* --------------------------------------------------------------------- */
diff -r ccd490be2889 -r dfee63faa805 sys/fs/puffs/puffs_vfsops.c
--- a/sys/fs/puffs/puffs_vfsops.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/puffs/puffs_vfsops.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vfsops.c,v 1.120 2017/04/01 19:35:56 riastradh Exp $ */
+/* $NetBSD: puffs_vfsops.c,v 1.121 2018/05/28 21:04:37 chs Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.120 2017/04/01 19:35:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.121 2018/05/28 21:04:37 chs Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -76,6 +76,7 @@
#if 0
.gop_alloc, should ask userspace
#endif
+ .gop_putrange = genfs_gop_putrange,
};
/*
diff -r ccd490be2889 -r dfee63faa805 sys/fs/sysvbfs/sysvbfs.c
--- a/sys/fs/sysvbfs/sysvbfs.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/sysvbfs/sysvbfs.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysvbfs.c,v 1.16 2017/02/17 08:31:24 hannken Exp $ */
+/* $NetBSD: sysvbfs.c,v 1.17 2018/05/28 21:04:37 chs Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.16 2017/02/17 08:31:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs.c,v 1.17 2018/05/28 21:04:37 chs Exp $");
#include <sys/resource.h>
#include <sys/param.h>
@@ -108,6 +108,7 @@
.gop_size = genfs_size,
.gop_alloc = sysvbfs_gop_alloc,
.gop_write = genfs_gop_write,
+ .gop_putrange = genfs_gop_putrange,
};
struct vfsops sysvbfs_vfsops = {
diff -r ccd490be2889 -r dfee63faa805 sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/udf/udf_subr.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.139 2017/04/01 19:35:56 riastradh Exp $ */
+/* $NetBSD: udf_subr.c,v 1.140 2018/05/28 21:04:38 chs Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.139 2017/04/01 19:35:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.140 2018/05/28 21:04:38 chs Exp $");
#endif /* not lint */
@@ -4028,6 +4028,7 @@
.gop_alloc = udf_gop_alloc,
.gop_write = genfs_gop_write_rwmap,
.gop_markupdate = udf_gop_markupdate,
+ .gop_putrange = genfs_gop_putrange,
};
diff -r ccd490be2889 -r dfee63faa805 sys/fs/v7fs/v7fs_extern.c
--- a/sys/fs/v7fs/v7fs_extern.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/fs/v7fs/v7fs_extern.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_extern.c,v 1.5 2017/02/17 08:31:25 hannken Exp $ */
+/* $NetBSD: v7fs_extern.c,v 1.6 2018/05/28 21:04:38 chs Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_extern.c,v 1.5 2017/02/17 08:31:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_extern.c,v 1.6 2018/05/28 21:04:38 chs Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
@@ -222,6 +222,7 @@
.gop_size = genfs_size,
.gop_alloc = v7fs_gop_alloc,
.gop_write = genfs_gop_write,
+ .gop_putrange = genfs_gop_putrange,
};
struct vfsops v7fs_vfsops = {
diff -r ccd490be2889 -r dfee63faa805 sys/miscfs/genfs/genfs_io.c
--- a/sys/miscfs/genfs/genfs_io.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/miscfs/genfs/genfs_io.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_io.c,v 1.71 2017/10/28 00:37:13 pgoyette Exp $ */
+/* $NetBSD: genfs_io.c,v 1.72 2018/05/28 21:04:38 chs Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.71 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.72 2018/05/28 21:04:38 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1120,10 +1120,29 @@
UVM_PAGE_OWN(pg, "genfs_putpages");
/*
+ * let the fs constrain the offset range of the cluster.
+ * we additionally constrain the range here such that
+ * it fits in the "pgs" pages array.
+ */
+
+ off_t fslo, fshi, genlo, lo;
+ GOP_PUTRANGE(vp, off, &fslo, &fshi);
+ KASSERT(fslo == trunc_page(fslo));
+ KASSERT(fslo <= off);
+ KASSERT(fshi == trunc_page(fshi));
+ KASSERT(fshi == 0 || off < fshi);
+
+ if (off > MAXPHYS / 2)
+ genlo = trunc_page(off - (MAXPHYS / 2));
+ else
+ genlo = 0;
+ lo = MAX(fslo, genlo);
+
+ /*
* first look backward.
*/
- npages = MIN(MAXPAGES >> 1, off >> PAGE_SHIFT);
+ npages = (off - lo) >> PAGE_SHIFT;
nback = npages;
uvn_findpages(uobj, off - PAGE_SIZE, &nback, &pgs[0],
UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY|UFP_BACKWARD);
@@ -1150,6 +1169,9 @@
*/
npages = MAXPAGES - nback - 1;
+ if (fshi)
+ npages = MIN(npages,
+ (fshi - off - 1) >> PAGE_SHIFT);
uvn_findpages(uobj, off + PAGE_SIZE, &npages,
&pgs[nback + 1],
UFP_NOWAIT|UFP_NOALLOC|UFP_DIRTYONLY);
@@ -1314,6 +1336,18 @@
return (error);
}
+/*
+ * Default putrange method for file systems that do not care
+ * how many pages are given to one GOP_WRITE() call.
+ */
+void
+genfs_gop_putrange(struct vnode *vp, off_t off, off_t *lop, off_t *hip)
+{
+
+ *lop = 0;
+ *hip = 0;
+}
+
int
genfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags)
{
diff -r ccd490be2889 -r dfee63faa805 sys/miscfs/genfs/genfs_node.h
--- a/sys/miscfs/genfs/genfs_node.h Mon May 28 21:04:35 2018 +0000
+++ b/sys/miscfs/genfs/genfs_node.h Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_node.h,v 1.21 2013/06/06 02:00:59 dholland Exp $ */
+/* $NetBSD: genfs_node.h,v 1.22 2018/05/28 21:04:38 chs Exp $ */
/*
* Copyright (c) 2001 Chuck Silvers.
@@ -46,6 +46,7 @@
struct kauth_cred *);
int (*gop_write)(struct vnode *, struct vm_page **, int, int);
void (*gop_markupdate)(struct vnode *, int);
+ void (*gop_putrange)(struct vnode *, off_t, off_t *, off_t *);
};
#define GOP_SIZE(vp, size, eobp, flags) \
@@ -54,6 +55,8 @@
(*VTOG(vp)->g_op->gop_alloc)((vp), (off), (len), (flags), (cred))
#define GOP_WRITE(vp, pgs, npages, flags) \
(*VTOG(vp)->g_op->gop_write)((vp), (pgs), (npages), (flags))
+#define GOP_PUTRANGE(vp, off, lop, hip) \
+ (*VTOG(vp)->g_op->gop_putrange)((vp), (off), (lop), (hip))
/*
* GOP_MARKUPDATE: mark vnode's timestamps for update.
@@ -85,6 +88,7 @@
void genfs_size(struct vnode *, off_t, off_t *, int);
void genfs_node_init(struct vnode *, const struct genfs_ops *);
void genfs_node_destroy(struct vnode *);
+void genfs_gop_putrange(struct vnode *, off_t, off_t *, off_t *);
int genfs_gop_write(struct vnode *, struct vm_page **, int, int);
int genfs_gop_write_rwmap(struct vnode *, struct vm_page **, int, int);
int genfs_compat_gop_write(struct vnode *, struct vm_page **, int, int);
diff -r ccd490be2889 -r dfee63faa805 sys/nfs/nfs_node.c
--- a/sys/nfs/nfs_node.c Mon May 28 21:04:35 2018 +0000
+++ b/sys/nfs/nfs_node.c Mon May 28 21:04:37 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_node.c,v 1.122 2017/05/26 14:34:20 riastradh Exp $ */
+/* $NetBSD: nfs_node.c,v 1.123 2018/05/28 21:04:38 chs Exp $ */
Home |
Main Index |
Thread Index |
Old Index