From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:36969 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752244AbcD2CBx (ORCPT ); Thu, 28 Apr 2016 22:01:53 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 26350AC60 for ; Fri, 29 Apr 2016 02:01:52 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PoC 7/7] ocfs2: report inode errors to userspace Date: Thu, 28 Apr 2016 21:01:22 -0500 Message-Id: <1461895282-4941-8-git-send-email-rgoldwyn@suse.de> In-Reply-To: <1461895282-4941-1-git-send-email-rgoldwyn@suse.de> References: <1461895282-4941-1-git-send-email-rgoldwyn@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Goldwyn Rodrigues Signed-off-by: Goldwyn Rodrigues --- fs/ocfs2/inode.c | 13 +++++++++++++ fs/ocfs2/sysfs.c | 17 +++++++++++++++++ fs/ocfs2/sysfs.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 12f4a9e..a6cfe5d 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -54,6 +54,7 @@ #include "refcounttree.h" #include "ocfs2_trace.h" #include "filecheck.h" +#include "sysfs.h" #include "buffer_head_io.h" @@ -1412,6 +1413,9 @@ int ocfs2_validate_inode_block(struct super_block *sb, rc = ocfs2_error(sb, "Invalid dinode #%llu: signature = %.*s\n", (unsigned long long)bh->b_blocknr, 7, di->i_signature); + ocfs2_report_error(OCFS2_SB(sb), (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr, + rc); goto bail; } @@ -1419,6 +1423,9 @@ int ocfs2_validate_inode_block(struct super_block *sb, rc = ocfs2_error(sb, "Invalid dinode #%llu: i_blkno is %llu\n", (unsigned long long)bh->b_blocknr, (unsigned long long)le64_to_cpu(di->i_blkno)); + ocfs2_report_error(OCFS2_SB(sb), (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr, + rc); goto bail; } @@ -1426,6 +1433,9 @@ int ocfs2_validate_inode_block(struct super_block *sb, rc = ocfs2_error(sb, "Invalid dinode #%llu: OCFS2_VALID_FL not set\n", (unsigned long long)bh->b_blocknr); + ocfs2_report_error(OCFS2_SB(sb), (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr, + rc); goto bail; } @@ -1435,6 +1445,9 @@ int ocfs2_validate_inode_block(struct super_block *sb, "Invalid dinode #%llu: fs_generation is %u\n", (unsigned long long)bh->b_blocknr, le32_to_cpu(di->i_fs_generation)); + ocfs2_report_error(OCFS2_SB(sb), (unsigned long long)bh->b_blocknr, + (unsigned long long)bh->b_blocknr, + rc); goto bail; } diff --git a/fs/ocfs2/sysfs.c b/fs/ocfs2/sysfs.c index 738bad6..886ce57 100644 --- a/fs/ocfs2/sysfs.c +++ b/fs/ocfs2/sysfs.c @@ -97,6 +97,23 @@ static struct attribute *ocfs2_sb_attrs[] = { NULL }; +void ocfs2_report_error(struct ocfs2_super *osb, unsigned long long ino, + unsigned long long blkno, int errno) +{ + char event_name[] = "EVENT=FS_ERROR"; + char device[16]; + char inode_number[16]; + char error_number[16]; + char block_number[16]; + char *envp[] = {event_name, inode_number, error_number, block_number, + NULL}; + snprintf(device, 16, "DEVICE=%s", osb->sb->s_id); + snprintf(error_number, 16, "ERROR=%d", errno); + snprintf(inode_number, 16, "INODE=%llu", ino); + snprintf(block_number, 16, "BLOCK=%llu", blkno); + sb_report_event(osb->sb, envp); +} + int ocfs2_sysfs_sb_init(struct super_block *sb) { sb->s_attr = ocfs2_sb_attrs; diff --git a/fs/ocfs2/sysfs.h b/fs/ocfs2/sysfs.h index 328f9c749..9eddcf6 100644 --- a/fs/ocfs2/sysfs.h +++ b/fs/ocfs2/sysfs.h @@ -3,6 +3,8 @@ #ifndef _SYS_H #define _SYS_H +void ocfs2_report_error(struct ocfs2_super *osb, unsigned long long ino, + unsigned long long blkno, int error); int ocfs2_sysfs_sb_init(struct super_block *sb); #endif -- 2.6.6