From 442c1e48782910e67eeafe7a3b4dd60a1c9d0271 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 11 Sep 2014 11:38:38 -0400 Subject: [PATCH] add patch provide-separate-oeprations-for-sysfs-feature-files --- ...ide-separate-oeprations-for-sysfs-feature-files | 57 ++++++++++++++++++++++ series | 1 + timestamps | 7 +-- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 provide-separate-oeprations-for-sysfs-feature-files diff --git a/provide-separate-oeprations-for-sysfs-feature-files b/provide-separate-oeprations-for-sysfs-feature-files new file mode 100644 index 00000000..e71ce656 --- /dev/null +++ b/provide-separate-oeprations-for-sysfs-feature-files @@ -0,0 +1,57 @@ +ext4: provide separate operations for sysfs feature files + +From: 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 +Signed-off-by: Theodore Ts'o +--- + 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, + }; + diff --git a/series b/series index 3fb43b80..8f6c9511 100644 --- a/series +++ b/series @@ -44,6 +44,7 @@ use-non-moveable-memory-for-the-jbd-superblock dont-use-MAXQUOTAS-value add-sysfs-entry-showing-whether-the-fs-contains-errors +provide-separate-oeprations-for-sysfs-feature-files ########################################## # unstable patches diff --git a/timestamps b/timestamps index 8613b0a3..e39cf565 100755 --- a/timestamps +++ b/timestamps @@ -76,6 +76,7 @@ touch -d @1410061312 use-discard-if-possible-in-blkdev_issue_zeroout touch -d @1410111565 dont-use-io-end-if-not-needed touch -d @1410448515 dont-use-MAXQUOTAS-value touch -d @1410448693 add-sysfs-entry-showing-whether-the-fs-contains-errors -touch -d @1410448744 series -touch -d @1410448748 status -touch -d @1410449285 timestamps +touch -d @1410449278 provide-separate-oeprations-for-sysfs-feature-files +touch -d @1410449303 series +touch -d @1410449306 status +touch -d @1410449308 timestamps -- 2.11.4.GIT