Source-Changes-HG archive

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

[src/trunk]: src/lib/libpuffs Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init...



details:   https://anonhg.NetBSD.org/src/rev/839c40e60418
branches:  trunk
changeset: 778689:839c40e60418
user:      manu <manu%NetBSD.org@localhost>
date:      Sun Apr 08 15:07:45 2012 +0000

description:
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)

diffstat:

 lib/libpuffs/dispatcher.c |  79 ++++++++++++++++++++++++++++++++++++++++++++--
 lib/libpuffs/pnode.c      |  17 ++++++++-
 lib/libpuffs/puffs.3      |  14 +++++++-
 lib/libpuffs/puffs.h      |   7 ++-
 4 files changed, 108 insertions(+), 9 deletions(-)

diffs (259 lines):

diff -r 68f4e6a59b56 -r 839c40e60418 lib/libpuffs/dispatcher.c
--- a/lib/libpuffs/dispatcher.c Sun Apr 08 15:04:41 2012 +0000
+++ b/lib/libpuffs/dispatcher.c Sun Apr 08 15:07:45 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dispatcher.c,v 1.38 2011/11/25 15:02:02 manu Exp $     */
+/*     $NetBSD: dispatcher.c,v 1.39 2012/04/08 15:07:45 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.38 2011/11/25 15:02:02 manu Exp $");
+__RCSID("$NetBSD: dispatcher.c,v 1.39 2012/04/08 15:07:45 manu Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -48,8 +48,30 @@
 
 #include "puffs_priv.h"
 
+#define PUFFS_USE_FS_TTL(pu) (pu->pu_flags & PUFFS_KFLAG_CACHE_FS_TTL) 
+
 static void dispatch(struct puffs_cc *);
 
+static void 
+update_fs_ttl(struct puffs_usermount *pu, puffs_cookie_t opc, 
+             struct vattr *rvap, 
+             struct timespec *va_ttl, struct timespec *cn_ttl)
+{
+       struct puffs_node *pn = NULL;
+
+       pn = PU_CMAP(pu, opc);
+
+       (void)memcpy(rvap, &pn->pn_va, sizeof(*rvap));
+
+       va_ttl->tv_sec =  pn->pn_va_ttl.tv_sec;
+       va_ttl->tv_nsec =  pn->pn_va_ttl.tv_nsec;
+
+       if (cn_ttl != NULL) {
+               cn_ttl->tv_sec =  pn->pn_cn_ttl.tv_sec;
+               cn_ttl->tv_nsec =  pn->pn_cn_ttl.tv_nsec;
+       }
+}
+
 /* for our eyes only */
 void
 puffs__ml_dispatch(struct puffs_usermount *pu, struct puffs_framebuf *pb)
@@ -258,6 +280,7 @@
                        struct puffs_vnmsg_lookup *auxt = auxbuf;
                        struct puffs_newinfo pni;
                        struct puffs_cn pcn;
+                       struct puffs_node *pn = NULL;
 
                        pcn.pcn_pkcnp = &auxt->pvnr_cn;
                        PUFFS_KCREDTOCRED(pcn.pcn_cred, &auxt->pvnr_cn_cred);
