* [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors
@ 2014-09-09 11:32 Lukas Czerner
2014-09-09 11:32 ` [PATCH 2/2] ext4: Provide separate operations for sysfs feature files Lukas Czerner
2014-09-11 15:19 ` [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors Theodore Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Lukas Czerner @ 2014-09-09 11:32 UTC (permalink / raw)
To: linux-ext4; +Cc: Lukas Czerner
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 entries:
errors_count (number of fs errors we encounter)
first_error_time (unix timestamp for the first error we see)
last_error_time (unix timestamp for the last error we see)
If the file system is not marked as containing errors then any of the
file will return 0. Otherwise it will contain valid information. More
details about the errors should as always be found in the logs.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
fs/ext4/super.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 0b28b36..8e55ae1 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2548,6 +2548,16 @@ static ssize_t sbi_ui_store(struct ext4_attr *a,
return count;
}
+static ssize_t es_ui_show(struct ext4_attr *a,
+ struct ext4_sb_info *sbi, char *buf)
+{
+
+ unsigned int *ui = (unsigned int *) (((char *) sbi->s_es) +
+ a->u.offset);
+
+ return snprintf(buf, PAGE_SIZE, "%u\n", *ui);
+}
+
static ssize_t reserved_clusters_show(struct ext4_attr *a,
struct ext4_sb_info *sbi, char *buf)
{
@@ -2601,14 +2611,29 @@ static struct ext4_attr ext4_attr_##_name = { \
.offset = offsetof(struct ext4_sb_info, _elname),\
}, \
}
+
+#define EXT4_ATTR_OFFSET_ES(_name,_mode,_show,_store,_elname) \
+static struct ext4_attr ext4_attr_##_name = { \
+ .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .show = _show, \
+ .store = _store, \
+ .u = { \
+ .offset = offsetof(struct ext4_super_block, _elname), \
+ }, \
+}
+
#define EXT4_ATTR(name, mode, show, store) \
static struct ext4_attr ext4_attr_##name = __ATTR(name, mode, show, store)
#define EXT4_INFO_ATTR(name) EXT4_ATTR(name, 0444, NULL, NULL)
#define EXT4_RO_ATTR(name) EXT4_ATTR(name, 0444, name##_show, NULL)
#define EXT4_RW_ATTR(name) EXT4_ATTR(name, 0644, name##_show, name##_store)
+
+#define EXT4_RO_ATTR_ES_UI(name, elname) \
+ EXT4_ATTR_OFFSET_ES(name, 0444, es_ui_show, NULL, elname)
#define EXT4_RW_ATTR_SBI_UI(name, elname) \
EXT4_ATTR_OFFSET(name, 0644, sbi_ui_show, sbi_ui_store, elname)
+
#define ATTR_LIST(name) &ext4_attr_##name.attr
#define EXT4_DEPRECATED_ATTR(_name, _val) \
static struct ext4_attr ext4_attr_##_name = { \
@@ -2641,6 +2666,9 @@ EXT4_RW_ATTR_SBI_UI(warning_ratelimit_interval_ms, s_warning_ratelimit_state.int
EXT4_RW_ATTR_SBI_UI(warning_ratelimit_burst, s_warning_ratelimit_state.burst);
EXT4_RW_ATTR_SBI_UI(msg_ratelimit_interval_ms, s_msg_ratelimit_state.interval);
EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst);
+EXT4_RO_ATTR_ES_UI(errors_count, s_error_count);
+EXT4_RO_ATTR_ES_UI(first_error_time, s_first_error_time);
+EXT4_RO_ATTR_ES_UI(last_error_time, s_last_error_time);
static struct attribute *ext4_attrs[] = {
ATTR_LIST(delayed_allocation_blocks),
@@ -2664,6 +2692,9 @@ static struct attribute *ext4_attrs[] = {
ATTR_LIST(warning_ratelimit_burst),
ATTR_LIST(msg_ratelimit_interval_ms),
ATTR_LIST(msg_ratelimit_burst),
+ ATTR_LIST(errors_count),
+ ATTR_LIST(first_error_time),
+ ATTR_LIST(last_error_time),
NULL,
};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ext4: Provide separate operations for sysfs feature files
2014-09-09 11:32 [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors Lukas Czerner
@ 2014-09-09 11:32 ` Lukas Czerner
2014-09-11 15:28 ` [2/2] " Theodore Ts'o
2014-09-11 15:19 ` [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors Theodore Ts'o
1 sibling, 1 reply; 4+ messages in thread
From: Lukas Czerner @ 2014-09-09 11:32 UTC (permalink / raw)
To: linux-ext4; +Cc: Lukas Czerner
Currently sysfs feature files uses ext4_attr_ops as the file operations
to show/store data. However the feature files is not supposed to contain
any data at all, the sole existence of the file means that the module
support the feature. Moreover, none of the sysfs feature attributes
actually register show/store functions so that would not be a problem.
However if a sysfs feature attribute register a show or store function
we might be in trouble because the kobject in this case is _not_ embedded
in the ext4_sb_info structure as ext4_attr_show/store expect.
So just to be safe, provide separate empty sysfs_ops to use in
ext4_feat_ktype. This might safe us from potential problems in the
future. As a bonus we can "store" something more descriptive than
nothing in the files, so let it contain "enabled" to make it clear that
the feature is really present in the module.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
fs/ext4/super.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 8e55ae1..2eff922 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2754,9 +2754,25 @@ static void ext4_feat_release(struct kobject *kobj)
complete(&ext4_feat->f_kobj_unregister);
}
+static ssize_t ext4_feat_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "supported\n");
+}
+
+/*
+ * We can not use ext4_attr_show/store because it relies on the kobject
+ * being embedded in the ext4_sb_info structure which is definitely not
+ * true in this case.
+ */
+static const struct sysfs_ops ext4_feat_ops = {
+ .show = ext4_feat_show,
+ .store = NULL,
+};
+
static struct kobj_type ext4_feat_ktype = {
.default_attrs = ext4_feat_attrs,
- .sysfs_ops = &ext4_attr_ops,
+ .sysfs_ops = &ext4_feat_ops,
.release = ext4_feat_release,
};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors
2014-09-09 11:32 [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors Lukas Czerner
2014-09-09 11:32 ` [PATCH 2/2] ext4: Provide separate operations for sysfs feature files Lukas Czerner
@ 2014-09-11 15:19 ` Theodore Ts'o
1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2014-09-11 15:19 UTC (permalink / raw)
To: Lukas Czerner; +Cc: linux-ext4
On Tue, Sep 09, 2014 at 01:32:19PM +0200, Lukas Czerner wrote:
> 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 entries:
>
> errors_count (number of fs errors we encounter)
> first_error_time (unix timestamp for the first error we see)
> last_error_time (unix timestamp for the last error we see)
>
> If the file system is not marked as containing errors then any of the
> file will return 0. Otherwise it will contain valid information. More
> details about the errors should as always be found in the logs.
>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [2/2] ext4: Provide separate operations for sysfs feature files
2014-09-09 11:32 ` [PATCH 2/2] ext4: Provide separate operations for sysfs feature files Lukas Czerner
@ 2014-09-11 15:28 ` Theodore Ts'o
0 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2014-09-11 15:28 UTC (permalink / raw)
To: Lukas Czerner; +Cc: linux-ext4
On Tue, Sep 09, 2014 at 01:32:20PM +0200, Lukas Czerner wrote:
> Currently sysfs feature files uses ext4_attr_ops as the file operations
> to show/store data. However the feature files is not supposed to contain
> any data at all, the sole existence of the file means that the module
> support the feature. Moreover, none of the sysfs feature attributes
> actually register show/store functions so that would not be a problem.
>
> However if a sysfs feature attribute register a show or store function
> we might be in trouble because the kobject in this case is _not_ embedded
> in the ext4_sb_info structure as ext4_attr_show/store expect.
>
> So just to be safe, provide separate empty sysfs_ops to use in
> ext4_feat_ktype. This might safe us from potential problems in the
> future. As a bonus we can "store" something more descriptive than
> nothing in the files, so let it contain "enabled" to make it clear that
> the feature is really present in the module.
>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-11 15:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09 11:32 [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors Lukas Czerner
2014-09-09 11:32 ` [PATCH 2/2] ext4: Provide separate operations for sysfs feature files Lukas Czerner
2014-09-11 15:28 ` [2/2] " Theodore Ts'o
2014-09-11 15:19 ` [PATCH 1/2] ext4: add sysfs entry showing whether the fs contains errors Theodore Ts'o
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).