aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nilfs2/Makefile2
-rw-r--r--fs/nilfs2/nilfs.h8
-rw-r--r--fs/nilfs2/super.c9
-rw-r--r--fs/nilfs2/sysfs.c4
-rw-r--r--fs/nilfs2/the_nilfs.c16
5 files changed, 34 insertions, 5 deletions
diff --git a/fs/nilfs2/Makefile b/fs/nilfs2/Makefile
index 85c98737a146..fc603e0431bb 100644
--- a/fs/nilfs2/Makefile
+++ b/fs/nilfs2/Makefile
@@ -2,4 +2,4 @@ obj-$(CONFIG_NILFS2_FS) += nilfs2.o
2nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \ 2nilfs2-y := inode.o file.o dir.o super.o namei.o page.o mdt.o \
3 btnode.o bmap.o btree.o direct.o dat.o recovery.o \ 3 btnode.o bmap.o btree.o direct.o dat.o recovery.o \
4 the_nilfs.o segbuf.o segment.o cpfile.o sufile.o \ 4 the_nilfs.o segbuf.o segment.o cpfile.o sufile.o \
5 ifile.o alloc.o gcinode.o ioctl.o 5 ifile.o alloc.o gcinode.o ioctl.o sysfs.o
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 9bc72dec3fa6..0696161bf59d 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -320,6 +320,14 @@ int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *);
320int nilfs_init_gcinode(struct inode *inode); 320int nilfs_init_gcinode(struct inode *inode);
321void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs); 321void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs);
322 322
323/* sysfs.c */
324int __init nilfs_sysfs_init(void);
325void nilfs_sysfs_exit(void);
326int nilfs_sysfs_create_device_group(struct super_block *);
327void nilfs_sysfs_delete_device_group(struct the_nilfs *);
328int nilfs_sysfs_create_snapshot_group(struct nilfs_root *);
329void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *);
330
323/* 331/*
324 * Inodes and files operations 332 * Inodes and files operations
325 */ 333 */
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 8c532b2ca3ab..c519927b7b5e 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1452,13 +1452,19 @@ static int __init init_nilfs_fs(void)
1452 if (err) 1452 if (err)
1453 goto fail; 1453 goto fail;
1454 1454
1455 err = register_filesystem(&nilfs_fs_type); 1455 err = nilfs_sysfs_init();
1456 if (err) 1456 if (err)
1457 goto free_cachep; 1457 goto free_cachep;
1458 1458
1459 err = register_filesystem(&nilfs_fs_type);
1460 if (err)
1461 goto deinit_sysfs_entry;
1462
1459 printk(KERN_INFO "NILFS version 2 loaded\n"); 1463 printk(KERN_INFO "NILFS version 2 loaded\n");
1460 return 0; 1464 return 0;
1461 1465
1466deinit_sysfs_entry:
1467 nilfs_sysfs_exit();
1462free_cachep: 1468free_cachep:
1463 nilfs_destroy_cachep(); 1469 nilfs_destroy_cachep();
1464fail: 1470fail:
@@ -1468,6 +1474,7 @@ fail:
1468static void __exit exit_nilfs_fs(void) 1474static void __exit exit_nilfs_fs(void)
1469{ 1475{
1470 nilfs_destroy_cachep(); 1476 nilfs_destroy_cachep();
1477 nilfs_sysfs_exit();
1471 unregister_filesystem(&nilfs_fs_type); 1478 unregister_filesystem(&nilfs_fs_type);
1472} 1479}
1473 1480
diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 0f6148c8121a..bbb0dcc35905 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -87,7 +87,7 @@ static struct kobj_type nilfs_##name##_ktype = { \
87}; 87};
88 88
89#define NILFS_DEV_INT_GROUP_FNS(name, parent_name) \ 89#define NILFS_DEV_INT_GROUP_FNS(name, parent_name) \
90int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \ 90static int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \
91{ \ 91{ \
92 struct kobject *parent; \ 92 struct kobject *parent; \
93 struct kobject *kobj; \ 93 struct kobject *kobj; \
@@ -106,7 +106,7 @@ int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \
106 return err; \ 106 return err; \
107 return 0; \ 107 return 0; \
108} \ 108} \
109void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \ 109static void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \
110{ \ 110{ \
111 kobject_del(&nilfs->ns_##parent_name##_subgroups->sg_##name##_kobj); \ 111 kobject_del(&nilfs->ns_##parent_name##_subgroups->sg_##name##_kobj); \
112} 112}
diff --git a/fs/nilfs2/the_nilfs.c b/fs/nilfs2/the_nilfs.c
index 59d50088b886..9da25fe9ea61 100644
--- a/fs/nilfs2/the_nilfs.c
+++ b/fs/nilfs2/the_nilfs.c
@@ -98,6 +98,7 @@ void destroy_nilfs(struct the_nilfs *nilfs)
98{ 98{
99 might_sleep(); 99 might_sleep();
100 if (nilfs_init(nilfs)) { 100 if (nilfs_init(nilfs)) {
101 nilfs_sysfs_delete_device_group(nilfs);
101 brelse(nilfs->ns_sbh[0]); 102 brelse(nilfs->ns_sbh[0]);
102 brelse(nilfs->ns_sbh[1]); 103 brelse(nilfs->ns_sbh[1]);
103 } 104 }
@@ -641,6 +642,10 @@ int init_nilfs(struct the_nilfs *nilfs, struct super_block *sb, char *data)
641 if (err) 642 if (err)
642 goto failed_sbh; 643 goto failed_sbh;
643 644
645 err = nilfs_sysfs_create_device_group(sb);
646 if (err)
647 goto failed_sbh;
648
644 set_nilfs_init(nilfs); 649 set_nilfs_init(nilfs);
645 err = 0; 650 err = 0;
646 out: 651 out:
@@ -741,12 +746,13 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno)
741{ 746{
742 struct rb_node **p, *parent; 747 struct rb_node **p, *parent;
743 struct nilfs_root *root, *new; 748 struct nilfs_root *root, *new;
749 int err;
744 750
745 root = nilfs_lookup_root(nilfs, cno); 751 root = nilfs_lookup_root(nilfs, cno);
746 if (root) 752 if (root)
747 return root; 753 return root;
748 754
749 new = kmalloc(sizeof(*root), GFP_KERNEL); 755 new = kzalloc(sizeof(*root), GFP_KERNEL);
750 if (!new) 756 if (!new)
751 return NULL; 757 return NULL;
752 758
@@ -783,6 +789,12 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno)
783 789
784 spin_unlock(&nilfs->ns_cptree_lock); 790 spin_unlock(&nilfs->ns_cptree_lock);
785 791
792 err = nilfs_sysfs_create_snapshot_group(new);
793 if (err) {
794 kfree(new);
795 new = NULL;
796 }
797
786 return new; 798 return new;
787} 799}
788 800
@@ -791,6 +803,8 @@ void nilfs_put_root(struct nilfs_root *root)
791 if (atomic_dec_and_test(&root->count)) { 803 if (atomic_dec_and_test(&root->count)) {
792 struct the_nilfs *nilfs = root->nilfs; 804 struct the_nilfs *nilfs = root->nilfs;
793 805
806 nilfs_sysfs_delete_snapshot_group(root);
807
794 spin_lock(&nilfs->ns_cptree_lock); 808 spin_lock(&nilfs->ns_cptree_lock);
795 rb_erase(&root->rb_node, &nilfs->ns_cptree); 809 rb_erase(&root->rb_node, &nilfs->ns_cptree);
796 spin_unlock(&nilfs->ns_cptree_lock); 810 spin_unlock(&nilfs->ns_cptree_lock);