[Crash-utility] [PATCH] Fix for "files -[cp]" options on Linux 4.17

Kazuhito Hagio k-hagio at ab.jp.nec.com
Tue Sep 4 15:07:09 UTC 2018


Since the kernel commit b93b016313b3ba8003c3b8bb71f569af91f19fc7
("page cache: use xa_lock") renamed the address_space ->page_tree
to ->i_pages, without this patch, the "files -[cp]" options don't
work on Linux 4.17 and later kernels.
(In this case, is it OK not to add a new member to offset_table?)

Also, it looks like the address_space's member that the "files -c"
option really requires is ->nrpages, not ->page_tree.

Signed-off-by: Kazuhito Hagio <k-hagio at ab.jp.nec.com>
---
 filesys.c | 2 +-
 memory.c  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/filesys.c b/filesys.c
index 47f5a24..527b3f6 100644
--- a/filesys.c
+++ b/filesys.c
@@ -2275,7 +2275,7 @@ cmd_files(void)
 			return;
 
 		case 'c':
-			if (VALID_MEMBER(address_space_page_tree) &&
+			if (VALID_MEMBER(address_space_nrpages) &&
 			    VALID_MEMBER(inode_i_mapping))
 				open_flags |= PRINT_NRPAGES;
 			else
diff --git a/memory.c b/memory.c
index 24fce5e..ea25047 100644
--- a/memory.c
+++ b/memory.c
@@ -487,6 +487,8 @@ vm_init(void)
 	MEMBER_OFFSET_INIT(block_device_bd_disk, "block_device", "bd_disk");
 	MEMBER_OFFSET_INIT(inode_i_mapping, "inode", "i_mapping");
 	MEMBER_OFFSET_INIT(address_space_page_tree, "address_space", "page_tree");
+	if (INVALID_MEMBER(address_space_page_tree))
+		MEMBER_OFFSET_INIT(address_space_page_tree, "address_space", "i_pages");
 	MEMBER_OFFSET_INIT(address_space_nrpages, "address_space", "nrpages");
 	if (INVALID_MEMBER(address_space_nrpages))
 		MEMBER_OFFSET_INIT(address_space_nrpages, "address_space", "__nrpages");
-- 
1.8.3.1




More information about the Crash-utility mailing list