Module Name: src
Committed By: manu
Date: Wed Jun 27 13:25:24 UTC 2012
Modified Files:
src/lib/libpuffs: dispatcher.c puffs.h puffs_ops.3
Log Message:
Pass the FAF flag to handlers:
- setattr_ttl is updated to add a flag argument. Since it was not present in
a previous release, we can change its API
- write2 is introduced, this is write with an extra flag for FAF.
- fsync already has the FAF information in a flag and needs no change
- for other operations, FAF is unconditional
To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libpuffs/dispatcher.c
cvs rdiff -u -r1.121 -r1.122 src/lib/libpuffs/puffs.h
cvs rdiff -u -r1.31 -r1.32 src/lib/libpuffs/puffs_ops.3
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libpuffs/dispatcher.c
diff -u src/lib/libpuffs/dispatcher.c:1.40 src/lib/libpuffs/dispatcher.c:1.41
--- src/lib/libpuffs/dispatcher.c:1.40 Wed Apr 18 00:57:22 2012
+++ src/lib/libpuffs/dispatcher.c Wed Jun 27 13:25:23 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: dispatcher.c,v 1.40 2012/04/18 00:57:22 manu Exp $ */
+/* $NetBSD: dispatcher.c,v 1.41 2012/06/27 13:25:23 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.40 2012/04/18 00:57:22 manu Exp $");
+__RCSID("$NetBSD: dispatcher.c,v 1.41 2012/06/27 13:25:23 manu Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -467,14 +467,19 @@ dispatch(struct puffs_cc *pcc)
PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
if (PUFFS_USE_FS_TTL(pu)) {
+ int xflag = 0;
+
if (pops->puffs_node_setattr_ttl == NULL) {
error = EOPNOTSUPP;
break;
}
+ if (!PUFFSOP_WANTREPLY(preq->preq_opclass))
+ xflag |= PUFFS_SETATTR_FAF;
+
error = pops->puffs_node_setattr_ttl(pu,
opcookie, &auxt->pvnr_va, pcr,
- &auxt->pvnr_va_ttl);
+ &auxt->pvnr_va_ttl, xflag);
} else {
if (pops->puffs_node_setattr == NULL) {
error = EOPNOTSUPP;
@@ -913,15 +918,27 @@ dispatch(struct puffs_cc *pcc)
struct puffs_vnmsg_write *auxt = auxbuf;
PUFFS_MAKECRED(pcr, &auxt->pvnr_cred);
- if (pops->puffs_node_write == NULL) {
+ if (pops->puffs_node_write2 != NULL) {
+ int xflag = 0;
+
+ if (!PUFFSOP_WANTREPLY(preq->preq_opclass))
+ xflag |= PUFFS_SETATTR_FAF;
+
+ error = pops->puffs_node_write2(pu,
+ opcookie, auxt->pvnr_data,
+ auxt->pvnr_offset, &auxt->pvnr_resid,
+ pcr, auxt->pvnr_ioflag, xflag);
+
+ } else if (pops->puffs_node_write != NULL) {
+ error = pops->puffs_node_write(pu,
+ opcookie, auxt->pvnr_data,
+ auxt->pvnr_offset, &auxt->pvnr_resid,
+ pcr, auxt->pvnr_ioflag);
+ } else {
error = EIO;
break;
}
- error = pops->puffs_node_write(pu,
- opcookie, auxt->pvnr_data,
- auxt->pvnr_offset, &auxt->pvnr_resid,
- pcr, auxt->pvnr_ioflag);
/* don't need to move data back to the kernel */
preq->preq_buflen = sizeof(struct puffs_vnmsg_write);
Index: src/lib/libpuffs/puffs.h
diff -u src/lib/libpuffs/puffs.h:1.121 src/lib/libpuffs/puffs.h:1.122
--- src/lib/libpuffs/puffs.h:1.121 Wed Apr 18 00:57:22 2012
+++ src/lib/libpuffs/puffs.h Wed Jun 27 13:25:23 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs.h,v 1.121 2012/04/18 00:57:22 manu Exp $ */
+/* $NetBSD: puffs.h,v 1.122 2012/06/27 13:25:23 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -111,6 +111,12 @@ struct puffs_usermount;
#define PUFFS_FSYNC_DATAONLY 0x0002
#define PUFFS_FSYNC_CACHE 0x0100
+/*
+ * xflags for setattr_ttl and write2
+ */
+#define PUFFS_SETATTR_FAF 0x1
+#define PUFFS_WRITE_FAF 0x1
+
#define PUFFS_EXTATTR_LIST_LENPREFIX 1
/*
* Magic constants
@@ -238,9 +244,11 @@ struct puffs_ops {
struct timespec *);
int (*puffs_node_setattr_ttl)(struct puffs_usermount *,
puffs_cookie_t, struct vattr *, const struct puffs_cred *,
- struct timespec *);
+ struct timespec *, int);
+ int (*puffs_node_write2)(struct puffs_usermount *, puffs_cookie_t,
+ uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int);
- void *puffs_ops_spare[30];
+ void *puffs_ops_spare[29];
};
typedef int (*pu_pathbuild_fn)(struct puffs_usermount *,
@@ -393,7 +401,10 @@ enum {
struct timespec *); \
int fsname##_node_setattr_ttl(struct puffs_usermount *, \
puffs_cookie_t, struct vattr *, const struct puffs_cred *, \
- struct timespec *);
+ struct timespec *, int); \
+ int fsname##_node_write2(struct puffs_usermount *, \
+ puffs_cookie_t, uint8_t *, off_t, size_t *, \
+ const struct puffs_cred *, int, int);
#define PUFFSOP_INIT(ops) \
Index: src/lib/libpuffs/puffs_ops.3
diff -u src/lib/libpuffs/puffs_ops.3:1.31 src/lib/libpuffs/puffs_ops.3:1.32
--- src/lib/libpuffs/puffs_ops.3:1.31 Wed Apr 18 14:24:26 2012
+++ src/lib/libpuffs/puffs_ops.3 Wed Jun 27 13:25:23 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: puffs_ops.3,v 1.31 2012/04/18 14:24:26 wiz Exp $
+.\" $NetBSD: puffs_ops.3,v 1.32 2012/06/27 13:25:23 manu Exp $
.\"
.\" Copyright (c) 2007 Antti Kantee. All rights reserved.
.\"
@@ -110,7 +110,7 @@
.Ft int
.Fo puffs_node_setattr_ttl
.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "const struct vattr *vap"
-.Fa "const struct puffs_cred *pcr" "struct timespec *va_ttl"
+.Fa "const struct puffs_cred *pcr" "struct timespec *va_ttl" "int xflag"
.Fc
.Ft int
.Fo puffs_node_poll
@@ -187,6 +187,12 @@
.Fa "off_t offset" "size_t *resid" "const struct puffs_cred *pcr" "int ioflag"
.Fc
.Ft int
+.Fo puffs_node_write2
+.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc" "uint8_t *buf"
+.Fa "off_t offset" "size_t *resid" "const struct puffs_cred *pcr" "int ioflag"
+.Fa "int xflag"
+.Fc
+.Ft int
.Fo puffs_node_abortop
.Fa "struct puffs_usermount *pu" "puffs_cookie_t opc"
.Fa "const struct puffs_cn *pcn"
@@ -241,6 +247,7 @@
.Fn puffs_newinfo_setvattl "struct puffs_newinfo *pni" "struct timespec *va_ttl"
.Ft void
.Fn puffs_newinfo_setcnttl "struct puffs_newinfo *pni" "struct timespec *cn_ttl"
+.Fc
.Sh DESCRIPTION
The operations
.Nm puffs
@@ -521,11 +528,15 @@ Only fields of
which contain a value different from
.Dv PUFFS_VNOVAL
(typecast to the field's type!) contain a valid value.
-.It Fn puffs_node_setattr_ttl "pu" "opc" "va" "pcr" "va_ttl"
+.It Fn puffs_node_setattr_ttl "pu" "opc" "va" "pcr" "va_ttl" "xflag"
Same as
.Fn puffs_node_setattr
with cached attribute time to live specified in
-.Fa va_ttl
+.Fa va_ttl .
+.Dv PUFFS_SETATTR_FAF
+will be set in
+.Fa xflag
+for Fire-And-Forget operations.
.It Fn puffs_node_poll "pu" "opc" "events"
Poll for events on node
.Ar opc .
@@ -749,8 +760,10 @@ The parameter
should be set to indicate the amount of request NOT completed.
In the normal case this should be 0.
.It Fn puffs_node_write "pu" "opc" "buf" "offset" "resid" "pcr" "ioflag"
+.It Fn puffs_node_write2 "pu" "opc" "buf" "offset" "resid" "pcr" "ioflag" \
+"xflag"
.Fn puffs_node_write
-Write data to a file
+writes data to a file
.Fa opc
at
.Fa offset
@@ -759,9 +772,17 @@ The number of octets written is indicate
.Fa resid ;
everything must be written or an error will be generated.
The parameter must be set to indicate the amount of data NOT written.
-In case the flag
+In case the ioflag
.Dv PUFFS_IO_APPEND
is specified, the data should be appended to the end of the file.
+.Fn puffs_node_write2
+serves the same purpose as
+.Fn puffs_node_write
+with an additional
+.Fa xflag
+in which
+.Dv PUFFS_WRITE_FAF
+is set for Fire-And-Forget operations.
.It Fn puffs_node_print "pu" "opc"
Print information about node.
This is used only for kernel-initiated diagnostic purposes.