diff options
Diffstat (limited to 'fs/nilfs2/sysfs.c')
-rw-r--r-- | fs/nilfs2/sysfs.c | 99 |
1 files changed, 98 insertions, 1 deletions
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index 61454a859e81..fe8e1411dc6a 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c | |||
@@ -112,6 +112,95 @@ void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \ | |||
112 | } | 112 | } |
113 | 113 | ||
114 | /************************************************************************ | 114 | /************************************************************************ |
115 | * NILFS segments attrs * | ||
116 | ************************************************************************/ | ||
117 | |||
118 | static ssize_t | ||
119 | nilfs_segments_segments_number_show(struct nilfs_segments_attr *attr, | ||
120 | struct the_nilfs *nilfs, | ||
121 | char *buf) | ||
122 | { | ||
123 | return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_nsegments); | ||
124 | } | ||
125 | |||
126 | static ssize_t | ||
127 | nilfs_segments_blocks_per_segment_show(struct nilfs_segments_attr *attr, | ||
128 | struct the_nilfs *nilfs, | ||
129 | char *buf) | ||
130 | { | ||
131 | return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_blocks_per_segment); | ||
132 | } | ||
133 | |||
134 | static ssize_t | ||
135 | nilfs_segments_clean_segments_show(struct nilfs_segments_attr *attr, | ||
136 | struct the_nilfs *nilfs, | ||
137 | char *buf) | ||
138 | { | ||
139 | unsigned long ncleansegs; | ||
140 | |||
141 | down_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem); | ||
142 | ncleansegs = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile); | ||
143 | up_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem); | ||
144 | |||
145 | return snprintf(buf, PAGE_SIZE, "%lu\n", ncleansegs); | ||
146 | } | ||
147 | |||
148 | static ssize_t | ||
149 | nilfs_segments_dirty_segments_show(struct nilfs_segments_attr *attr, | ||
150 | struct the_nilfs *nilfs, | ||
151 | char *buf) | ||
152 | { | ||
153 | struct nilfs_sustat sustat; | ||
154 | int err; | ||
155 | |||
156 | down_read(&nilfs->ns_segctor_sem); | ||
157 | err = nilfs_sufile_get_stat(nilfs->ns_sufile, &sustat); | ||
158 | up_read(&nilfs->ns_segctor_sem); | ||
159 | if (err < 0) { | ||
160 | printk(KERN_ERR "NILFS: unable to get segment stat: err=%d\n", | ||
161 | err); | ||
162 | return err; | ||
163 | } | ||
164 | |||
165 | return snprintf(buf, PAGE_SIZE, "%llu\n", sustat.ss_ndirtysegs); | ||
166 | } | ||
167 | |||
168 | static const char segments_readme_str[] = | ||
169 | "The segments group contains attributes that describe\n" | ||
170 | "details about volume's segments.\n\n" | ||
171 | "(1) segments_number\n\tshow number of segments on volume.\n\n" | ||
172 | "(2) blocks_per_segment\n\tshow number of blocks in segment.\n\n" | ||
173 | "(3) clean_segments\n\tshow count of clean segments.\n\n" | ||
174 | "(4) dirty_segments\n\tshow count of dirty segments.\n\n"; | ||
175 | |||
176 | static ssize_t | ||
177 | nilfs_segments_README_show(struct nilfs_segments_attr *attr, | ||
178 | struct the_nilfs *nilfs, | ||
179 | char *buf) | ||
180 | { | ||
181 | return snprintf(buf, PAGE_SIZE, segments_readme_str); | ||
182 | } | ||
183 | |||
184 | NILFS_SEGMENTS_RO_ATTR(segments_number); | ||
185 | NILFS_SEGMENTS_RO_ATTR(blocks_per_segment); | ||
186 | NILFS_SEGMENTS_RO_ATTR(clean_segments); | ||
187 | NILFS_SEGMENTS_RO_ATTR(dirty_segments); | ||
188 | NILFS_SEGMENTS_RO_ATTR(README); | ||
189 | |||
190 | static struct attribute *nilfs_segments_attrs[] = { | ||
191 | NILFS_SEGMENTS_ATTR_LIST(segments_number), | ||
192 | NILFS_SEGMENTS_ATTR_LIST(blocks_per_segment), | ||
193 | NILFS_SEGMENTS_ATTR_LIST(clean_segments), | ||
194 | NILFS_SEGMENTS_ATTR_LIST(dirty_segments), | ||
195 | NILFS_SEGMENTS_ATTR_LIST(README), | ||
196 | NULL, | ||
197 | }; | ||
198 | |||
199 | NILFS_DEV_INT_GROUP_OPS(segments, dev); | ||
200 | NILFS_DEV_INT_GROUP_TYPE(segments, dev); | ||
201 | NILFS_DEV_INT_GROUP_FNS(segments, dev); | ||
202 | |||
203 | /************************************************************************ | ||
115 | * NILFS segctor attrs * | 204 | * NILFS segctor attrs * |
116 | ************************************************************************/ | 205 | ************************************************************************/ |
117 | 206 | ||
@@ -664,10 +753,14 @@ int nilfs_sysfs_create_device_group(struct super_block *sb) | |||
664 | if (err) | 753 | if (err) |
665 | goto free_dev_subgroups; | 754 | goto free_dev_subgroups; |
666 | 755 | ||
667 | err = nilfs_sysfs_create_superblock_group(nilfs); | 756 | err = nilfs_sysfs_create_segments_group(nilfs); |
668 | if (err) | 757 | if (err) |
669 | goto cleanup_dev_kobject; | 758 | goto cleanup_dev_kobject; |
670 | 759 | ||
760 | err = nilfs_sysfs_create_superblock_group(nilfs); | ||
761 | if (err) | ||
762 | goto delete_segments_group; | ||
763 | |||
671 | err = nilfs_sysfs_create_segctor_group(nilfs); | 764 | err = nilfs_sysfs_create_segctor_group(nilfs); |
672 | if (err) | 765 | if (err) |
673 | goto delete_superblock_group; | 766 | goto delete_superblock_group; |
@@ -677,6 +770,9 @@ int nilfs_sysfs_create_device_group(struct super_block *sb) | |||
677 | delete_superblock_group: | 770 | delete_superblock_group: |
678 | nilfs_sysfs_delete_superblock_group(nilfs); | 771 | nilfs_sysfs_delete_superblock_group(nilfs); |
679 | 772 | ||
773 | delete_segments_group: | ||
774 | nilfs_sysfs_delete_segments_group(nilfs); | ||
775 | |||
680 | cleanup_dev_kobject: | 776 | cleanup_dev_kobject: |
681 | kobject_del(&nilfs->ns_dev_kobj); | 777 | kobject_del(&nilfs->ns_dev_kobj); |
682 | 778 | ||
@@ -689,6 +785,7 @@ failed_create_device_group: | |||
689 | 785 | ||
690 | void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs) | 786 | void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs) |
691 | { | 787 | { |
788 | nilfs_sysfs_delete_segments_group(nilfs); | ||
692 | nilfs_sysfs_delete_superblock_group(nilfs); | 789 | nilfs_sysfs_delete_superblock_group(nilfs); |
693 | nilfs_sysfs_delete_segctor_group(nilfs); | 790 | nilfs_sysfs_delete_segctor_group(nilfs); |
694 | kobject_del(&nilfs->ns_dev_kobj); | 791 | kobject_del(&nilfs->ns_dev_kobj); |