~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/zonefs/sysfs.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/zonefs/sysfs.c (Architecture ppc) and /fs/zonefs/sysfs.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 /*                                                  2 /*
  3  * Simple file system for zoned block devices       3  * Simple file system for zoned block devices exposing zones as files.
  4  *                                                  4  *
  5  * Copyright (C) 2022 Western Digital Corporat      5  * Copyright (C) 2022 Western Digital Corporation or its affiliates.
  6  */                                                 6  */
  7 #include <linux/fs.h>                               7 #include <linux/fs.h>
  8 #include <linux/seq_file.h>                         8 #include <linux/seq_file.h>
  9 #include <linux/blkdev.h>                           9 #include <linux/blkdev.h>
 10                                                    10 
 11 #include "zonefs.h"                                11 #include "zonefs.h"
 12                                                    12 
 13 struct zonefs_sysfs_attr {                         13 struct zonefs_sysfs_attr {
 14         struct attribute attr;                     14         struct attribute attr;
 15         ssize_t (*show)(struct zonefs_sb_info      15         ssize_t (*show)(struct zonefs_sb_info *sbi, char *buf);
 16 };                                                 16 };
 17                                                    17 
 18 #define ZONEFS_SYSFS_ATTR_RO(name) \               18 #define ZONEFS_SYSFS_ATTR_RO(name) \
 19 static struct zonefs_sysfs_attr zonefs_sysfs_a     19 static struct zonefs_sysfs_attr zonefs_sysfs_attr_##name = __ATTR_RO(name)
 20                                                    20 
 21 #define ATTR_LIST(name) &zonefs_sysfs_attr_##n     21 #define ATTR_LIST(name) &zonefs_sysfs_attr_##name.attr
 22                                                    22 
 23 static ssize_t zonefs_sysfs_attr_show(struct k     23 static ssize_t zonefs_sysfs_attr_show(struct kobject *kobj,
 24                                       struct a     24                                       struct attribute *attr, char *buf)
 25 {                                                  25 {
 26         struct zonefs_sb_info *sbi =               26         struct zonefs_sb_info *sbi =
 27                 container_of(kobj, struct zone     27                 container_of(kobj, struct zonefs_sb_info, s_kobj);
 28         struct zonefs_sysfs_attr *zonefs_attr      28         struct zonefs_sysfs_attr *zonefs_attr =
 29                 container_of(attr, struct zone     29                 container_of(attr, struct zonefs_sysfs_attr, attr);
 30                                                    30 
 31         if (!zonefs_attr->show)                    31         if (!zonefs_attr->show)
 32                 return 0;                          32                 return 0;
 33                                                    33 
 34         return zonefs_attr->show(sbi, buf);        34         return zonefs_attr->show(sbi, buf);
 35 }                                                  35 }
 36                                                    36 
 37 static ssize_t max_wro_seq_files_show(struct z     37 static ssize_t max_wro_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 38 {                                                  38 {
 39         return sysfs_emit(buf, "%u\n", sbi->s_     39         return sysfs_emit(buf, "%u\n", sbi->s_max_wro_seq_files);
 40 }                                                  40 }
 41 ZONEFS_SYSFS_ATTR_RO(max_wro_seq_files);           41 ZONEFS_SYSFS_ATTR_RO(max_wro_seq_files);
 42                                                    42 
 43 static ssize_t nr_wro_seq_files_show(struct zo     43 static ssize_t nr_wro_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 44 {                                                  44 {
 45         return sysfs_emit(buf, "%d\n", atomic_     45         return sysfs_emit(buf, "%d\n", atomic_read(&sbi->s_wro_seq_files));
 46 }                                                  46 }
 47 ZONEFS_SYSFS_ATTR_RO(nr_wro_seq_files);            47 ZONEFS_SYSFS_ATTR_RO(nr_wro_seq_files);
 48                                                    48 
 49 static ssize_t max_active_seq_files_show(struc     49 static ssize_t max_active_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 50 {                                                  50 {
 51         return sysfs_emit(buf, "%u\n", sbi->s_     51         return sysfs_emit(buf, "%u\n", sbi->s_max_active_seq_files);
 52 }                                                  52 }
 53 ZONEFS_SYSFS_ATTR_RO(max_active_seq_files);        53 ZONEFS_SYSFS_ATTR_RO(max_active_seq_files);
 54                                                    54 
 55 static ssize_t nr_active_seq_files_show(struct     55 static ssize_t nr_active_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 56 {                                                  56 {
 57         return sysfs_emit(buf, "%d\n", atomic_     57         return sysfs_emit(buf, "%d\n", atomic_read(&sbi->s_active_seq_files));
 58 }                                                  58 }
 59 ZONEFS_SYSFS_ATTR_RO(nr_active_seq_files);         59 ZONEFS_SYSFS_ATTR_RO(nr_active_seq_files);
 60                                                    60 
 61 static struct attribute *zonefs_sysfs_attrs[]      61 static struct attribute *zonefs_sysfs_attrs[] = {
 62         ATTR_LIST(max_wro_seq_files),              62         ATTR_LIST(max_wro_seq_files),
 63         ATTR_LIST(nr_wro_seq_files),               63         ATTR_LIST(nr_wro_seq_files),
 64         ATTR_LIST(max_active_seq_files),           64         ATTR_LIST(max_active_seq_files),
 65         ATTR_LIST(nr_active_seq_files),            65         ATTR_LIST(nr_active_seq_files),
 66         NULL,                                      66         NULL,
 67 };                                                 67 };
 68 ATTRIBUTE_GROUPS(zonefs_sysfs);                    68 ATTRIBUTE_GROUPS(zonefs_sysfs);
 69                                                    69 
 70 static void zonefs_sysfs_sb_release(struct kob     70 static void zonefs_sysfs_sb_release(struct kobject *kobj)
 71 {                                                  71 {
 72         struct zonefs_sb_info *sbi =               72         struct zonefs_sb_info *sbi =
 73                 container_of(kobj, struct zone     73                 container_of(kobj, struct zonefs_sb_info, s_kobj);
 74                                                    74 
 75         complete(&sbi->s_kobj_unregister);         75         complete(&sbi->s_kobj_unregister);
 76 }                                                  76 }
 77                                                    77 
 78 static const struct sysfs_ops zonefs_sysfs_att     78 static const struct sysfs_ops zonefs_sysfs_attr_ops = {
 79         .show   = zonefs_sysfs_attr_show,          79         .show   = zonefs_sysfs_attr_show,
 80 };                                                 80 };
 81                                                    81 
 82 static const struct kobj_type zonefs_sb_ktype      82 static const struct kobj_type zonefs_sb_ktype = {
 83         .default_groups = zonefs_sysfs_groups,     83         .default_groups = zonefs_sysfs_groups,
 84         .sysfs_ops      = &zonefs_sysfs_attr_o     84         .sysfs_ops      = &zonefs_sysfs_attr_ops,
 85         .release        = zonefs_sysfs_sb_rele     85         .release        = zonefs_sysfs_sb_release,
 86 };                                                 86 };
 87                                                    87 
 88 static struct kobject *zonefs_sysfs_root;          88 static struct kobject *zonefs_sysfs_root;
 89                                                    89 
 90 int zonefs_sysfs_register(struct super_block *     90 int zonefs_sysfs_register(struct super_block *sb)
 91 {                                                  91 {
 92         struct zonefs_sb_info *sbi = ZONEFS_SB     92         struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 93         int ret;                                   93         int ret;
 94                                                    94 
 95         init_completion(&sbi->s_kobj_unregiste     95         init_completion(&sbi->s_kobj_unregister);
 96         ret = kobject_init_and_add(&sbi->s_kob     96         ret = kobject_init_and_add(&sbi->s_kobj, &zonefs_sb_ktype,
 97                                    zonefs_sysf     97                                    zonefs_sysfs_root, "%s", sb->s_id);
 98         if (ret) {                                 98         if (ret) {
 99                 kobject_put(&sbi->s_kobj);         99                 kobject_put(&sbi->s_kobj);
100                 wait_for_completion(&sbi->s_ko    100                 wait_for_completion(&sbi->s_kobj_unregister);
101                 return ret;                       101                 return ret;
102         }                                         102         }
103                                                   103 
104         sbi->s_sysfs_registered = true;           104         sbi->s_sysfs_registered = true;
105                                                   105 
106         return 0;                                 106         return 0;
107 }                                                 107 }
108                                                   108 
109 void zonefs_sysfs_unregister(struct super_bloc    109 void zonefs_sysfs_unregister(struct super_block *sb)
110 {                                                 110 {
111         struct zonefs_sb_info *sbi = ZONEFS_SB    111         struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
112                                                   112 
113         if (!sbi || !sbi->s_sysfs_registered)     113         if (!sbi || !sbi->s_sysfs_registered)
114                 return;                           114                 return;
115                                                   115 
116         kobject_del(&sbi->s_kobj);                116         kobject_del(&sbi->s_kobj);
117         kobject_put(&sbi->s_kobj);                117         kobject_put(&sbi->s_kobj);
118         wait_for_completion(&sbi->s_kobj_unreg    118         wait_for_completion(&sbi->s_kobj_unregister);
119 }                                                 119 }
120                                                   120 
121 int __init zonefs_sysfs_init(void)                121 int __init zonefs_sysfs_init(void)
122 {                                                 122 {
123         zonefs_sysfs_root = kobject_create_and    123         zonefs_sysfs_root = kobject_create_and_add("zonefs", fs_kobj);
124         if (!zonefs_sysfs_root)                   124         if (!zonefs_sysfs_root)
125                 return -ENOMEM;                   125                 return -ENOMEM;
126                                                   126 
127         return 0;                                 127         return 0;
128 }                                                 128 }
129                                                   129 
130 void zonefs_sysfs_exit(void)                      130 void zonefs_sysfs_exit(void)
131 {                                                 131 {
132         kobject_put(zonefs_sysfs_root);           132         kobject_put(zonefs_sysfs_root);
133         zonefs_sysfs_root = NULL;                 133         zonefs_sysfs_root = NULL;
134 }                                                 134 }
135                                                   135 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php