Blame SOURCES/github_2f57a96c_files-c-p.patch

608733
commit 2f57a96ce27d8b121c2822de2a66c71b83bdad21
608733
Author: Dave Anderson <anderson@redhat.com>
608733
Date:   Tue Sep 4 14:29:45 2018 -0400
608733
608733
    Fix for the "files" command in Linux 4.17 and later kernels that
608733
    contain commit b93b016313b3ba8003c3b8bb71f569af91f19fc7, titled
608733
    "page cache: use xa_lock".  Without the patch, the "files -c" option
608733
    fails with the message "files: -c option not supported or applicable
608733
    on this architecture or kernel", and the "files -p <inode>" option
608733
    fails in a similar manner.
608733
    (k-hagio@ab.jp.nec.com)
608733
608733
diff --git a/filesys.c b/filesys.c
608733
index 47f5a24..32daa5a 100644
608733
--- a/filesys.c
608733
+++ b/filesys.c
608733
@@ -2207,6 +2207,11 @@ dump_inode_page_cache_info(ulong inode)
608733
 		RJUST|LONG_DEC,
608733
 		MKSTR(nrpages)));
608733
 
608733
+	FREEBUF(inode_buf);
608733
+
608733
+	if (!nrpages)
608733
+		return;
608733
+
608733
 	root_rnode = i_mapping + OFFSET(address_space_page_tree);
608733
 	rtp.index = 0;
608733
 	rtp.value = (void *)&dump_inode_page;
608733
@@ -2217,7 +2222,6 @@ dump_inode_page_cache_info(ulong inode)
608733
 		error(INFO, "page_tree count: %ld  nrpages: %ld\n",
608733
 			count, nrpages);
608733
 
608733
-	FREEBUF(inode_buf);
608733
 	return;
608733
 }
608733
 
608733
@@ -2275,7 +2279,7 @@ cmd_files(void)
608733
 			return;
608733
 
608733
 		case 'c':
608733
-			if (VALID_MEMBER(address_space_page_tree) &&
608733
+			if (VALID_MEMBER(address_space_nrpages) &&
608733
 			    VALID_MEMBER(inode_i_mapping))
608733
 				open_flags |= PRINT_NRPAGES;
608733
 			else
608733
diff --git a/memory.c b/memory.c
608733
index 24fce5e..ea25047 100644
608733
--- a/memory.c
608733
+++ b/memory.c
608733
@@ -485,6 +485,8 @@ vm_init(void)
608733
 	MEMBER_OFFSET_INIT(block_device_bd_disk, "block_device", "bd_disk");
608733
 	MEMBER_OFFSET_INIT(inode_i_mapping, "inode", "i_mapping");
608733
 	MEMBER_OFFSET_INIT(address_space_page_tree, "address_space", "page_tree");
608733
+	if (INVALID_MEMBER(address_space_page_tree))
608733
+		MEMBER_OFFSET_INIT(address_space_page_tree, "address_space", "i_pages");
608733
 	MEMBER_OFFSET_INIT(address_space_nrpages, "address_space", "nrpages");
608733
 	if (INVALID_MEMBER(address_space_nrpages))
608733
 		MEMBER_OFFSET_INIT(address_space_nrpages, "address_space", "__nrpages");