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.
This commit is contained in:
parent
0656708806
commit
e406c140eb
|
@ -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>
|
||||
|
@ -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 @@ const struct genfs_ops efs_genfsops = {
|
|||
.gop_size = genfs_size,
|
||||
.gop_alloc = efs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
int
|
||||
|
|
|
@ -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 @@ static const struct genfs_ops msdosfs_genfsops = {
|
|||
.gop_alloc = msdosfs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_markupdate = msdosfs_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
MALLOC_DECLARE(M_MSDOSFSFAT);
|
||||
|
|
|
@ -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 @@ static const struct genfs_ops nilfs_genfsops = {
|
|||
.gop_alloc = nilfs_gop_alloc,
|
||||
.gop_write = genfs_gop_write_rwmap,
|
||||
.gop_markupdate = nilfs_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -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 @@ static const struct genfs_ops puffs_genfsops = {
|
|||
#if 0
|
||||
.gop_alloc, should ask userspace
|
||||
#endif
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 @@ const struct genfs_ops sysvbfs_genfsops = {
|
|||
.gop_size = genfs_size,
|
||||
.gop_alloc = sysvbfs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
struct vfsops sysvbfs_vfsops = {
|
||||
|
|
|
@ -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 @@ static const struct genfs_ops udf_genfsops = {
|
|||
.gop_alloc = udf_gop_alloc,
|
||||
.gop_write = genfs_gop_write_rwmap,
|
||||
.gop_markupdate = udf_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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 @@ const struct genfs_ops v7fs_genfsops = {
|
|||
.gop_size = genfs_size,
|
||||
.gop_alloc = v7fs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
struct vfsops v7fs_vfsops = {
|
||||
|
|
|
@ -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>
|
||||
|
@ -1119,11 +1119,30 @@ retry:
|
|||
pg->flags |= PG_BUSY;
|
||||
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 @@ retry:
|
|||
*/
|
||||
|
||||
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 @@ skip_scan:
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -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 genfs_ops {
|
|||
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 @@ struct genfs_ops {
|
|||
(*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 @@ struct genfs_node {
|
|||
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);
|
||||
|
|
|
@ -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 $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.122 2017/05/26 14:34:20 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.123 2018/05/28 21:04:38 chs Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_nfs.h"
|
||||
|
@ -73,6 +73,7 @@ static const struct genfs_ops nfs_genfsops = {
|
|||
.gop_size = nfs_gop_size,
|
||||
.gop_alloc = nfs_gop_alloc,
|
||||
.gop_write = nfs_gop_write,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: chfs_vfsops.c,v 1.17 2017/11/14 22:06:40 riastradh Exp $ */
|
||||
/* $NetBSD: chfs_vfsops.c,v 1.18 2018/05/28 21:04:38 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2010 Department of Software Engineering,
|
||||
|
@ -99,6 +99,7 @@ const struct genfs_ops chfs_genfsops = {
|
|||
.gop_alloc = chfs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_markupdate = ufs_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
struct pool chfs_inode_pool;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ext2fs_vfsops.c,v 1.210 2017/07/30 14:23:54 riastradh Exp $ */
|
||||
/* $NetBSD: ext2fs_vfsops.c,v 1.211 2018/05/28 21:04:38 chs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1991, 1993, 1994
|
||||
|
@ -60,7 +60,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.210 2017/07/30 14:23:54 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.211 2018/05/28 21:04:38 chs Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_compat_netbsd.h"
|
||||
|
@ -152,6 +152,7 @@ static const struct genfs_ops ext2fs_genfsops = {
|
|||
.gop_alloc = ext2fs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_markupdate = ufs_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
static const struct ufs_ops ext2fs_ufsops = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_vfsops.c,v 1.356 2018/01/28 10:02:00 hannken Exp $ */
|
||||
/* $NetBSD: ffs_vfsops.c,v 1.357 2018/05/28 21:04:38 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.356 2018/01/28 10:02:00 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.357 2018/05/28 21:04:38 chs Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ffs.h"
|
||||
|
@ -178,6 +178,7 @@ static const struct genfs_ops ffs_genfsops = {
|
|||
.gop_alloc = ufs_gop_alloc,
|
||||
.gop_write = genfs_gop_write,
|
||||
.gop_markupdate = ufs_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
static const struct ufs_ops ffs_ufsops = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_vfsops.c,v 1.361 2017/10/28 00:37:13 pgoyette Exp $ */
|
||||
/* $NetBSD: lfs_vfsops.c,v 1.362 2018/05/28 21:04:38 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.361 2017/10/28 00:37:13 pgoyette Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.362 2018/05/28 21:04:38 chs Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lfs.h"
|
||||
|
@ -176,6 +176,7 @@ const struct genfs_ops lfs_genfsops = {
|
|||
.gop_alloc = ulfs_gop_alloc,
|
||||
.gop_write = lfs_gop_write,
|
||||
.gop_markupdate = ulfs_gop_markupdate,
|
||||
.gop_putrange = genfs_gop_putrange,
|
||||
};
|
||||
|
||||
struct shortlong {
|
||||
|
|
Loading…
Reference in New Issue