From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: Lukas Czerner <lczerner@redhat.com>
Subject: [PATCH v2] ext4: add sysfs entry showing whether the fs contains errors
Date: Wed, 7 May 2014 14:04:34 +0200 [thread overview]
Message-ID: <1399464274-16310-1-git-send-email-lczerner@redhat.com> (raw)
Currently there is no easy way to tell that the mounted file system
contains errors other than checking for log messages, or reading the
information directly from superblock.
This patch adds new sysfs entry "errors" for each ext4 file
system so user can simply check
cat /sys/fs/ext4/sda/errors
If the file system is not marked as containing errors then the file
returns just 0. Otherwise it would print out the following information:
<error count> first <first_error_time> <first_error_func>:<first_error_line> \
last <last_error_time> <last_error_func>:<last_error_line>
For example:
2 first 1399305407 trigger_test_error:2630 last 1399463224 trigger_test_error:2601
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
v2: Change the name of the file to errors and change the output format
fs/ext4/super.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6f9e6fa..9d49ec1 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2502,6 +2502,27 @@ static ssize_t lifetime_write_kbytes_show(struct ext4_attr *a,
EXT4_SB(sb)->s_sectors_written_start) >> 1)));
}
+static ssize_t errors_show(struct ext4_attr *a,
+ struct ext4_sb_info *sbi, char *buf)
+{
+ struct ext4_super_block *es = sbi->s_es;
+
+ if (es->s_error_count)
+ return snprintf(buf, PAGE_SIZE,
+ "%u first %u %.*s:%d last %u %.*s:%d\n",
+ le32_to_cpu(es->s_error_count),
+ le32_to_cpu(es->s_first_error_time),
+ (int) sizeof(es->s_first_error_func),
+ es->s_first_error_func,
+ le32_to_cpu(es->s_first_error_line),
+ le32_to_cpu(es->s_last_error_time),
+ (int) sizeof(es->s_last_error_func),
+ es->s_last_error_func,
+ le32_to_cpu(es->s_last_error_line));
+ else
+ return snprintf(buf, PAGE_SIZE, "0\n");
+}
+
static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
struct ext4_sb_info *sbi,
const char *buf, size_t count)
@@ -2617,6 +2638,7 @@ static struct ext4_attr ext4_attr_##_name = { \
EXT4_RO_ATTR(delayed_allocation_blocks);
EXT4_RO_ATTR(session_write_kbytes);
EXT4_RO_ATTR(lifetime_write_kbytes);
+EXT4_RO_ATTR(errors);
EXT4_RW_ATTR(reserved_clusters);
EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show,
inode_readahead_blks_store, s_inode_readahead_blks);
@@ -2641,6 +2663,7 @@ static struct attribute *ext4_attrs[] = {
ATTR_LIST(delayed_allocation_blocks),
ATTR_LIST(session_write_kbytes),
ATTR_LIST(lifetime_write_kbytes),
+ ATTR_LIST(errors),
ATTR_LIST(reserved_clusters),
ATTR_LIST(inode_readahead_blks),
ATTR_LIST(inode_goal),
--
1.8.3.1
next reply other threads:[~2014-05-07 12:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 12:04 Lukas Czerner [this message]
2014-05-07 14:36 ` [PATCH v2] ext4: add sysfs entry showing whether the fs contains errors Theodore Ts'o
2014-05-07 15:35 ` Lukáš Czerner
2014-05-07 16:01 ` Theodore Ts'o
2014-05-07 16:03 ` Lukáš Czerner
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=1399464274-16310-1-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/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).