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

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

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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 (Version linux-6.12-rc7) and /fs/zonefs/sysfs.c (Version linux-6.0.19)


  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 static inline struct zonefs_sysfs_attr *to_attr(struct attribute *attr)
                                                   >>  19 {
                                                   >>  20         return container_of(attr, struct zonefs_sysfs_attr, attr);
                                                   >>  21 }
                                                   >>  22 
 18 #define ZONEFS_SYSFS_ATTR_RO(name) \               23 #define ZONEFS_SYSFS_ATTR_RO(name) \
 19 static struct zonefs_sysfs_attr zonefs_sysfs_a     24 static struct zonefs_sysfs_attr zonefs_sysfs_attr_##name = __ATTR_RO(name)
 20                                                    25 
 21 #define ATTR_LIST(name) &zonefs_sysfs_attr_##n     26 #define ATTR_LIST(name) &zonefs_sysfs_attr_##name.attr
 22                                                    27 
 23 static ssize_t zonefs_sysfs_attr_show(struct k     28 static ssize_t zonefs_sysfs_attr_show(struct kobject *kobj,
 24                                       struct a     29                                       struct attribute *attr, char *buf)
 25 {                                                  30 {
 26         struct zonefs_sb_info *sbi =               31         struct zonefs_sb_info *sbi =
 27                 container_of(kobj, struct zone     32                 container_of(kobj, struct zonefs_sb_info, s_kobj);
 28         struct zonefs_sysfs_attr *zonefs_attr      33         struct zonefs_sysfs_attr *zonefs_attr =
 29                 container_of(attr, struct zone     34                 container_of(attr, struct zonefs_sysfs_attr, attr);
 30                                                    35 
 31         if (!zonefs_attr->show)                    36         if (!zonefs_attr->show)
 32                 return 0;                          37                 return 0;
 33                                                    38 
 34         return zonefs_attr->show(sbi, buf);        39         return zonefs_attr->show(sbi, buf);
 35 }                                                  40 }
 36                                                    41 
 37 static ssize_t max_wro_seq_files_show(struct z     42 static ssize_t max_wro_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 38 {                                                  43 {
 39         return sysfs_emit(buf, "%u\n", sbi->s_     44         return sysfs_emit(buf, "%u\n", sbi->s_max_wro_seq_files);
 40 }                                                  45 }
 41 ZONEFS_SYSFS_ATTR_RO(max_wro_seq_files);           46 ZONEFS_SYSFS_ATTR_RO(max_wro_seq_files);
 42                                                    47 
 43 static ssize_t nr_wro_seq_files_show(struct zo     48 static ssize_t nr_wro_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 44 {                                                  49 {
 45         return sysfs_emit(buf, "%d\n", atomic_     50         return sysfs_emit(buf, "%d\n", atomic_read(&sbi->s_wro_seq_files));
 46 }                                                  51 }
 47 ZONEFS_SYSFS_ATTR_RO(nr_wro_seq_files);            52 ZONEFS_SYSFS_ATTR_RO(nr_wro_seq_files);
 48                                                    53 
 49 static ssize_t max_active_seq_files_show(struc     54 static ssize_t max_active_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 50 {                                                  55 {
 51         return sysfs_emit(buf, "%u\n", sbi->s_     56         return sysfs_emit(buf, "%u\n", sbi->s_max_active_seq_files);
 52 }                                                  57 }
 53 ZONEFS_SYSFS_ATTR_RO(max_active_seq_files);        58 ZONEFS_SYSFS_ATTR_RO(max_active_seq_files);
 54                                                    59 
 55 static ssize_t nr_active_seq_files_show(struct     60 static ssize_t nr_active_seq_files_show(struct zonefs_sb_info *sbi, char *buf)
 56 {                                                  61 {
 57         return sysfs_emit(buf, "%d\n", atomic_     62         return sysfs_emit(buf, "%d\n", atomic_read(&sbi->s_active_seq_files));
 58 }                                                  63 }
 59 ZONEFS_SYSFS_ATTR_RO(nr_active_seq_files);         64 ZONEFS_SYSFS_ATTR_RO(nr_active_seq_files);
 60                                                    65 
 61 static struct attribute *zonefs_sysfs_attrs[]      66 static struct attribute *zonefs_sysfs_attrs[] = {
 62         ATTR_LIST(max_wro_seq_files),              67         ATTR_LIST(max_wro_seq_files),
 63         ATTR_LIST(nr_wro_seq_files),               68         ATTR_LIST(nr_wro_seq_files),
 64         ATTR_LIST(max_active_seq_files),           69         ATTR_LIST(max_active_seq_files),
 65         ATTR_LIST(nr_active_seq_files),            70         ATTR_LIST(nr_active_seq_files),
 66         NULL,                                      71         NULL,
 67 };                                                 72 };
 68 ATTRIBUTE_GROUPS(zonefs_sysfs);                    73 ATTRIBUTE_GROUPS(zonefs_sysfs);
 69                                                    74 
 70 static void zonefs_sysfs_sb_release(struct kob     75 static void zonefs_sysfs_sb_release(struct kobject *kobj)
 71 {                                                  76 {
 72         struct zonefs_sb_info *sbi =               77         struct zonefs_sb_info *sbi =
 73                 container_of(kobj, struct zone     78                 container_of(kobj, struct zonefs_sb_info, s_kobj);
 74                                                    79 
 75         complete(&sbi->s_kobj_unregister);         80         complete(&sbi->s_kobj_unregister);
 76 }                                                  81 }
 77                                                    82 
 78 static const struct sysfs_ops zonefs_sysfs_att     83 static const struct sysfs_ops zonefs_sysfs_attr_ops = {
 79         .show   = zonefs_sysfs_attr_show,          84         .show   = zonefs_sysfs_attr_show,
 80 };                                                 85 };
 81                                                    86 
 82 static const struct kobj_type zonefs_sb_ktype  !!  87 static struct kobj_type zonefs_sb_ktype = {
 83         .default_groups = zonefs_sysfs_groups,     88         .default_groups = zonefs_sysfs_groups,
 84         .sysfs_ops      = &zonefs_sysfs_attr_o     89         .sysfs_ops      = &zonefs_sysfs_attr_ops,
 85         .release        = zonefs_sysfs_sb_rele     90         .release        = zonefs_sysfs_sb_release,
 86 };                                                 91 };
 87                                                    92 
 88 static struct kobject *zonefs_sysfs_root;          93 static struct kobject *zonefs_sysfs_root;
 89                                                    94 
 90 int zonefs_sysfs_register(struct super_block *     95 int zonefs_sysfs_register(struct super_block *sb)
 91 {                                                  96 {
 92         struct zonefs_sb_info *sbi = ZONEFS_SB     97         struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 93         int ret;                                   98         int ret;
 94                                                    99 
 95         super_set_sysfs_name_id(sb);           << 
 96         init_completion(&sbi->s_kobj_unregiste    100         init_completion(&sbi->s_kobj_unregister);
 97         ret = kobject_init_and_add(&sbi->s_kob    101         ret = kobject_init_and_add(&sbi->s_kobj, &zonefs_sb_ktype,
 98                                    zonefs_sysf    102                                    zonefs_sysfs_root, "%s", sb->s_id);
 99         if (ret) {                                103         if (ret) {
100                 kobject_put(&sbi->s_kobj);        104                 kobject_put(&sbi->s_kobj);
101                 wait_for_completion(&sbi->s_ko    105                 wait_for_completion(&sbi->s_kobj_unregister);
102                 return ret;                       106                 return ret;
103         }                                         107         }
104                                                   108 
105         sbi->s_sysfs_registered = true;           109         sbi->s_sysfs_registered = true;
106                                                   110 
107         return 0;                                 111         return 0;
108 }                                                 112 }
109                                                   113 
110 void zonefs_sysfs_unregister(struct super_bloc    114 void zonefs_sysfs_unregister(struct super_block *sb)
111 {                                                 115 {
112         struct zonefs_sb_info *sbi = ZONEFS_SB    116         struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
113                                                   117 
114         if (!sbi || !sbi->s_sysfs_registered)     118         if (!sbi || !sbi->s_sysfs_registered)
115                 return;                           119                 return;
116                                                   120 
117         kobject_del(&sbi->s_kobj);                121         kobject_del(&sbi->s_kobj);
118         kobject_put(&sbi->s_kobj);                122         kobject_put(&sbi->s_kobj);
119         wait_for_completion(&sbi->s_kobj_unreg    123         wait_for_completion(&sbi->s_kobj_unregister);
120 }                                                 124 }
121                                                   125 
122 int __init zonefs_sysfs_init(void)                126 int __init zonefs_sysfs_init(void)
123 {                                                 127 {
124         zonefs_sysfs_root = kobject_create_and    128         zonefs_sysfs_root = kobject_create_and_add("zonefs", fs_kobj);
125         if (!zonefs_sysfs_root)                   129         if (!zonefs_sysfs_root)
126                 return -ENOMEM;                   130                 return -ENOMEM;
127                                                   131 
128         return 0;                                 132         return 0;
129 }                                                 133 }
130                                                   134 
131 void zonefs_sysfs_exit(void)                      135 void zonefs_sysfs_exit(void)
132 {                                                 136 {
133         kobject_put(zonefs_sysfs_root);           137         kobject_put(zonefs_sysfs_root);
134         zonefs_sysfs_root = NULL;                 138         zonefs_sysfs_root = NULL;
135 }                                                 139 }
136                                                   140 

~ [ 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