From daf6b1cf282c895bb7cd3cb090e5bee06648cd16 Mon Sep 17 00:00:00 2001 From: Marc Dionne Date: Tue, 1 Jul 2008 04:33:38 +0000 Subject: [PATCH] linux-nfstrans-updates-20080630 LICENSE IPL10 FIXES 105109 exportfs - NFS translator: - The exportfs code is updated for the new export ops. The changes are made conditional on a new configure test that detects the new ops. fh_to_dentry() basically replaces decode_fh and uses our own get_dentry function instead of the now defunct find_exported_dentry. - A check for fh_len=4 is removed - in testing this value is always 6, possibly because of changes in the kernel code. - The check for authtab in osi_nfssrv.c assumes that an undefined weak symbol is 0. On my system, an unresolved weak symbol in a loaded module gets the value 0xfffffffe (-2 or -ENOENT) - again, probably a change on the kernel side. Check that the pointer is not an error constant using IS_ERR(). - In osi_vfsops.c, only use the export_ops bits if building the translator afspag: the problem here was dealing with unresolved symbols - afs_showflags is redefined in afs_pag_call.c so it's available for the afspag module - A new source file afs_warn.c gets the afs_warn* functions from afs_util.c. This allows the afspag module to get the afs_warnuser function without dragging in too many symbols. The new file is attached separately. other: - d_path() now takes a struct path argument - includes a new configure test - osi_vfsmnt -> osi_vfsmount in osi_misc.c Looked like a typo? - reorder the remove_proc_entry() calls - we need to remove the children before the parent (introduced with my earlier patch) --- acinclude.m4 | 2 + src/afs/LINUX/osi_export.c | 25 ++++++++- src/afs/LINUX/osi_misc.c | 7 ++- src/afs/LINUX/osi_nfssrv.c | 3 +- src/afs/LINUX/osi_proc.c | 8 +-- src/afs/LINUX/osi_vfsops.c | 4 +- src/afs/afs_pag_call.c | 1 + src/afs/afs_util.c | 73 ------------------------ src/afs/afs_warn.c | 126 ++++++++++++++++++++++++++++++++++++++++++ src/cf/linux-test4.m4 | 28 ++++++++++ src/libafs/Makefile.common.in | 4 ++ 11 files changed, 198 insertions(+), 83 deletions(-) create mode 100644 src/afs/afs_warn.c diff --git a/acinclude.m4 b/acinclude.m4 index f951122..c76db5c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -613,6 +613,8 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_KMEM_CACHE_INIT LINUX_HAVE_KMEM_CACHE_T LINUX_KMEM_CACHE_CREATE_TAKES_DTOR + LINUX_D_PATH_TAKES_STRUCT_PATH + LINUX_NEW_EXPORT_OPS LINUX_CONFIG_H_EXISTS LINUX_COMPLETION_H_EXISTS LINUX_EXPORTFS_H_EXISTS diff --git a/src/afs/LINUX/osi_export.c b/src/afs/LINUX/osi_export.c index 24d5063..e92f34b 100644 --- a/src/afs/LINUX/osi_export.c +++ b/src/afs/LINUX/osi_export.c @@ -30,6 +30,10 @@ RCSID /* #define OSI_EXPORT_DEBUG */ extern struct dentry_operations afs_dentry_operations; +#if defined(NEW_EXPORT_OPS) +static struct dentry *afs_export_get_dentry(struct super_block *sb, + void *inump); +#endif struct get_name_data { char *name; @@ -154,14 +158,23 @@ static int afs_encode_fh(struct dentry *de, __u32 *fh, int *max_len, return AFSFH_NET_CELLFID; } +#if defined(NEW_EXPORT_OPS) +static struct dentry *afs_fh_to_dentry(struct super_block *sb, struct fid *fh_fid, + int fh_len, int fh_type) +#else static struct dentry *afs_decode_fh(struct super_block *sb, __u32 *fh, int fh_len, int fh_type, int (*acceptable)(void *, struct dentry *), void *context) +#endif { struct VenusFid fid; struct cell *tc; struct dentry *result; +#if defined(NEW_EXPORT_OPS) + __u32 *fh = (__u32 *)fh_fid->raw; +#endif + switch (fh_type) { case AFSFH_VENUSFID: @@ -191,8 +204,6 @@ static struct dentry *afs_decode_fh(struct super_block *sb, __u32 *fh, break; case AFSFH_NET_VENUSFID: - if (fh_len != 4) - return NULL; fid.Cell = ntohl(fh[0]); fid.Fid.Volume = ntohl(fh[1]); fid.Fid.Vnode = ntohl(fh[2]); @@ -275,8 +286,14 @@ static struct dentry *afs_decode_fh(struct super_block *sb, __u32 *fh, return NULL; } +#if defined(NEW_EXPORT_OPS) + result = afs_export_get_dentry(sb, &fid); +#else result = sb->s_export_op->find_exported_dentry(sb, &fid, 0, acceptable, context); + +#endif + #ifdef OSI_EXPORT_DEBUG if (!result) { printk("afs: decode_fh(0x%08x/%d/%d.%d): no dentry\n", @@ -930,8 +947,12 @@ done: struct export_operations afs_export_ops = { .encode_fh = afs_encode_fh, +#if defined(NEW_EXPORT_OPS) + .fh_to_dentry = afs_fh_to_dentry, +#else .decode_fh = afs_decode_fh, .get_dentry = afs_export_get_dentry, +#endif .get_name = afs_export_get_name, .get_parent = afs_export_get_parent, }; diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c index adf030c..bbffb08 100644 --- a/src/afs/LINUX/osi_misc.c +++ b/src/afs/LINUX/osi_misc.c @@ -168,7 +168,7 @@ int osi_abspath(char *aname, char *buf, int buflen, int followlink, char **pathp) { struct dentry *dp = NULL; - struct vfsmnt *mnt = NULL; + struct vfsmount *mnt = NULL; char *tname, *path; int code; @@ -178,7 +178,12 @@ int osi_abspath(char *aname, char *buf, int buflen, return -PTR_ERR(tname); code = osi_lookupname_internal(tname, followlink, &mnt, &dp); if (!code) { +#if defined(D_PATH_TAKES_STRUCT_PATH) + struct path p = { mnt, dp }; + path = d_path(&p, buf, buflen); +#else path = d_path(dp, mnt, buf, buflen); +#endif if (IS_ERR(path)) { code = -PTR_ERR(path); diff --git a/src/afs/LINUX/osi_nfssrv.c b/src/afs/LINUX/osi_nfssrv.c index a2c2e05..5c423ce 100644 --- a/src/afs/LINUX/osi_nfssrv.c +++ b/src/afs/LINUX/osi_nfssrv.c @@ -206,7 +206,8 @@ void osi_linux_nfssrv_init(void) nfssrv_list = 0; RWLOCK_INIT(&afs_xnfssrv, "afs_xnfssrv"); - if (authtab) afs_authtab = authtab; + if (authtab && !IS_ERR(authtab)) + afs_authtab = authtab; else if (authtab_addr) afs_authtab = (struct auth_ops **)authtab_addr; else { printk("Warning: Unable to find the address of authtab\n"); diff --git a/src/afs/LINUX/osi_proc.c b/src/afs/LINUX/osi_proc.c index 7c15b73..75ee013 100644 --- a/src/afs/LINUX/osi_proc.c +++ b/src/afs/LINUX/osi_proc.c @@ -349,14 +349,14 @@ osi_proc_clean(void) char path[64]; #endif + remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs); +#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H + remove_proc_entry("unixusers", openafs_procfs); +#endif #if defined(EXPORTED_PROC_ROOT_FS) remove_proc_entry(PROC_FSDIRNAME, proc_root_fs); #else sprintf(path, "fs/%s", PROC_FSDIRNAME); remove_proc_entry(path, NULL); #endif - remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs); -#ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H - remove_proc_entry("unixusers", openafs_procfs); -#endif } diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c index f297fe7..8419625 100644 --- a/src/afs/LINUX/osi_vfsops.c +++ b/src/afs/LINUX/osi_vfsops.c @@ -39,7 +39,7 @@ struct vfsmount *afs_cacheMnt; int afs_was_mounted = 0; /* Used to force reload if mount/unmount/mount */ extern struct super_operations afs_sops; -#if defined(AFS_LINUX26_ENV) +#if defined(AFS_LINUX26_ENV) && !defined(AFS_NONFSTRANS) extern struct export_operations afs_export_ops; #endif extern afs_rwlock_t afs_xvcache; @@ -146,7 +146,7 @@ afs_read_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits = 10; sb->s_magic = AFS_VFSMAGIC; sb->s_op = &afs_sops; /* Super block (vfs) ops */ -#if defined(AFS_LINUX26_ENV) +#if defined(AFS_LINUX26_ENV) && !defined(AFS_NONFSTRANS) sb->s_export_op = &afs_export_ops; #endif #if defined(MAX_NON_LFS) diff --git a/src/afs/afs_pag_call.c b/src/afs/afs_pag_call.c index 3f7b047..530b798 100644 --- a/src/afs/afs_pag_call.c +++ b/src/afs/afs_pag_call.c @@ -50,6 +50,7 @@ char *afs_sysname = 0; char *afs_sysnamelist[MAXNUMSYSNAMES]; int afs_sysnamecount = 0; int afs_sysnamegen = 0; +afs_int32 afs_showflags = GAGUSER | GAGCONSOLE; /* show all messages */ void afs_Daemon(void) diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c index 6c37316..602b822 100644 --- a/src/afs/afs_util.c +++ b/src/afs/afs_util.c @@ -197,79 +197,6 @@ print_internet_address(char *preamble, struct srvAddr *sa, char *postamble, -/* * * * * * * - * this code badly needs to be cleaned up... too many ugly ifdefs. - * XXX - */ -#if 0 -void -afs_warn(char *a, long b, long c, long d, long e, long f, long g, long h, - long i, long j) -#else -void -afs_warn(a, b, c, d, e, f, g, h, i, j) - char *a; -#if defined( AFS_USE_VOID_PTR) - void *b, *c, *d, *e, *f, *g, *h, *i, *j; -#else - long b, c, d, e, f, g, h, i, j; -#endif -#endif -{ - AFS_STATCNT(afs_warn); - - if (afs_showflags & GAGCONSOLE) { -#if defined(AFS_AIX_ENV) - struct file *fd; - - /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */ - if (fp_open - ("/dev/console", O_WRONLY | O_NOCTTY | O_NDELAY, 0666, 0, FP_SYS, - &fd) == 0) { - char buf[1024]; - ssize_t len; - ssize_t count; - - sprintf(buf, a, b, c, d, e, f, g, h, i, j); - len = strlen(buf); - fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count); - fp_close(fd); - } -#else - printf(a, b, c, d, e, f, g, h, i, j); -#endif - } -} - -#if 0 -void -afs_warnuser(char *a, long b, long c, long d, long e, long f, long g, long h, - long i, long j) -#else -void -afs_warnuser(a, b, c, d, e, f, g, h, i, j) - char *a; - long b, c, d, e, f, g, h, i, j; -#endif -{ - AFS_STATCNT(afs_warnuser); - if (afs_showflags & GAGUSER) { -#ifdef AFS_GLOBAL_SUNLOCK - int haveGlock = ISAFS_GLOCK(); - if (haveGlock) - AFS_GUNLOCK(); -#endif /* AFS_GLOBAL_SUNLOCK */ - - uprintf(a, b, c, d, e, f, g, h, i, j); - -#ifdef AFS_GLOBAL_SUNLOCK - if (haveGlock) - AFS_GLOCK(); -#endif /* AFS_GLOBAL_SUNLOCK */ - } -} - - /* run everywhere, checking locks */ void afs_CheckLocks(void) diff --git a/src/afs/afs_warn.c b/src/afs/afs_warn.c new file mode 100644 index 0000000..d722e567 --- /dev/null +++ b/src/afs/afs_warn.c @@ -0,0 +1,126 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +/* + * afs_warn.c - afs_warn + * + * Implements: afs_warn, afs_warnuser + */ +#include +#include "afs/param.h" + +RCSID + ("$Header$"); + +#include "afs/stds.h" +#include "afs/sysincludes.h" /* Standard vendor system headers */ + +#if !defined(UKERNEL) +#if !defined(AFS_LINUX20_ENV) +#include +#endif +#include + +#ifdef AFS_SGI62_ENV +#include "h/hashing.h" +#endif +#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN60_ENV) +#include +#endif /* ! AFS_HPUX110_ENV */ +#endif /* !defined(UKERNEL) */ + +#include "afsincludes.h" /* Afs-based standard headers */ +#include "afs/afs_stats.h" /* afs statistics */ + +#if defined(AFS_SUN56_ENV) +#include +#include +#if defined(AFS_SUN58_ENV) +#include +#endif +#include +#endif + +#if defined(AFS_AIX_ENV) +#include +#endif + + + +/* * * * * * * + * this code badly needs to be cleaned up... too many ugly ifdefs. + * XXX + */ +#if 0 +void +afs_warn(char *a, long b, long c, long d, long e, long f, long g, long h, + long i, long j) +#else +void +afs_warn(a, b, c, d, e, f, g, h, i, j) + char *a; +#if defined( AFS_USE_VOID_PTR) + void *b, *c, *d, *e, *f, *g, *h, *i, *j; +#else + long b, c, d, e, f, g, h, i, j; +#endif +#endif +{ + AFS_STATCNT(afs_warn); + + if (afs_showflags & GAGCONSOLE) { +#if defined(AFS_AIX_ENV) + struct file *fd; + + /* cf. console_printf() in oncplus/kernext/nfs/serv/shared.c */ + if (fp_open + ("/dev/console", O_WRONLY | O_NOCTTY | O_NDELAY, 0666, 0, FP_SYS, + &fd) == 0) { + char buf[1024]; + ssize_t len; + ssize_t count; + + sprintf(buf, a, b, c, d, e, f, g, h, i, j); + len = strlen(buf); + fp_write(fd, buf, len, 0, UIO_SYSSPACE, &count); + fp_close(fd); + } +#else + printf(a, b, c, d, e, f, g, h, i, j); +#endif + } +} + +#if 0 +void +afs_warnuser(char *a, long b, long c, long d, long e, long f, long g, long h, + long i, long j) +#else +void +afs_warnuser(a, b, c, d, e, f, g, h, i, j) + char *a; + long b, c, d, e, f, g, h, i, j; +#endif +{ + AFS_STATCNT(afs_warnuser); + if (afs_showflags & GAGUSER) { +#ifdef AFS_GLOBAL_SUNLOCK + int haveGlock = ISAFS_GLOCK(); + if (haveGlock) + AFS_GUNLOCK(); +#endif /* AFS_GLOBAL_SUNLOCK */ + + uprintf(a, b, c, d, e, f, g, h, i, j); + +#ifdef AFS_GLOBAL_SUNLOCK + if (haveGlock) + AFS_GLOCK(); +#endif /* AFS_GLOBAL_SUNLOCK */ + } +} diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 65df334..10032ed 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -1051,3 +1051,31 @@ AC_DEFUN([LINUX_EXPORTS_PROC_ROOT_FS], [ AC_DEFINE([EXPORTED_PROC_ROOT_FS], 1, [define if proc_root_fs is exported]) fi]) +AC_DEFUN([LINUX_D_PATH_TAKES_STRUCT_PATH], [ + AC_MSG_CHECKING([if d_path() takes a struct path argument]) + AC_CACHE_VAL([ac_cv_linux_d_path_takes_struct_path], [ + AC_TRY_KBUILD( +[#include ], +[struct path *p; +d_path(p, NULL, 0);], + ac_cv_linux_d_path_takes_struct_path=yes, + ac_cv_linux_d_path_takes_struct_path=no)]) + AC_MSG_RESULT($ac_cv_linux_d_path_takes_struct_path) + if test "x$ac_cv_linux_d_path_takes_struct_path" = "xyes"; then + AC_DEFINE([D_PATH_TAKES_STRUCT_PATH], 1, [define if d_path() takes a struct path argument]) + fi]) + +AC_DEFUN([LINUX_NEW_EXPORT_OPS], [ + AC_MSG_CHECKING([if kernel uses new export ops]) + AC_CACHE_VAL([ac_cv_linux_new_export_ops], [ + AC_TRY_KBUILD( +[#include ], +[struct export_operations _eops; +_eops.fh_to_parent(NULL, NULL, 0, 0);], + ac_cv_linux_new_export_ops=yes, + ac_cv_linux_new_export_ops=no)]) + AC_MSG_RESULT($ac_cv_linux_new_export_ops) + if test "x$ac_cv_linux_new_export_ops" = "xyes"; then + AC_DEFINE([NEW_EXPORT_OPS], 1, [define if kernel uses new export ops]) + fi]) + diff --git a/src/libafs/Makefile.common.in b/src/libafs/Makefile.common.in index 87dd84e..fb9c0a1 100644 --- a/src/libafs/Makefile.common.in +++ b/src/libafs/Makefile.common.in @@ -126,6 +126,7 @@ AFSAOBJS = \ afs_vnop_symlink.o \ afs_vnop_write.o \ afs_volume.o \ + afs_warn.o \ afsaux.o \ Kvice.xdr.o \ xdr_arrayn.o \ @@ -194,6 +195,7 @@ AFSPAGOBJS = \ afs_pag_user.o \ afs_stat.o \ afs_syscall.o \ + afs_warn.o \ afsaux.o \ xdr_arrayn.o \ xdr_array.o \ @@ -282,6 +284,8 @@ afs_user.o: $(TOP_SRC_AFS)/afs_user.c $(CRULE_OPT) afs_util.o: $(TOP_SRC_AFS)/afs_util.c $(CRULE_OPT) +afs_warn.o: $(TOP_SRC_AFS)/afs_warn.c + $(CRULE_OPT) afs_vcache.o: $(TOP_SRC_AFS)/afs_vcache.c $(CRULE_OPT) afs_vnop_access.o: $(TOP_SRC_VNOPS)/afs_vnop_access.c -- 1.9.4