Douglas E. Engert wrote:
Mattias Pantzare wrote:
On Sat, Nov 1, 2008 at 19:53, Vincent Fox <[EMAIL PROTECTED]> wrote:
So is there any way to using a ZFS filesystem for client cache?
I tried Solaris 10 version 1.4.7 in namei binary & not and it
panics the system.

No.

Someone have to implement that.


I have attached a patch based on Derrick's suggestion to use the
AFS_CACHE_VNODE_PATH code.

Some comments questions about this:

 o The patch sets this as the default for sun4x_510, sun4x_511,
   unx86_510 sunx86_511. I have only tested on sun4x_510 with
   a ZFS root.

 o The code will also be used on UFS cache partitions.

 o There is code in afs/SOLARIS for a Xvfs file system.
   Rather then overloading the osi_UfsOpen, it might be a
   better choice to create a osi_ZfsOpen much like the
   osi_XvfsOpen. Let me know if that would be better,
   and I can rework the patch. It might be possible
   to use VOP_GETATTR to get an inode as even with ZFS
   they to generate inode numbers.

 o The Solaris vn_open will use the user's CRED, and
   it was found that permission denied was possible,
   so pn_get_buf, lookuppnvp and VOP_OPEN where used
   instead, using the cred of afs_osi_cred.

 o The ois_DisableAtime routine was trying to update
   the inode. I skipped that part of the code. Is this
   OK or not?   Is there another way to update the flag?

 o The original patch would set the ainode to a signed
   value, but on Solairs with 64 bit, the ainode was
   defined to be unsigned long. This caused problems
   with if (ainode < 0) and switch (ainode).
   So the patch goes back to using afs_int32 for ainode.

The patch was against the 1.4.8pre3 source.



_______________________________________________
OpenAFS-info mailing list
[email protected]
https://lists.openafs.org/mailman/listinfo/openafs-info




--

 Douglas E. Engert  <[EMAIL PROTECTED]>
 Argonne National Laboratory
 9700 South Cass Avenue
 Argonne, Illinois  60439
 (630) 252-5444
--- ./src/afs/SOLARIS/,osi_file.c       Mon Mar 17 10:28:55 2008
+++ ./src/afs/SOLARIS/osi_file.c        Tue Nov 11 09:24:36 2008
@@ -167,7 +167,13 @@
 }
 #endif /* AFS_HAVE_VXFS */
 
-#if defined(AFS_SUN57_64BIT_ENV)
+/*
+ * AFS_CACHE_VNODE_PATH used with any file system. Inodes are 
+ * not used with ZFS. The ainode is not an inode number but a 
+ * signed index to chucks in the cache
+ */
+
+#if !defined(AFS_CACHE_VNODE_PATH) && defined(AFS_SUN57_64BIT_ENV)
 void *
 osi_UfsOpen(ino_t ainode)
 #else
@@ -175,22 +181,85 @@
 osi_UfsOpen(afs_int32 ainode)
 #endif
 {
+#ifdef AFS_CACHE_VNODE_PATH
+    struct vnode *vp;
+#else
     struct inode *ip;
+#endif
     register struct osi_file *afile = NULL;
     afs_int32 code = 0;
+#ifdef AFS_CACHE_VNODE_PATH
     int dummy;
+    char fname[1024];
+    char namebuf[1024];
+    struct pathname lookpn;
+#endif
+    struct osi_stat tstat;
     afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
     AFS_GUNLOCK();
+
+#ifdef AFS_CACHE_VNODE_PATH
+    if (ainode < 0) {
+       switch (ainode) {
+       case AFS_CACHE_CELLS_INODE:
+           snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "CellItems");
+           break;
+       case AFS_CACHE_ITEMS_INODE:
+           snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "CacheItems");
+           break;
+       case AFS_CACHE_VOLUME_INODE:
+           snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "VolumeItems");
+           break;
+       default:
+           osi_Panic("Invalid negative inode");
+       }
+    } else {
+       dummy = ainode / afs_numfilesperdir;
+       snprintf(fname, 1024, "%s/D%d/V%d", afs_cachebasedir, dummy, ainode);
+    }
+               
+       /* Can not use vn_open or lookupname, they use user's CRED() 
+     * We need to run as root So must use low level lookuppnvp 
+     * assume fname starts  with /
+        */
+
+       code = pn_get_buf(fname, AFS_UIOSYS, &lookpn, namebuf, sizeof(namebuf));
+    if (code != 0) 
+        osi_Panic("UfsOpen: pn_get_buf failed %ld %s %ld", code, fname, 
ainode);
+ 
+       VN_HOLD(rootdir); /* released in loopuppnvp */
+       code = lookuppnvp(&lookpn, NULL, FOLLOW, NULL, &vp, 
+           rootdir, rootdir, &afs_osi_cred); 
+    if (code != 0)  
+        osi_Panic("UfsOpen: lookuppnvp failed %ld %s %ld", code, fname, 
ainode);
+       
+#ifdef AFS_SUN511_ENV
+    code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred, NULL);
+#else
+    code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred);
+#endif
+
+    if (code != 0)
+        osi_Panic("UfsOpen: VOP_OPEN failed %ld %s %ld", code, fname, ainode);
+
+#else
     code =
        igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, &ip,
                  CRED(), &dummy);
