Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpuffs Pass the FAF flag to handlers:



details:   https://anonhg.NetBSD.org/src/rev/23dda4fc01f3
branches:  trunk
changeset: 779913:23dda4fc01f3
user:      manu <manu%NetBSD.org@localhost>
date:      Wed Jun 27 13:25:23 2012 +0000

description:
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

diffstat:

 lib/libpuffs/dispatcher.c |  33 +++++++++++++++++++++++++--------
 lib/libpuffs/puffs.h      |  19 +++++++++++++++----
 lib/libpuffs/puffs_ops.3  |  33 +++++++++++++++++++++++++++------
 3 files changed, 67 insertions(+), 18 deletions(-)

diffs (208 lines):

diff -r befac6c91c7c -r 23dda4fc01f3 lib/libpuffs/dispatcher.c
--- a/lib/libpuffs/dispatcher.c Wed Jun 27 12:28:28 2012 +0000
+++ b/lib/libpuffs/dispatcher.c Wed Jun 27 13:25:23 2012 +0000
@@ -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 @@
                        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 @@
                        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);
diff -r befac6c91c7c -r 23dda4fc01f3 lib/libpuffs/puffs.h
--- a/lib/libpuffs/puffs.h      Wed Jun 27 12:28:28 2012 +0000
+++ b/lib/libpuffs/puffs.h      Wed Jun 27 13:25:23 2012 +0000
@@ -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 @@
 #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 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 @@
            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)                                              \
diff -r befac6c91c7c -r 23dda4fc01f3 lib/libpuffs/puffs_ops.3
--- a/lib/libpuffs/puffs_ops.3  Wed Jun 27 12:28:28 2012 +0000
+++ b/lib/libpuffs/puffs_ops.3  Wed Jun 27 13:25:23 2012 +0000
@@ -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 @@
 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 @@
 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 @@
 .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.



Home | Main Index | Thread Index | Old Index