Module Name:    src
Committed By:   manu
Date:           Sun Apr  8 15:07:46 UTC 2012

Modified Files:
        src/lib/libpuffs: dispatcher.c pnode.c puffs.3 puffs.h

Log Message:
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)


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libpuffs/dispatcher.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libpuffs/pnode.c
cvs rdiff -u -r1.49 -r1.50 src/lib/libpuffs/puffs.3
cvs rdiff -u -r1.119 -r1.120 src/lib/libpuffs/puffs.h

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.38 src/lib/libpuffs/dispatcher.c:1.39
--- src/lib/libpuffs/dispatcher.c:1.38	Fri Nov 25 15:02:02 2011
+++ src/lib/libpuffs/dispatcher.c	Sun Apr  8 15:07:45 2012
@@ -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 @@ __RCSID("$NetBSD: dispatcher.c,v 1.38 20
 
 #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 @@ dispatch(struct puffs_cc *pcc)
 			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 @@ dispatch(struct puffs_cc *pcc)
 				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 @@ dispatch(struct puffs_cc *pcc)
 				}
 			}
 
+			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 @@ dispatch(struct puffs_cc *pcc)
 				}
 			}
 
+			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 @@ dispatch(struct puffs_cc *pcc)
 				}
 			}
 
+			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 @@ dispatch(struct puffs_cc *pcc)
 
 			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 @@ dispatch(struct puffs_cc *pcc)
 
 			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 @@ dispatch(struct puffs_cc *pcc)
 				}
 			}
 
+			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 @@ dispatch(struct puffs_cc *pcc)
 				}
 			}
 
+			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;
 		}
 

Index: src/lib/libpuffs/pnode.c
diff -u src/lib/libpuffs/pnode.c:1.10 src/lib/libpuffs/pnode.c:1.11
--- src/lib/libpuffs/pnode.c:1.10	Tue Aug 12 19:44:39 2008
+++ src/lib/libpuffs/pnode.c	Sun Apr  8 15:07:45 2012
@@ -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 @@ puffs_pn_getmnt(struct puffs_node *pn)
 	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)

Index: src/lib/libpuffs/puffs.3
diff -u src/lib/libpuffs/puffs.3:1.49 src/lib/libpuffs/puffs.3:1.50
--- src/lib/libpuffs/puffs.3:1.49	Mon Dec 26 17:59:07 2011
+++ src/lib/libpuffs/puffs.3	Sun Apr  8 15:07:45 2012
@@ -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 @@ to avoid doing a full comparison for eve
 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.

Index: src/lib/libpuffs/puffs.h
diff -u src/lib/libpuffs/puffs.h:1.119 src/lib/libpuffs/puffs.h:1.120
--- src/lib/libpuffs/puffs.h:1.119	Mon Aug 29 20:48:36 2011
+++ src/lib/libpuffs/puffs.h	Sun Apr  8 15:07:45 2012
@@ -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 @@ struct puffs_node {
 
 	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_getpriv(struct puffs_n
 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);

Reply via email to