[PATCH 24/24] HWPOISON: show corrupted file info

From: Wu Fengguang
Date: Tue Dec 01 2009 - 23:40:13 EST


If file data is corrupted, the user may want to know which file
is corrupted.

CC: Andi Kleen <andi@xxxxxxxxxxxxxx>
Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
---
mm/memory-failure.c | 43 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

--- linux-mm.orig/mm/memory-failure.c 2009-12-01 09:56:21.000000000 +0800
+++ linux-mm/mm/memory-failure.c 2009-12-01 09:56:23.000000000 +0800
@@ -56,6 +56,47 @@ u64 hwpoison_filter_flags_mask;
u64 hwpoison_filter_flags_value;
u32 hwpoison_filter_memcg;

+static void describe_page_file(struct page *page)
+{
+ char *name = "?";
+ struct inode *inode;
+ struct dentry *dentry;
+
+ if (PageAnon(page))
+ return;
+
+ if (!page->mapping)
+ return;
+
+ inode = igrab(page->mapping->host);
+ if (!inode)
+ return;
+
+ dentry = d_find_alias(inode);
+
+ if (dentry) {
+ spin_lock(&dentry->d_lock);
+ name = dentry->d_name.name;
+ }
+
+ printk(KERN_ERR
+ "MCE %#lx: dev %d:%d inode %lu(%s) pgoff %lu%s\n",
+ page_to_pfn(page),
+ MAJOR(inode->i_sb->s_dev),
+ MINOR(inode->i_sb->s_dev),
+ inode->i_ino,
+ name,
+ page->index,
+ PageDirty(page) ? " corrupted" : "");
+
+ if (dentry) {
+ spin_unlock(&dentry->d_lock);
+ dput(dentry);
+ }
+
+ iput(inode);
+}
+
static int hwpoison_filter_dev(struct page *p)
{
struct address_space *mapping;
@@ -525,6 +566,8 @@ static int me_pagecache_clean(struct hwp
} else {
ret = RECOVERED;
}
+ if (PageDirty(p) && !PageSwapBacked(p))
+ describe_page_file(p);
} else {
/*
* If the file system doesn't support it just invalidate


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/