From 1b065bec142604e2b9c923f1b032ab3231872773 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 10 Mar 2008 19:05:28 +0000 Subject: [PATCH] STABLE14-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? (cherry picked from commit cadbebc2e50aedea01475620a3add4c315c13faa) --- 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.i386_linux26.h | 4 ++++ 5 files changed, 71 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index d7f1f5434..3d5c068dd 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -667,6 +667,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 @@ -893,6 +895,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 aa50b20f0..a720cce77 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -57,14 +57,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 7bc45c61d..417bffa44 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -52,10 +52,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 3f1937c1f..d4078cc9a 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -957,3 +957,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.i386_linux26.h b/src/config/param.i386_linux26.h index 8495a9522..4081f73a4 100644 --- a/src/config/param.i386_linux26.h +++ b/src/config/param.i386_linux26.h @@ -28,6 +28,10 @@ #define AFS_64BIT_ENV 1 #define AFS_64BIT_CLIENT 1 +#ifndef HAVE_IGET +#define AFS_CACHE_VNODE_PATH 1 +#endif + #if defined(__KERNEL__) && !defined(KDUMP_KERNEL) #ifdef CONFIG_SMP -- 2.39.5