<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Rachita Kothiyal wrote:
<blockquote TYPE=CITE>On Fri, Dec 23, 2005 at 05:03:30PM -0500, anderson@prospeed.net
wrote:
<br>>
<br>> Hi Rachita,
<br>>
<br>> This looks good -- the only thing I'll change is to print out the
<br>> offsets unconditionally in dump_offset_table() -- I actually
<br>> want to see everything in the table, including the -1's for
<br>> the invalid members.
<p>Hi Dave
<p>I am resending the patch with changes as suggested.
<br>Please review.
<p>Thanks
<br>Rachita
<br><tt></tt> </blockquote>
<tt>Strange -- I thought this patch was a no-brainer, but there seems to
be</tt>
<br><tt>a bizarre problem with this patch, one that I've not gotten a handle
on</tt>
<br><tt>yet, nor have I ever seen such behaviour before. I'm testing
the "files"</tt>
<br><tt>command on RHEL3 and RHEL4, and both see the same behaviour.</tt><tt></tt>
<p><tt>If I run "foreach files" in the foreground, I get the expected output.</tt>
<br><tt>But if I run "foreach files > output", all tasks show "no
open files".</tt>
<br><tt>So for some reason the change of the output stream is affecting
the</tt>
<br><tt>operation of the command?</tt><tt></tt>
<p><tt>And probably related, check this out, where the first "files 2365"</tt>
<br><tt>command takes syslogd's PID and works OK -- but if I set the crash</tt>
<br><tt>context to that PID, and then do just a "files" alone I get the</tt>
<br><tt>"no open files" response:</tt><tt></tt>
<p><tt>crash> files 2365</tt>
<br><tt>PID: 2365 TASK: 2184e7b0 CPU: 1 COMMAND:
"syslogd"</tt>
<br><tt>ROOT: / CWD: /</tt>
<br><tt> FD FILE DENTRY
INODE TYPE PATH</tt>
<br><tt> 0 21280880 202a963c 1d086aac SOCK
socket:/[5686]</tt>
<br><tt> 1 20e7a080 1fcd63dc 1a0b5548 REG
/var/log/messages</tt>
<br><tt> 2 20852180 1fcc4df4 1a0b5320 REG
/var/log/secure</tt>
<br><tt> 3 20852980 202a9c2c 1a0b50f8 REG
/var/log/maillog</tt>
<br><tt> 4 20dd7280 202a9cc4 1a768de8 REG
/var/log/cron</tt>
<br><tt> 5 21383280 202a9d5c 1a768bc0 REG
/var/log/spooler</tt>
<br><tt> 6 20852880 202a9f24 1a768998 REG
/var/log/boot.log</tt>
<br><tt> 7 216e6380 202a950c 1a768548 REG
/var/log/news/news.crit</tt>
<br><tt> 8 2109aa80 202a9df4 1a768320 REG
/var/log/news/news.err</tt>
<br><tt> 9 216d7680 202a9214 1a7680f8 REG
/var/log/news/news.notice</tt><tt></tt>
<p><tt>crash> set 2365</tt>
<br><tt> PID: 2365</tt>
<br><tt>COMMAND: "syslogd"</tt>
<br><tt> TASK: 2184e7b0 [THREAD_INFO: 20cd9000]</tt>
<br><tt> CPU: 1</tt>
<br><tt> STATE: TASK_INTERRUPTIBLE</tt>
<br><tt>crash> files</tt>
<br><tt>PID: 2365 TASK: 2184e7b0 CPU: 1 COMMAND:
"syslogd"</tt>
<br><tt>ROOT: / CWD: /</tt>
<br><tt>No open files</tt>
<br><tt>crash></tt><tt></tt>
<p><tt>Can you try the same thing on your 2.6.14 kernel?</tt><tt></tt>
<p><tt>Thanks,</tt>
<br><tt> Dave</tt>
<br><tt></tt>
<br><tt></tt>
<br><tt></tt>
<blockquote TYPE=CITE>
<br> o Following changes in the 'files_struct' structure from
<br> kernels 2.6.14 onwards, this patch attempts to fix the
<br> broken files command.
<p>Signed-off-by: Rachita Kothiyal <rachita@in.ibm.com>
<br>---
<p> defs.h | 6 ++++
<br> filesys.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++----------------
<br> symbols.c | 11 ++++++++
<br> 3 files changed, 78 insertions(+), 21 deletions(-)
<p>diff -puN filesys.c~crash-fix-files-command filesys.c
<br>--- crash-4.0-2.17/filesys.c~crash-fix-files-command
2005-12-23 18:26:05.000000000 +0530
<br>+++ crash-4.0-2.17-rachita/filesys.c 2005-12-23 18:26:16.000000000
+0530
<br>@@ -1710,12 +1710,20 @@ vfs_init(void)
<br> MEMBER_OFFSET_INIT(fs_struct_pwd,
"fs_struct", "pwd");
<br> MEMBER_OFFSET_INIT(fs_struct_rootmnt,
"fs_struct", "rootmnt");
<br> MEMBER_OFFSET_INIT(fs_struct_pwdmnt,
"fs_struct", "pwdmnt");
<br>- MEMBER_OFFSET_INIT(files_struct_max_fds,
"files_struct", "max_fds");
<br>- MEMBER_OFFSET_INIT(files_struct_max_fdset,
"files_struct", "max_fdset");
<br>- MEMBER_OFFSET_INIT(files_struct_open_fds,
"files_struct", "open_fds");
<br> MEMBER_OFFSET_INIT(files_struct_open_fds_init,
<br>
"files_struct", "open_fds_init");
<br>- MEMBER_OFFSET_INIT(files_struct_fd,
"files_struct", "fd");
<br>+ MEMBER_OFFSET_INIT(files_struct_fdt,
"files_struct", "fdt");
<br>+ if ( VALID_MEMBER(files_struct_fdt))
{
<br>+
MEMBER_OFFSET_INIT(fdtable_max_fds, "fdtable", "max_fds");
<br>+
MEMBER_OFFSET_INIT(fdtable_max_fdset, "fdtable", "max_fdset");
<br>+
MEMBER_OFFSET_INIT(fdtable_open_fds, "fdtable", "open_fds");
<br>+
MEMBER_OFFSET_INIT(fdtable_fd, "fdtable", "fd");
<br>+ } else {
<br>+
MEMBER_OFFSET_INIT(files_struct_max_fds, "files_struct", "max_fds");
<br>+
MEMBER_OFFSET_INIT(files_struct_max_fdset, "files_struct", "max_fdset");
<br>+
MEMBER_OFFSET_INIT(files_struct_open_fds, "files_struct", "open_fds");
<br>+
MEMBER_OFFSET_INIT(files_struct_fd, "files_struct", "fd");
<br>+ }
<br> MEMBER_OFFSET_INIT(file_f_dentry,
"file", "f_dentry");
<br> MEMBER_OFFSET_INIT(file_f_vfsmnt,
"file", "f_vfsmnt");
<br> MEMBER_OFFSET_INIT(file_f_count,
"file", "f_count");
<br>@@ -1766,6 +1774,8 @@ vfs_init(void)
<br> STRUCT_SIZE_INIT(umode_t,
"umode_t");
<br> STRUCT_SIZE_INIT(dentry,
"dentry");
<br> STRUCT_SIZE_INIT(files_struct,
"files_struct");
<br>+ if (VALID_MEMBER(files_struct_fdt))
<br>+
STRUCT_SIZE_INIT(fdtable, "fdtable");
<br> STRUCT_SIZE_INIT(file, "file");
<br> STRUCT_SIZE_INIT(inode,
"inode");
<br> STRUCT_SIZE_INIT(vfsmount,
"vfsmount");
<br>@@ -2002,8 +2012,8 @@ void
<br> open_files_dump(ulong task, int flags, struct reference *ref)
<br> {
<br> struct task_context
*tc;
<br>- ulong files_struct_addr;
<br>- char *files_struct_buf;
<br>+ ulong files_struct_addr, fdtable_addr;
<br>+ char *files_struct_buf, *fdtable_buf
= NULL;
<br> ulong fs_struct_addr;
<br> char *dentry_buf, *fs_struct_buf;
<br> ulong root_dentry, pwd_dentry;
<br>@@ -2031,6 +2041,8 @@ open_files_dump(ulong task, int flags, s
<br> BZERO(root_pathname, BUFSIZE);
<br> BZERO(pwd_pathname, BUFSIZE);
<br> files_struct_buf = GETBUF(SIZE(files_struct));
<br>+ if (VALID_SIZE(fdtable))
<br>+
fdtable_buf = GETBUF(SIZE(fdtable));
<br> fill_task_struct(task);
<p> sprintf(files_header, " FD%s%s%s%s%s%s%sTYPE%sPATH\n",
<br>@@ -2111,24 +2123,41 @@ open_files_dump(ulong task, int flags, s
<p> files_struct_addr = ULONG(tt->task_struct
+ OFFSET(task_struct_files));
<p>- if (files_struct_addr) {
<br>-
readmem(files_struct_addr, KVADDR, files_struct_buf,
<br>-
SIZE(files_struct), "files_struct buffer",
<br>-
FAULT_ON_ERROR);
<br>-
<br>-
max_fdset = INT(files_struct_buf +
<br>+ if (files_struct_addr) {
<br>+
readmem(files_struct_addr, KVADDR, files_struct_buf,
<br>+
SIZE(files_struct), "files_struct buffer",
<br>+
FAULT_ON_ERROR);
<br>+
<br>+
if (VALID_MEMBER(files_struct_max_fdset)) {
<br>+
max_fdset = INT(files_struct_buf +
<br>
OFFSET(files_struct_max_fdset));
<p>-
max_fds = INT(files_struct_buf +
<br>-
OFFSET(files_struct_max_fds));
<br>- }
<br>+
max_fds = INT(files_struct_buf +
<br>+
OFFSET(files_struct_max_fds));
<br>+
}
<br>+ }
<br>+
<br>+ if (VALID_MEMBER(files_struct_fdt))
{
<br>+
fdtable_addr = ULONG(files_struct_buf + OFFSET(files_struct_fdt));
<p>- if (!files_struct_addr || max_fdset
== 0 || max_fds == 0) {
<br>+
if (fdtable_addr) {
<br>+
readmem(fdtable_addr, KVADDR, fdtable_buf,
SIZE(fdtable), "fdtable buffer",
FAULT_ON_ERROR);
<br>+
<br>+
max_fdset = INT(fdtable_buf +
<br>+
OFFSET(fdtable_max_fdset));
<br>+
max_fds = INT(fdtable_buf +
<br>+
OFFSET(fdtable_max_fds));
<br>+
}
<br>+ }
<br>+
<br>+ if (!fdtable_addr || !files_struct_addr
|| max_fdset == 0 || max_fds == 0) {
<br>
if (ref) {
<br>
if (ref->cmdflags & FILES_REF_FOUND)
<br>
fprintf(fp, "\n");
<br>
} else
<br>
fprintf(fp, "No open files\n");
<br>+
if (fdtable_buf)
<br>+
FREEBUF(fdtable_buf);
<br>
FREEBUF(files_struct_buf);
<br>
return;
<br> }
<br>@@ -2150,8 +2179,12 @@ open_files_dump(ulong task, int flags, s
<br>
}
<br> }
<p>- open_fds_addr = ULONG(files_struct_buf
+
<br>-
OFFSET(files_struct_open_fds));
<br>+ if (VALID_MEMBER(fdtable_open_fds))
<br>+
open_fds_addr = ULONG(fdtable_buf +
<br>+
OFFSET(fdtable_open_fds));
<br>+ else
<br>+
open_fds_addr = ULONG(files_struct_buf +
<br>+
OFFSET(files_struct_open_fds));
<p> if (open_fds_addr) {
<br>
if (VALID_MEMBER(files_struct_open_fds_init) &&
<br>@@ -2161,16 +2194,21 @@ open_files_dump(ulong task, int flags, s
<br>
OFFSET(files_struct_open_fds_init),
<br>
&open_fds, sizeof(fd_set));
<br>
else
<br>-
readmem(open_fds_addr, KVADDR, &open_fds,
<br>-
sizeof(fd_set), "files_struct open_fds",
<br>+
readmem(open_fds_addr, KVADDR, &open_fds,
<br>+
sizeof(fd_set), "fdtable open_fds",
<br>
FAULT_ON_ERROR);
<br> }
<p>- fd = ULONG(files_struct_buf +
OFFSET(files_struct_fd));
<br>+ if (VALID_MEMBER(fdtable_fd))
<br>+
fd = ULONG(fdtable_buf + OFFSET(fdtable_fd));
<br>+ else
<br>+
fd = ULONG(files_struct_buf + OFFSET(files_struct_fd));
<p> if (!open_fds_addr || !fd)
{
<br>
if (ref && (ref->cmdflags & FILES_REF_FOUND))
<br>
fprintf(fp, "\n");
<br>+
if (fdtable_buf)
<br>+
FREEBUF(fdtable_buf);
<br>
FREEBUF(files_struct_buf);
<br>
return;
<br> }
<br>@@ -2224,6 +2262,8 @@ open_files_dump(ulong task, int flags, s
<br> if (ref && (ref->cmdflags
& FILES_REF_FOUND))
<br>
fprintf(fp, "\n");
<p>+ if (fdtable_buf)
<br>+
FREEBUF(fdtable_buf);
<br> FREEBUF(files_struct_buf);
<br> }
<p>diff -puN defs.h~crash-fix-files-command defs.h
<br>--- crash-4.0-2.17/defs.h~crash-fix-files-command
2005-12-23 18:26:24.000000000 +0530
<br>+++ crash-4.0-2.17-rachita/defs.h
2005-12-23 18:26:33.000000000 +0530
<br>@@ -980,6 +980,11 @@ struct offset_table {
<br> long hw_interrupt_type_set_affinity;
<br> long irq_cpustat_t___softirq_active;
<br> long irq_cpustat_t___softirq_mask;
<br>+ long fdtable_max_fds;
<br>+ long fdtable_max_fdset;
<br>+ long fdtable_open_fds;
<br>+ long fdtable_fd;
<br>+ long files_struct_fdt;
<br> long files_struct_max_fds;
<br> long files_struct_max_fdset;
<br> long files_struct_open_fds;
<br>@@ -1253,6 +1258,7 @@ struct size_table {
/* stash of
<br> long umode_t;
<br> long dentry;
<br> long files_struct;
<br>+ long fdtable;
<br> long fs_struct;
<br> long file;
<br> long inode;
<br>diff -puN symbols.c~crash-fix-files-command symbols.c
<br>--- crash-4.0-2.17/symbols.c~crash-fix-files-command
2005-12-23 18:27:16.000000000 +0530
<br>+++ crash-4.0-2.17-rachita/symbols.c 2006-01-03 12:07:09.579170576
+0530
<br>@@ -5976,6 +5976,16 @@ dump_offset_table(char *spec, ulong make
<br> fprintf(fp, " irq_cpustat_t___softirq_mask:
%ld\n",
<br>
OFFSET(irq_cpustat_t___softirq_mask));
<p>+ fprintf(fp, "
files_struct_fdt: %ld\n",
<br>+
OFFSET(files_struct_fdt));
<br>+ fprintf(fp, "
fdtable_max_fds: %ld\n",
<br>+
OFFSET(fdtable_max_fds));
<br>+ fprintf(fp, "
fdtable_max_fdset: %ld\n",
<br>+
OFFSET(fdtable_max_fdset));
<br>+ fprintf(fp, "
fdtable_open_fds: %ld\n",
<br>+
OFFSET(fdtable_open_fds));
<br>+ fprintf(fp, "
fdtable_fd: %ld\n",
<br>+
OFFSET(fdtable_fd));
<br> fprintf(fp, "
files_struct_max_fds: %ld\n",
<br>
OFFSET(files_struct_max_fds));
<br> fprintf(fp, "
files_struct_max_fdset: %ld\n",
<br>@@ -6525,6 +6535,7 @@ dump_offset_table(char *spec, ulong make
<br> fprintf(fp, "
fs_struct: %ld\n", SIZE(fs_struct));
<br> fprintf(fp, "
files_struct: %ld\n",
<br>
SIZE(files_struct));
<br>+ fprintf(fp, "
fdtable: %ld\n", SIZE(fdtable));
<br> fprintf(fp, "
file: %ld\n", SIZE(file));
<br> fprintf(fp, "
inode: %ld\n", SIZE(inode));
<br> fprintf(fp, "
vfsmount: %ld\n", SIZE(vfsmount));
<br>_
<p>--
<br>Crash-utility mailing list
<br>Crash-utility@redhat.com
<br><a href="https://www.redhat.com/mailman/listinfo/crash-utility">https://www.redhat.com/mailman/listinfo/crash-utility</a></blockquote>
</html>