+#endif
     AFS_GLOCK();
     if (code) {
        osi_FreeSmallSpace(afile);
-       osi_Panic("UfsOpen: igetinode failed");
+       osi_Panic("UfsOpen: igetinode failed %ld %s %ld", code, fname, ainode);
     }
+#ifdef AFS_CACHE_VNODE_PATH
+       afile->vnode = vp;
+       code = afs_osi_Stat(afile, &tstat);
+       afile->size = tstat.size;
+#else
     afile->vnode = ITOV(ip);
     afile->size = VTOI(afile->vnode)->i_size;
+#endif
     afile->offset = 0;
     afile->proc = (int (*)())0;
     afile->inum = ainode;      /* for hint validity checking */
@@ -200,7 +269,7 @@
 /**
   * In Solaris 7 we use 64 bit inode numbers
   */
-#if defined(AFS_SUN57_64BIT_ENV)
+#if !defined(AFS_CACHE_VNODE_PATH) && defined(AFS_SUN57_64BIT_ENV)
 void *
 osi_UFSOpen(ino_t ainode)
 #else
@@ -304,12 +373,14 @@
 osi_DisableAtimes(struct vnode *avp)
 {
     if (afs_CacheFSType == AFS_SUN_UFS_CACHE) {
+#ifndef AFS_CACHE_VNODE_PATH 
        struct inode *ip = VTOI(avp);
        rw_enter(&ip->i_contents, RW_READER);
        mutex_enter(&ip->i_tlock);
        ip->i_flag &= ~IACC;
        mutex_exit(&ip->i_tlock);
        rw_exit(&ip->i_contents);
+#endif
     }
 }
 
--- ./src/afs/,afs_prototypes.h Sat Jun 28 22:26:04 2008
+++ ./src/afs/afs_prototypes.h  Tue Nov 11 08:22:30 2008
@@ -590,7 +590,7 @@
 
 /* ARCH/osi_file.c */
 extern int afs_osicred_initialized;
-#if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV)
+#if !defined(AFS_CACHE_VNODE_PATH) && (defined(AFS_SUN57_64BIT_ENV) || 
defined(AFS_SGI62_ENV))
 extern void *osi_UFSOpen(ino_t ainode);
 #else
 extern void *osi_UFSOpen(afs_int32 ainode);
--- ./src/config/,param.sunx86_510.h    Fri Dec 23 19:09:53 2005
+++ ./src/config/param.sunx86_510.h     Fri Nov  7 08:45:47 2008
@@ -38,6 +38,8 @@
 
 #define AFS_HAVE_FLOCK_SYSID    1
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK     1       /* For global locking */
--- ./src/config/,param.sunx86_511.h    Thu Dec 28 15:59:45 2006
+++ ./src/config/param.sunx86_511.h     Fri Nov  7 08:46:14 2008
@@ -39,6 +39,8 @@
 
 #define AFS_HAVE_FLOCK_SYSID    1
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK     1       /* For global locking */
--- ./src/config/,param.sun4x_510.h     Fri Dec 23 19:09:53 2005
+++ ./src/config/param.sun4x_510.h      Fri Nov  7 08:43:53 2008
@@ -34,6 +34,8 @@
 #define AFS_3DISPARES          1       /* Utilize the 3 available disk inode 
'spares' */
 #endif /* AFS_NAMEI_ENV */
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK     1       /* For global locking */
--- ./src/config/,param.sun4x_511.h     Thu Dec 28 15:59:45 2006
+++ ./src/config/param.sun4x_511.h      Fri Nov  7 08:45:10 2008
@@ -35,6 +35,8 @@
 #define AFS_3DISPARES          1       /* Utilize the 3 available disk inode 
'spares' */
 #endif /* AFS_NAMEI_ENV */
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK     1       /* For global locking */

Reply via email to