From cadbebc2e50aedea01475620a3add4c315c13faa Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 10 Mar 2008 18:50:47 +0000 Subject: [PATCH] linux-2625-20080310 LICENSE IPL10 adapted from marc dionne's patch, but works more directly like the darwin port, further, i'm guessing iget_locked will go away evewntually. maybe this is too conservative? --- acinclude.m4 | 8 ++++++++ src/afs/LINUX/osi_file.c | 29 ++++++++++++++++++++++++++++- src/afs/LINUX/osi_misc.c | 7 +++++++ src/cf/linux-test4.m4 | 24 ++++++++++++++++++++++++ src/config/param.linux26.h | 5 +++++ 5 files changed, 72 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 4aafbb5..5fbf5c2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -669,6 +669,8 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_INIT_WORK_HAS_DATA LINUX_REGISTER_SYSCTL_TABLE_NOFLAG LINUX_SYSCTL_TABLE_CHECKING + LINUX_HAVE_IGET + LINUX_FS_STRUCT_NAMEIDATA_HAS_PATH LINUX_EXPORTS_SYS_CHDIR LINUX_EXPORTS_SYS_CLOSE LINUX_EXPORTS_SYS_OPEN @@ -898,6 +900,12 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) if test "x$ac_cv_linux_sysctl_table_checking" = "xyes" ; then AC_DEFINE(SYSCTL_TABLE_CHECKING, 1, [define if your kernel has sysctl table checking]) fi + if test "x$ac_cv_linux_have_iget" = "xyes" ; then + AC_DEFINE(HAVE_IGET, 1, [define if your kernel has iget]) + fi + if test "x$ac_cv_linux_struct_nameidata_has_path" = "xyes" ; then + AC_DEFINE(STRUCT_NAMEIDATA_HAS_PATH, 1, [define if your struct nameidata has path]) + fi if test "x$ac_cv_linux_exports_tasklist_lock" = "xyes" ; then AC_DEFINE(EXPORTED_TASKLIST_LOCK, 1, [define if tasklist_lock exported]) fi diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index d6b3974..2eca460 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -58,14 +58,41 @@ osi_UFSOpen(afs_int32 ainode) sizeof(struct osi_file)); } memset(afile, 0, sizeof(struct osi_file)); +#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); + } + + code = osi_lookupname(fname, AFS_UIOSYS, 0, &dp); + if (code) { + osi_Panic("Failed cache file lookup: %s in UFSOpen\n", fname); + } + tip = dp->d_inode; +#else tip = iget(afs_cacheSBp, (u_long) ainode); if (!tip) osi_Panic("Can't get inode %d\n", ainode); - tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ dp = d_alloc_anon(tip); if (!dp) osi_Panic("Can't get dentry for inode %d\n", ainode); +#endif + tip->i_flags |= MS_NOATIME; /* Disable updating access times. */ filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR); if (IS_ERR(filp)) diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index 76914b1..adf030c 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -99,10 +99,17 @@ osi_lookupname_internal(char *aname, int followlink, struct vfsmount **mnt, #endif if (!code) { +#if defined(STRUCT_NAMEIDATA_HAS_PATH) + *dpp = dget(nd.path.dentry); + if (mnt) + *mnt = mntget(nd.path.mnt); + path_put(&nd.path); +#else *dpp = dget(nd.dentry); if (mnt) *mnt = mntget(nd.mnt); path_release(&nd); +#endif } return code; } diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 126f75f..995c5da 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -976,3 +976,27 @@ sysctl_check_table(NULL);], ac_cv_linux_sysctl_table_checking=yes)]) AC_MSG_RESULT($ac_cv_linux_sysctl_table_checking)]) +AC_DEFUN([LINUX_HAVE_IGET], [ + AC_MSG_CHECKING([for linux iget()]) + AC_CACHE_VAL([ac_cv_linux_have_iget], [ + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration" + AC_TRY_KBUILD( +[#include ], +[iget(NULL, NULL);], + ac_cv_linux_have_iget=yes, + ac_cv_linux_have_iget=no) + CPPFLAGS="$save_CPPFLAGS"]) + AC_MSG_RESULT($ac_cv_linux_have_iget)]) + +AC_DEFUN([LINUX_FS_STRUCT_NAMEIDATA_HAS_PATH], [ + AC_MSG_CHECKING([for path in struct nameidata]) + AC_CACHE_VAL([ac_cv_linux_struct_nameidata_has_path], [ + AC_TRY_KBUILD( +[#include ], +[struct nameidata _nd; +printk("%x\n", _nd.path);], + ac_cv_linux_struct_nameidata_has_path=yes, + ac_cv_linux_struct_nameidata_has_path=no)]) + AC_MSG_RESULT($ac_cv_linux_struct_nameidata_has_path)]) + diff --git a/src/config/param.linux26.h b/src/config/param.linux26.h index eeff2bb..3c0edd2 100644 --- a/src/config/param.linux26.h +++ b/src/config/param.linux26.h @@ -43,6 +43,7 @@ #ifndef MAX #define MAX(A,B) ((A) > (B) ? (A) : (B)) #endif + #endif /* KERNEL */ #ifndef KERNEL @@ -99,6 +100,10 @@ #endif #endif +#ifndef HAVE_IGET +#define AFS_CACHE_VNODE_PATH 1 +#endif + #include #endif /* AFS_PARAM_COMMON_H */ -- 1.9.4