From: Derrick Brashear Date: Fri, 7 Oct 2005 21:11:01 +0000 (+0000) Subject: dedebug-20051007 X-Git-Tag: openafs-devel-1_5_0~275 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=3b290d5b7972c589000837ea34f3ccbe047d36e0;p=packages%2Fo%2Fopenafs.git dedebug-20051007 perhaps this should never be pulled up. anyway, implement dentry cache status dumping for linux. and provide a tool to dump it disabled (tool, not rpc) by default ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== perhaps this should never be pulled up. anyway, implement dentry cache status dumping for linux.^? and provide a tool to dump it disabled (tool, not rpc) by default ==================== perhaps this should never be pulled up. anyway, implement dentry cache status dumping for linux.^? and provide a tool to dump it disabled (tool, not rpc) by default --- diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c index 73bebfd83..1332e4880 100644 --- a/src/afs/afs_callback.c +++ b/src/afs/afs_callback.c @@ -1522,3 +1522,141 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call, return code; } + + +#ifdef AFS_LINUX24_ENV +extern struct vcache *afs_globalVp; + +int recurse_dcache_parent(parent, a_index, addr, inode, flags, time, fileName) + struct dentry * parent; + afs_int32 a_index; + afs_int32 *addr; + afs_int32 *inode; + afs_int32 *flags; + afs_int32 *time; + char ** fileName; +{ + struct dentry *this_parent = parent; + struct list_head *next; + int found = 0; + struct dentry *dentry; + +repeat: + next = this_parent->d_subdirs.next; +resume: + while (next != &this_parent->d_subdirs) { + struct list_head *tmp = next; + dentry = list_entry(tmp, struct dentry, d_child); + if (a_index == 0) + goto searchdone3; + a_index--; + next = tmp->next; + /* + * Descend a level if the d_subdirs list is non-empty. + */ + if (!list_empty(&dentry->d_subdirs)) { + this_parent = dentry; + goto repeat; + } + } + /* + * All done at this level ... ascend and resume the search. + */ + if (this_parent != parent) { + next = this_parent->d_child.next; + this_parent = this_parent->d_parent; + goto resume; + } + goto ret; + + searchdone3: + if (d_unhashed(dentry)) + *flags = 1; + else + *flags = 0; + + *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:""); + *inode = ITOAFS(dentry->d_inode); + *addr = atomic_read(&(dentry)->d_count); + *time = dentry->d_time; + + return 0; + ret: + return 1; +} +#endif + +int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName) + struct rx_call *a_call; + afs_int32 a_index; + afs_int32 *addr; + afs_int32 *inode; + afs_int32 *flags; + afs_int32 *time; + char ** fileName; +{ /*SRXAFSCB_GetDE*/ + int code = 0; /*Return code*/ +#ifdef AFS_LINUX24_ENV + register int i; /*Loop variable*/ + register struct vcache *tvc = afs_globalVp; + struct dentry *dentry; + struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry; + +#ifdef RX_ENABLE_LOCKS + AFS_GLOCK(); +#endif /* RX_ENABLE_LOCKS */ + +#if defined(AFS_LINUX24_ENV) + spin_lock(&dcache_lock); +#endif + + cur = head; + while ((cur = cur->next) != head) { + dentry = list_entry(cur, struct dentry, d_alias); + + dget_locked(dentry); + +#if defined(AFS_LINUX24_ENV) + spin_unlock(&dcache_lock); +#endif + if (a_index == 0) + goto searchdone2; + a_index--; + + if (recurse_dcache_parent(dentry, a_index, addr, inode, flags, time, fileName) == 0) { + dput(dentry); + code = 0; + goto fcnDone; + } + dput(dentry); + } + searchdone2: + if (cur == head) { + /*Past EOF*/ + code = 1; + *fileName = afs_strdup(""); + goto fcnDone; + } + + if (d_unhashed(dentry)) + *flags = 1; + else + *flags = 0; + + *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:""); + *inode = ITOAFS(dentry->d_inode); + *addr = atomic_read(&(dentry)->d_count); + *time = dentry->d_time; + + dput(dentry); + code = 0; + +fcnDone: + +#ifdef RX_ENABLE_LOCKS + AFS_GUNLOCK(); +#endif /* RX_ENABLE_LOCKS */ +#endif + return(code); + +} /*SRXAFSCB_GetDE*/ diff --git a/src/fsint/afscbint.xg b/src/fsint/afscbint.xg index 8edc66ff5..e7e19dbff 100644 --- a/src/fsint/afscbint.xg +++ b/src/fsint/afscbint.xg @@ -111,3 +111,13 @@ proc TellMeAboutYourself( OUT struct interfaceAddr *addr, OUT Capabilities *capabilities ) = 65538; + +proc GetDE( + IN afs_int32 index, + OUT afs_int32 addr, + OUT afs_int32 inode, + OUT afs_int32 flags, + OUT afs_int32 time, + OUT string fileName +) = 65539; + diff --git a/src/fsint/common.xg b/src/fsint/common.xg index 88da5555f..db693382b 100644 --- a/src/fsint/common.xg +++ b/src/fsint/common.xg @@ -75,6 +75,22 @@ struct AFSDBLock { struct AFSDBLockDesc lock; }; +struct AFSDEntry { + afs_int32 addr; + afs_int32 cell; /*Cell part of the fid*/ + AFSFid netFid; /*Network part of the fid*/ + afs_int32 Length; + afs_int32 DataVersion; + struct AFSDBLockDesc lock; + afs_int32 callback; + afs_int32 cbExpires; + short refCount; + short opens; + short writers; + char mvstat; + char states; +}; + /* * Callback types. */ diff --git a/src/fsprobe/fsprobe_callback.c b/src/fsprobe/fsprobe_callback.c index fda8628ae..13f3d792c 100644 --- a/src/fsprobe/fsprobe_callback.c +++ b/src/fsprobe/fsprobe_callback.c @@ -761,3 +761,15 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall, */ return (0); } + +int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName) + struct rx_call *a_call; + afs_int32 a_index; + afs_int32 addr; + afs_int32 inode; + afs_int32 flags; + afs_int32 time; + char ** fileName; +{ + return RXGEN_OPCODE; +} diff --git a/src/venus/Makefile.in b/src/venus/Makefile.in index 49576486b..d2ad64b4e 100644 --- a/src/venus/Makefile.in +++ b/src/venus/Makefile.in @@ -66,6 +66,8 @@ ${DEST}/etc/fstrace: fstrace ${DEST}/bin/cmdebug: cmdebug ${INSTALL} -s $? $@ +${DEST}/bin/dedebug: dedebug + ${INSTALL} -s $? $@ up.o: up.c AFS_component_version_number.c @@ -123,6 +125,11 @@ cmdebug.o: cmdebug.c ${INCLS} AFS_component_version_number.c cmdebug: cmdebug.o ${CMLIBS} $(CC) -o cmdebug cmdebug.o ${CFLAGS} ${CMLIBS} ${XLIBS} +dedebug.o: dedebug.c ${INCLS} AFS_component_version_number.c + +dedebug: dedebug.o ${CMLIBS} + $(CC) -o dedebug dedebug.o ${CFLAGS} ${CMLIBS} ${XLIBS} + # @@ -320,7 +327,7 @@ install: \ # clean: - $(RM) -f *.o *.a up fs kdump-* kdump kdump64 core cmdebug AFS_component_version_number.c fstrace gcpags livesys + $(RM) -f *.o *.a up fs kdump-* kdump kdump64 core cmdebug AFS_component_version_number.c fstrace gcpags livesys dedebug test: cd test; $(MAKE) @@ -345,6 +352,9 @@ ${DESTDIR}${sbindir}/fstrace: fstrace ${DESTDIR}${bindir}/cmdebug: cmdebug ${INSTALL} -s $? $@ +${DESTDIR}${bindir}/dedebug: dedebug + ${INSTALL} -s $? $@ + ${DESTDIR}${sbindir}/kdump: kdump-build -set -x; \ case ${SYS_NAME} in \ diff --git a/src/venus/dedebug.c b/src/venus/dedebug.c new file mode 100644 index 000000000..18a14ec42 --- /dev/null +++ b/src/venus/dedebug.c @@ -0,0 +1,120 @@ +/* + * 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 + */ + +#include +#include + +RCSID("$Header$"); + + +#include +#include +#include +#include +#include +#ifdef AFS_AIX32_ENV +#include +#endif +#include +#include +#include +#include + +extern struct rx_securityClass *rxnull_NewServerSecurityObject(); +extern struct hostent *hostutil_GetHostByName(); + +static PrintCacheEntries(struct rx_connection *aconn, int aint32) +{ + register int i; + register afs_int32 code, addr, inode, flags, time; + char *fileName; + + for(i=0;i<100000;i++) { + code = RXAFSCB_GetDE(aconn, i, &addr, &inode, &flags, &time, &fileName); + if (code) { + if (code == 1) break; + printf("cmdebug: failed to get cache entry %d (%s)\n", i, + error_message(code)); + return code; + } + + /* otherwise print this entry */ + printf("%d: ** dentry %d %08x %d %d %s\n", + i, addr, inode, flags, time, fileName); + + printf("\n"); + } + printf("Returned %d entries.\n", i); + return 0; +} + +static CommandProc(as) +struct cmd_syndesc *as; { + struct rx_connection *conn; + register char *hostName; + register struct hostent *thp; + afs_int32 port; + struct rx_securityClass *secobj; + int int32p; + afs_int32 addr; + + hostName = as->parms[0].items->data; + if (as->parms[1].items) + port = atoi(as->parms[1].items->data); + else + port = 7001; + thp = hostutil_GetHostByName(hostName); + if (!thp) { + printf("cmdebug: can't resolve address for host %s.\n", hostName); + exit(1); + } + memcpy(&addr, thp->h_addr, sizeof(afs_int32)); + secobj = rxnull_NewServerSecurityObject(); + conn = rx_NewConnection(addr, htons(port), 1, secobj, 0); + if (!conn) { + printf("cmdebug: failed to create connection for host %s\n", hostName); + exit(1); + } + if (as->parms[2].items) int32p = 1; + else int32p = 0; + PrintCacheEntries(conn, int32p); + return 0; +} + +#include "AFS_component_version_number.c" + +main(argc, argv) +int argc; +char **argv; { + register struct cmd_syndesc *ts; + +#ifdef AFS_AIX32_ENV + /* + * The following signal action for AIX is necessary so that in case of a + * crash (i.e. core is generated) we can include the user's data section + * in the core dump. Unfortunately, by default, only a partial core is + * generated which, in many cases, isn't too useful. + */ + struct sigaction nsa; + + sigemptyset(&nsa.sa_mask); + nsa.sa_handler = SIG_DFL; + nsa.sa_flags = SA_FULLDUMP; + sigaction(SIGSEGV, &nsa, NULL); +#endif + rx_Init(0); + + ts = cmd_CreateSyntax((char *) 0, CommandProc, 0, "probe unik server"); + cmd_AddParm(ts, "-servers", CMD_SINGLE, CMD_REQUIRED, "server machine"); + cmd_AddParm(ts, "-port", CMD_SINGLE, CMD_OPTIONAL, "IP port"); + cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "print all info"); + + cmd_Dispatch(argc, argv); + exit(0); +} diff --git a/src/xstat/xstat_fs_callback.c b/src/xstat/xstat_fs_callback.c index 67e6a272e..2938e47df 100644 --- a/src/xstat/xstat_fs_callback.c +++ b/src/xstat/xstat_fs_callback.c @@ -781,3 +781,15 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall, */ return (0); } + +int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName) + struct rx_call *a_call; + afs_int32 a_index; + afs_int32 addr; + afs_int32 inode; + afs_int32 flags; + afs_int32 time; + char ** fileName; +{ + return RXGEN_OPCODE; +}