summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-11-06 11:22:30 +0100
committerChristian Brauner <brauner@kernel.org>2024-11-06 11:22:30 +0100
commit552b15103db404c7971d4958e6e28d4e7123a325 (patch)
tree3a769db0fe76530c30475bc51599ab3e6a6f66c0
parent9c8f520389c26b0a55951d494a6016763e8413fe (diff)
parent65c481f30896750f659345b915b669f78a3c0289 (diff)
downloadlwn-552b15103db404c7971d4958e6e28d4e7123a325.tar.gz
lwn-552b15103db404c7971d4958e6e28d4e7123a325.zip
Merge patch series "tmpfs: Casefold fixes"
André Almeida <andrealmeid@igalia.com> says: After casefold support for tmpfs was merged into vfs tree, two warnings were reported and I also found a small fix in the code. Thanks Nathan Chancellor and Stephen Rothwell! * patches from https://lore.kernel.org/r/20241101164251.327884-1-andrealmeid@igalia.com: tmpfs: Initialize sysfs during tmpfs init tmpfs: Fix type for sysfs' casefold attribute libfs: Fix kernel-doc warning in generic_ci_validate_strict_name Link: https://lore.kernel.org/r/20241101164251.327884-1-andrealmeid@igalia.com Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--include/linux/fs.h10
-rw-r--r--mm/shmem.c105
2 files changed, 73 insertions, 42 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b277369672a1..001d580af862 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3477,12 +3477,12 @@ int generic_ci_d_compare(const struct dentry *dentry, unsigned int len,
* @name: name of the new file
*
* Return:
- * * True if the filename is suitable for this directory. It can be
- * true if a given name is not suitable for a strict encoding
- * directory, but the directory being used isn't strict
+ * * True: if the filename is suitable for this directory. It can be
+ * true if a given name is not suitable for a strict encoding
+ * directory, but the directory being used isn't strict
* * False if the filename isn't suitable for this directory. This only
- * happens when a directory is casefolded and the filesystem is strict
- * about its encoding.
+ * happens when a directory is casefolded and the filesystem is strict
+ * about its encoding.
*/
static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name)
{
diff --git a/mm/shmem.c b/mm/shmem.c
index 0739143d1419..1389a29a18bf 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -5126,6 +5126,66 @@ static struct file_system_type shmem_fs_type = {
.fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP,
};
+#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
+
+#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \
+{ \
+ .attr = { .name = __stringify(_name), .mode = _mode }, \
+ .show = _show, \
+ .store = _store, \
+}
+
+#define TMPFS_ATTR_W(_name, _store) \
+ static struct kobj_attribute tmpfs_attr_##_name = \
+ __INIT_KOBJ_ATTR(_name, 0200, NULL, _store)
+
+#define TMPFS_ATTR_RW(_name, _show, _store) \
+ static struct kobj_attribute tmpfs_attr_##_name = \
+ __INIT_KOBJ_ATTR(_name, 0644, _show, _store)
+
+#define TMPFS_ATTR_RO(_name, _show) \
+ static struct kobj_attribute tmpfs_attr_##_name = \
+ __INIT_KOBJ_ATTR(_name, 0444, _show, NULL)
+
+#if IS_ENABLED(CONFIG_UNICODE)
+static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *a,
+ char *buf)
+{
+ return sysfs_emit(buf, "supported\n");
+}
+TMPFS_ATTR_RO(casefold, casefold_show);
+#endif
+
+static struct attribute *tmpfs_attributes[] = {
+#if IS_ENABLED(CONFIG_UNICODE)
+ &tmpfs_attr_casefold.attr,
+#endif
+ NULL
+};
+
+static const struct attribute_group tmpfs_attribute_group = {
+ .attrs = tmpfs_attributes,
+ .name = "features"
+};
+
+static struct kobject *tmpfs_kobj;
+
+static int __init tmpfs_sysfs_init(void)
+{
+ int ret;
+
+ tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
+ if (!tmpfs_kobj)
+ return -ENOMEM;
+
+ ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
+ if (ret)
+ kobject_put(tmpfs_kobj);
+
+ return ret;
+}
+#endif /* CONFIG_SYSFS && CONFIG_TMPFS */
+
void __init shmem_init(void)
{
int error;
@@ -5149,6 +5209,14 @@ void __init shmem_init(void)
goto out1;
}
+#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
+ error = tmpfs_sysfs_init();
+ if (error) {
+ pr_err("Could not init tmpfs sysfs\n");
+ goto out1;
+ }
+#endif
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY)
SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge;
@@ -5546,40 +5614,3 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
return page;
}
EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp);
-
-#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS)
-#if IS_ENABLED(CONFIG_UNICODE)
-static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported");
-#endif
-
-static struct attribute *tmpfs_attributes[] = {
-#if IS_ENABLED(CONFIG_UNICODE)
- &dev_attr_casefold.attr.attr,
-#endif
- NULL
-};
-
-static const struct attribute_group tmpfs_attribute_group = {
- .attrs = tmpfs_attributes,
- .name = "features"
-};
-
-static struct kobject *tmpfs_kobj;
-
-static int __init tmpfs_sysfs_init(void)
-{
- int ret;
-
- tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj);
- if (!tmpfs_kobj)
- return -ENOMEM;
-
- ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group);
- if (ret)
- kobject_put(tmpfs_kobj);
-
- return ret;
-}
-
-fs_initcall(tmpfs_sysfs_init);
-#endif /* CONFIG_SYSFS && CONFIG_TMPFS */