@@ -280,8 +303,6 @@
                                if (error) {
                                        pu->pu_pathfree(pu, &pcn.pcn_po_full);
                                } else {
-                                       struct puffs_node *pn;
-
                                        /*
                                         * did we get a new node or a
                                         * recycled node?
@@ -295,6 +316,12 @@
                                }
                        }
 
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, auxt->pvnr_newnode, 
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             &auxt->pvnr_cn_ttl);
+
                        break;
                }
 
@@ -335,6 +362,12 @@
                                }
                        }
 
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, auxt->pvnr_newnode, 
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             &auxt->pvnr_cn_ttl);
+
                        break;
                }
 
@@ -375,6 +408,12 @@
                                }
                        }
 
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, auxt->pvnr_newnode, 
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             &auxt->pvnr_cn_ttl);
+
                        break;
                }
 
@@ -435,6 +474,20 @@
 
                        error = pops->puffs_node_getattr(pu,
                            opcookie, &auxt->pvnr_va, pcr);
+
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu)) {
+                               struct puffs_node *pn;
+
+                               pn = PU_CMAP(pu, opcookie);
+                               auxt->pvnr_va_ttl = pn->pn_va_ttl;
+                       }
+
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, opcookie,
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             NULL);
+
                        break;
                }
 
@@ -450,6 +503,12 @@
 
                        error = pops->puffs_node_setattr(pu,
                            opcookie, &auxt->pvnr_va, pcr);
+
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, opcookie,
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             NULL);
                        break;
                }
 
@@ -646,6 +705,12 @@
                                }
                        }
 
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, auxt->pvnr_newnode, 
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             &auxt->pvnr_cn_ttl);
+
                        break;
                }
 
@@ -704,6 +769,12 @@
                                }
                        }
 
+                       if ((error == 0) && PUFFS_USE_FS_TTL(pu))
+                               update_fs_ttl(pu, auxt->pvnr_newnode, 
+                                             &auxt->pvnr_va,
+                                             &auxt->pvnr_va_ttl, 
+                                             &auxt->pvnr_cn_ttl);
+
                        break;
                }
 
diff -r 68f4e6a59b56 -r 839c40e60418 lib/libpuffs/pnode.c
--- a/lib/libpuffs/pnode.c      Sun Apr 08 15:04:41 2012 +0000
+++ b/lib/libpuffs/pnode.c      Sun Apr 08 15:07:45 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pnode.c,v 1.10 2008/08/12 19:44:39 pooka Exp $ */
+/*     $NetBSD: pnode.c,v 1.11 2012/04/08 15:07:45 manu Exp $  */
 
 /*
  * Copyright (c) 2006 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: pnode.c,v 1.10 2008/08/12 19:44:39 pooka Exp $");
+__RCSID("$NetBSD: pnode.c,v 1.11 2012/04/08 15:07:45 manu Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -136,6 +136,19 @@
        return pn->pn_mnt;
 }
 
+struct timespec *
+puffs_pn_getvattl(struct puffs_node *pn)
+{
+       return &pn->pn_va_ttl;
+}
+
+struct timespec *
+puffs_pn_getcnttl(struct puffs_node *pn)
+{
+       return &pn->pn_cn_ttl;
+}
+
+
 /* convenience / shortcut */
 void *
 puffs_pn_getmntspecific(struct puffs_node *pn)
diff -r 68f4e6a59b56 -r 839c40e60418 lib/libpuffs/puffs.3
--- a/lib/libpuffs/puffs.3      Sun Apr 08 15:04:41 2012 +0000
+++ b/lib/libpuffs/puffs.3      Sun Apr 08 15:07:45 2012 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: puffs.3,v 1.49 2011/12/26 17:59:07 njoly Exp $
+.\"    $NetBSD: puffs.3,v 1.50 2012/04/08 15:07:45 manu Exp $
 .\"
 .\" Copyright (c) 2006, 2007, 2008 Antti Kantee.  All rights reserved.
 .\"
@@ -235,6 +235,18 @@
 the one searched for.
 Especially if the file system uses the abovementioned function, it
 is a good idea to define this flag.
+.It Dv PUFFS_KFLAG_CACHE_FS_TTL
+Enforce name and attribute caches based on filesystem-supplied TTL.
+In lookup, create, mknod, mkdir, symlink, getattr and setattr,
+the filesystem must update the attributes and their TTL through
+.Fn puffs_pn_getvap ,
+and 
+.Fn puffs_pn_getvattl .
+.Pp
+In lookup, create, mknod, mkdir, and symlink,
+the name TTL must be updated though
+and
+.Fn puffs_pn_getcnttl .
 .It Dv PUFFS_FLAG_OPDUMP
 This option makes the framework dump a textual representation of
 each operation before executing it.
diff -r 68f4e6a59b56 -r 839c40e60418 lib/libpuffs/puffs.h
--- a/lib/libpuffs/puffs.h      Sun Apr 08 15:04:41 2012 +0000
+++ b/lib/libpuffs/puffs.h      Sun Apr 08 15:07:45 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs.h,v 1.119 2011/08/29 20:48:36 joerg Exp $        */
+/*     $NetBSD: puffs.h,v 1.120 2012/04/08 15:07:45 manu Exp $ */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -90,7 +90,8 @@
 
        LIST_HEAD(,puffs_kcache)pn_cacheinfo;   /* PUFFS_KFLAG_CACHE    */
 
-       void                    *pn_spare[4];
+       struct timespec         pn_cn_ttl;      /* PUFFS_FLAG_CACHE_FS_TTL */
+       struct timespec         pn_va_ttl;      /* PUFFS_FLAG_CACHE_FS_TTL */
 };
 #define PUFFS_NODE_REMOVED     0x01            /* not on entry list    */
 
@@ -486,6 +487,8 @@
 void                   puffs_pn_setpriv(struct puffs_node *, void *);
 struct puffs_pathobj   *puffs_pn_getpo(struct puffs_node *);
 struct puffs_usermount *puffs_pn_getmnt(struct puffs_node *);
+struct timespec                *puffs_pn_getvattl(struct puffs_node *);
+struct timespec                *puffs_pn_getcnttl(struct puffs_node *);
 
 void   puffs_newinfo_setcookie(struct puffs_newinfo *, puffs_cookie_t);
 void   puffs_newinfo_setvtype(struct puffs_newinfo *, enum vtype);



Home | Main Index | Thread Index | Old Index