From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 3/5] Generate uevents for errors
Date: Tue, 10 May 2016 12:52:37 -0500 [thread overview]
Message-ID: <1462902759-27084-4-git-send-email-rgoldwyn@suse.de> (raw)
In-Reply-To: <1462902759-27084-1-git-send-email-rgoldwyn@suse.de>
From: Goldwyn Rodrigues <rgoldwyn@suse.com>
Errors are reported to the userspace using the kobject we just added.
This can be used to automate checks and fixes using udev scripts
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
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 db4315b..5632d14 100644
--- a/fs/ocfs2/sysfs.c
+++ b/fs/ocfs2/sysfs.c
@@ -126,6 +126,23 @@ static ssize_t file_check_max_entries_store(struct ocfs2_super *osb,
return count;
}
+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);
+ kobject_uevent_env(&osb->kobj, KOBJ_CHANGE, envp);
+}
+
static void sb_release(struct kobject *kobj)
{
struct ocfs2_super *osb = container_of(kobj, struct ocfs2_super, kobj);
diff --git a/fs/ocfs2/sysfs.h b/fs/ocfs2/sysfs.h
index d929ac1..0383ee3 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);
void ocfs2_sysfs_sb_exit(struct super_block *sb);
--
2.6.6
next prev parent reply other threads:[~2016-05-10 17:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-10 17:52 [Ocfs2-devel] [PATCH 0/5] ocfs2: sysfs and cleanup Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 1/5] ocfs2: Provisions for sysfs entries Goldwyn Rodrigues
2016-05-11 10:53 ` Joseph Qi
2016-05-11 12:04 ` Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 2/5] Use the sysfs interface for creating filecheck files Goldwyn Rodrigues
2016-05-10 17:52 ` Goldwyn Rodrigues [this message]
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 4/5] ocfs2: Disallow duplicate entries in the list Goldwyn Rodrigues
2016-05-10 17:52 ` [Ocfs2-devel] [PATCH 5/5] Fix files when an inode is written in file_fix Goldwyn Rodrigues
2016-05-11 1:58 ` [Ocfs2-devel] [PATCH 0/5] ocfs2: sysfs and cleanup Gang He
-- strict thread matches above, loose matches on Subject: below --
2016-05-26 3:10 [Ocfs2-devel] [PATCH v2 " Goldwyn Rodrigues
2016-05-26 3:10 ` [Ocfs2-devel] [PATCH 3/5] Generate uevents for errors Goldwyn Rodrigues
2016-05-30 9:25 ` Gang He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462902759-27084-4-git-send-email-rgoldwyn@suse.de \
--to=rgoldwyn@suse.de \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).