Add an open2 method, like open but with an additionnal oflags used

by the filesystem to send back information about the file.
This is used to implement PUFFS_OPEN_IO_DIRECT by which the filesystem
tells the kernel that read/write should bypass the page cache.
This commit is contained in:
manu 2014-08-16 16:25:44 +00:00
parent b4cf015091
commit ccfb03f9b0
3 changed files with 29 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dispatcher.c,v 1.46 2013/11/06 19:56:38 christos Exp $ */
/* $NetBSD: dispatcher.c,v 1.47 2014/08/16 16:25:44 manu Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: dispatcher.c,v 1.46 2013/11/06 19:56:38 christos Exp $");
__RCSID("$NetBSD: dispatcher.c,v 1.47 2014/08/16 16:25:44 manu Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -412,6 +412,14 @@ dispatch(struct puffs_cc *pcc)
struct puffs_vnmsg_open *auxt = auxbuf;
PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
if (pops->puffs_node_open2 != NULL) {
error = pops->puffs_node_open2(pu,
opcookie, auxt->pvnr_mode, pcr,
&auxt->pvnr_oflags);
break;
}
if (pops->puffs_node_open == NULL) {
error = 0;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.h,v 1.124 2012/08/16 09:25:44 manu Exp $ */
/* $NetBSD: puffs.h,v 1.125 2014/08/16 16:25:44 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -250,6 +250,8 @@ struct puffs_ops {
uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int);
int (*puffs_node_reclaim2)(struct puffs_usermount *,
puffs_cookie_t, int);
int (*puffs_node_open2)(struct puffs_usermount *,
puffs_cookie_t, int, const struct puffs_cred *, int *);
void *puffs_ops_spare[28];
};
@ -410,7 +412,9 @@ enum {
puffs_cookie_t, uint8_t *, off_t, size_t *, \
const struct puffs_cred *, int, int); \
int fsname##_node_reclaim2(struct puffs_usermount *, \
puffs_cookie_t, int);
puffs_cookie_t, int); \
int fsname##_node_open2(struct puffs_usermount *, \
puffs_cookie_t, int, const struct puffs_cred *, int *);
#define PUFFSOP_INIT(ops) \

View File

@ -1,4 +1,4 @@
.\" $NetBSD: puffs_ops.3,v 1.36 2012/08/16 11:28:38 wiz Exp $
.\" $NetBSD: puffs_ops.3,v 1.37 2014/08/16 16:25:44 manu Exp $
.\"
.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
.\"
@ -83,6 +83,11 @@
.Fa "const struct puffs_cred *pcr"
.Fc
.Ft int
.Fo puffs_node_open2
.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int modep"
.Fa "const struct puffs_cred *pcr" "int *oflags"
.Fc
.Ft int
.Fo puffs_node_close
.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "int flags"
.Fa "const struct puffs_cred *pcr"
@ -481,6 +486,7 @@ file, directory and device special file, respectively.
In case of mknod, the device identifier can be found in
.Fa va-\*[Gt]va_rdev .
.It Fn puffs_node_open "pu" "opc" "mode" "pcr"
.It Fn puffs_node_open2 "pu" "opc" "mode" "pcr" "oflags"
Open the node denoted by the cookie
.Fa opc .
The parameter
@ -491,6 +497,12 @@ was called with, e.g.
.Dv O_APPEND
and
.Dv O_NONBLOCK .
.Fn puffs_node_open2
allows the filesystem to pass back information for the file in
.Fa oflags .
The only implemented flag for now is
.Dv PUFFS_OPEN_IO_DIRECT
that cause file read/write to bypass the page cache.
.It Fn puffs_node_close "pu" "opc" "flags" "pcr"
Close a node.
The parameter