aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2
diff options
context:
space:
mode:
authorVyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>2014-08-08 17:20:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 18:57:21 -0400
commita2ecb791a9d6e71a2d37d66034475a92ebc7e02c (patch)
treef9f5c2d3bd24ef0105786d73561bbcafaca3fb25 /fs/nilfs2
parent02a0ba1c60c2ad532322089a60256c8b0f46678c (diff)
nilfs2: add /sys/fs/nilfs2/<device>/mounted_snapshots group
This patch adds creation of /sys/fs/nilfs2/<device>/mounted_snapshots group. The mounted_snapshots group contains group for every mounted snapshot. Signed-off-by: Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com> Cc: Vyacheslav Dubeyko <slava@dubeyko.com> Cc: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Cc: Michael L. Semon <mlsemon35@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r--fs/nilfs2/sysfs.c36
-rw-r--r--fs/nilfs2/sysfs.h12
2 files changed, 47 insertions, 1 deletions
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 5cc735fcc1d5..fc0c961d486a 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -112,6 +112,32 @@ void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \
112} 112}
113 113
114/************************************************************************ 114/************************************************************************
115 * NILFS mounted snapshots attrs *
116 ************************************************************************/
117
118static const char mounted_snapshots_readme_str[] =
119 "The mounted_snapshots group contains group for\n"
120 "every mounted snapshot.\n";
121
122static ssize_t
123nilfs_mounted_snapshots_README_show(struct nilfs_mounted_snapshots_attr *attr,
124 struct the_nilfs *nilfs, char *buf)
125{
126 return snprintf(buf, PAGE_SIZE, mounted_snapshots_readme_str);
127}
128
129NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(README);
130
131static struct attribute *nilfs_mounted_snapshots_attrs[] = {
132 NILFS_MOUNTED_SNAPSHOTS_ATTR_LIST(README),
133 NULL,
134};
135
136NILFS_DEV_INT_GROUP_OPS(mounted_snapshots, dev);
137NILFS_DEV_INT_GROUP_TYPE(mounted_snapshots, dev);
138NILFS_DEV_INT_GROUP_FNS(mounted_snapshots, dev);
139
140/************************************************************************
115 * NILFS checkpoints attrs * 141 * NILFS checkpoints attrs *
116 ************************************************************************/ 142 ************************************************************************/
117 143
@@ -866,10 +892,14 @@ int nilfs_sysfs_create_device_group(struct super_block *sb)
866 if (err) 892 if (err)
867 goto free_dev_subgroups; 893 goto free_dev_subgroups;
868 894
869 err = nilfs_sysfs_create_checkpoints_group(nilfs); 895 err = nilfs_sysfs_create_mounted_snapshots_group(nilfs);
870 if (err) 896 if (err)
871 goto cleanup_dev_kobject; 897 goto cleanup_dev_kobject;
872 898
899 err = nilfs_sysfs_create_checkpoints_group(nilfs);
900 if (err)
901 goto delete_mounted_snapshots_group;
902
873 err = nilfs_sysfs_create_segments_group(nilfs); 903 err = nilfs_sysfs_create_segments_group(nilfs);
874 if (err) 904 if (err)
875 goto delete_checkpoints_group; 905 goto delete_checkpoints_group;
@@ -893,6 +923,9 @@ delete_segments_group:
893delete_checkpoints_group: 923delete_checkpoints_group:
894 nilfs_sysfs_delete_checkpoints_group(nilfs); 924 nilfs_sysfs_delete_checkpoints_group(nilfs);
895 925
926delete_mounted_snapshots_group:
927 nilfs_sysfs_delete_mounted_snapshots_group(nilfs);
928
896cleanup_dev_kobject: 929cleanup_dev_kobject:
897 kobject_del(&nilfs->ns_dev_kobj); 930 kobject_del(&nilfs->ns_dev_kobj);
898 931
@@ -905,6 +938,7 @@ failed_create_device_group:
905 938
906void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs) 939void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs)
907{ 940{
941 nilfs_sysfs_delete_mounted_snapshots_group(nilfs);
908 nilfs_sysfs_delete_checkpoints_group(nilfs); 942 nilfs_sysfs_delete_checkpoints_group(nilfs);
909 nilfs_sysfs_delete_segments_group(nilfs); 943 nilfs_sysfs_delete_segments_group(nilfs);
910 nilfs_sysfs_delete_superblock_group(nilfs); 944 nilfs_sysfs_delete_superblock_group(nilfs);
diff --git a/fs/nilfs2/sysfs.h b/fs/nilfs2/sysfs.h
index 62f0a0dc78ca..4e84e230e9dd 100644
--- a/fs/nilfs2/sysfs.h
+++ b/fs/nilfs2/sysfs.h
@@ -30,6 +30,8 @@
30 * @sg_superblock_kobj_unregister: completion state 30 * @sg_superblock_kobj_unregister: completion state
31 * @sg_segctor_kobj: /sys/fs/<nilfs>/<device>/segctor 31 * @sg_segctor_kobj: /sys/fs/<nilfs>/<device>/segctor
32 * @sg_segctor_kobj_unregister: completion state 32 * @sg_segctor_kobj_unregister: completion state
33 * @sg_mounted_snapshots_kobj: /sys/fs/<nilfs>/<device>/mounted_snapshots
34 * @sg_mounted_snapshots_kobj_unregister: completion state
33 * @sg_checkpoints_kobj: /sys/fs/<nilfs>/<device>/checkpoints 35 * @sg_checkpoints_kobj: /sys/fs/<nilfs>/<device>/checkpoints
34 * @sg_checkpoints_kobj_unregister: completion state 36 * @sg_checkpoints_kobj_unregister: completion state
35 * @sg_segments_kobj: /sys/fs/<nilfs>/<device>/segments 37 * @sg_segments_kobj: /sys/fs/<nilfs>/<device>/segments
@@ -44,6 +46,10 @@ struct nilfs_sysfs_dev_subgroups {
44 struct kobject sg_segctor_kobj; 46 struct kobject sg_segctor_kobj;
45 struct completion sg_segctor_kobj_unregister; 47 struct completion sg_segctor_kobj_unregister;
46 48
49 /* /sys/fs/<nilfs>/<device>/mounted_snapshots */
50 struct kobject sg_mounted_snapshots_kobj;
51 struct completion sg_mounted_snapshots_kobj_unregister;
52
47 /* /sys/fs/<nilfs>/<device>/checkpoints */ 53 /* /sys/fs/<nilfs>/<device>/checkpoints */
48 struct kobject sg_checkpoints_kobj; 54 struct kobject sg_checkpoints_kobj;
49 struct completion sg_checkpoints_kobj_unregister; 55 struct completion sg_checkpoints_kobj_unregister;
@@ -75,6 +81,7 @@ struct nilfs_##name##_attr { \
75 81
76NILFS_DEV_ATTR_STRUCT(dev); 82NILFS_DEV_ATTR_STRUCT(dev);
77NILFS_DEV_ATTR_STRUCT(segments); 83NILFS_DEV_ATTR_STRUCT(segments);
84NILFS_DEV_ATTR_STRUCT(mounted_snapshots);
78NILFS_DEV_ATTR_STRUCT(checkpoints); 85NILFS_DEV_ATTR_STRUCT(checkpoints);
79NILFS_DEV_ATTR_STRUCT(superblock); 86NILFS_DEV_ATTR_STRUCT(superblock);
80NILFS_DEV_ATTR_STRUCT(segctor); 87NILFS_DEV_ATTR_STRUCT(segctor);
@@ -111,6 +118,9 @@ NILFS_DEV_ATTR_STRUCT(segctor);
111#define NILFS_SEGMENTS_RW_ATTR(name) \ 118#define NILFS_SEGMENTS_RW_ATTR(name) \
112 NILFS_RW_ATTR(segs_info, name) 119 NILFS_RW_ATTR(segs_info, name)
113 120
121#define NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(name) \
122 NILFS_RO_ATTR(mounted_snapshots, name)
123
114#define NILFS_CHECKPOINTS_RO_ATTR(name) \ 124#define NILFS_CHECKPOINTS_RO_ATTR(name) \
115 NILFS_RO_ATTR(checkpoints, name) 125 NILFS_RO_ATTR(checkpoints, name)
116#define NILFS_CHECKPOINTS_RW_ATTR(name) \ 126#define NILFS_CHECKPOINTS_RW_ATTR(name) \
@@ -134,6 +144,8 @@ NILFS_DEV_ATTR_STRUCT(segctor);
134 (&nilfs_dev_attr_##name.attr) 144 (&nilfs_dev_attr_##name.attr)
135#define NILFS_SEGMENTS_ATTR_LIST(name) \ 145#define NILFS_SEGMENTS_ATTR_LIST(name) \
136 (&nilfs_segments_attr_##name.attr) 146 (&nilfs_segments_attr_##name.attr)
147#define NILFS_MOUNTED_SNAPSHOTS_ATTR_LIST(name) \
148 (&nilfs_mounted_snapshots_attr_##name.attr)
137#define NILFS_CHECKPOINTS_ATTR_LIST(name) \ 149#define NILFS_CHECKPOINTS_ATTR_LIST(name) \
138 (&nilfs_checkpoints_attr_##name.attr) 150 (&nilfs_checkpoints_attr_##name.attr)
139#define NILFS_SUPERBLOCK_ATTR_LIST(name) \ 151#define NILFS_SUPERBLOCK_ATTR_LIST(name) \