aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-01-14 04:42:30 -0500
committerJens Axboe <axboe@fb.com>2015-01-20 16:02:54 -0500
commita7a2c680a2ad81b3181a335ee76e23d5195007ee (patch)
tree6755c100ab14f95ab78eba709f2de737b16e3d02
parentec6f34e5b552fb0a52e6aae1a5afbbb1605cc6cc (diff)
fs: deduplicate noop_backing_dev_info
hugetlbfs, kernfs and dlmfs can simply use noop_backing_dev_info instead of creating a local duplicate. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--fs/hugetlbfs/inode.c14
-rw-r--r--fs/kernfs/inode.c14
-rw-r--r--fs/kernfs/kernfs-internal.h1
-rw-r--r--fs/kernfs/mount.c1
-rw-r--r--fs/ocfs2/dlmfs/dlmfs.c16
5 files changed, 4 insertions, 42 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 5eba47f593f8..de7c95c7d840 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -62,12 +62,6 @@ static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode)
62 return container_of(inode, struct hugetlbfs_inode_info, vfs_inode); 62 return container_of(inode, struct hugetlbfs_inode_info, vfs_inode);
63} 63}
64 64
65static struct backing_dev_info hugetlbfs_backing_dev_info = {
66 .name = "hugetlbfs",
67 .ra_pages = 0, /* No readahead */
68 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
69};
70
71int sysctl_hugetlb_shm_group; 65int sysctl_hugetlb_shm_group;
72 66
73enum { 67enum {
@@ -498,7 +492,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
498 lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, 492 lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
499 &hugetlbfs_i_mmap_rwsem_key); 493 &hugetlbfs_i_mmap_rwsem_key);
500 inode->i_mapping->a_ops = &hugetlbfs_aops; 494 inode->i_mapping->a_ops = &hugetlbfs_aops;
501 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 495 inode->i_mapping->backing_dev_info = &noop_backing_dev_info;
502 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 496 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
503 inode->i_mapping->private_data = resv_map; 497 inode->i_mapping->private_data = resv_map;
504 info = HUGETLBFS_I(inode); 498 info = HUGETLBFS_I(inode);
@@ -1032,10 +1026,6 @@ static int __init init_hugetlbfs_fs(void)
1032 return -ENOTSUPP; 1026 return -ENOTSUPP;
1033 } 1027 }
1034 1028
1035 error = bdi_init(&hugetlbfs_backing_dev_info);
1036 if (error)
1037 return error;
1038
1039 error = -ENOMEM; 1029 error = -ENOMEM;
1040 hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache", 1030 hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache",
1041 sizeof(struct hugetlbfs_inode_info), 1031 sizeof(struct hugetlbfs_inode_info),
@@ -1071,7 +1061,6 @@ static int __init init_hugetlbfs_fs(void)
1071 out: 1061 out:
1072 kmem_cache_destroy(hugetlbfs_inode_cachep); 1062 kmem_cache_destroy(hugetlbfs_inode_cachep);
1073 out2: 1063 out2:
1074 bdi_destroy(&hugetlbfs_backing_dev_info);
1075 return error; 1064 return error;
1076} 1065}
1077 1066
@@ -1091,7 +1080,6 @@ static void __exit exit_hugetlbfs_fs(void)
1091 for_each_hstate(h) 1080 for_each_hstate(h)
1092 kern_unmount(hugetlbfs_vfsmount[i++]); 1081 kern_unmount(hugetlbfs_vfsmount[i++]);
1093 unregister_filesystem(&hugetlbfs_fs_type); 1082 unregister_filesystem(&hugetlbfs_fs_type);
1094 bdi_destroy(&hugetlbfs_backing_dev_info);
1095} 1083}
1096 1084
1097module_init(init_hugetlbfs_fs) 1085module_init(init_hugetlbfs_fs)
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 985217626e66..06f06887b2d2 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -24,12 +24,6 @@ static const struct address_space_operations kernfs_aops = {
24 .write_end = simple_write_end, 24 .write_end = simple_write_end,
25}; 25};
26 26
27static struct backing_dev_info kernfs_bdi = {
28 .name = "kernfs",
29 .ra_pages = 0, /* No readahead */
30 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
31};
32
33static const struct inode_operations kernfs_iops = { 27static const struct inode_operations kernfs_iops = {
34 .permission = kernfs_iop_permission, 28 .permission = kernfs_iop_permission,
35 .setattr = kernfs_iop_setattr, 29 .setattr = kernfs_iop_setattr,
@@ -40,12 +34,6 @@ static const struct inode_operations kernfs_iops = {
40 .listxattr = kernfs_iop_listxattr, 34 .listxattr = kernfs_iop_listxattr,
41}; 35};
42 36
43void __init kernfs_inode_init(void)
44{
45 if (bdi_init(&kernfs_bdi))
46 panic("failed to init kernfs_bdi");
47}
48
49static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn) 37static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn)
50{ 38{
51 static DEFINE_MUTEX(iattr_mutex); 39 static DEFINE_MUTEX(iattr_mutex);
@@ -298,7 +286,7 @@ static void kernfs_init_inode(struct kernfs_node *kn, struct inode *inode)
298 kernfs_get(kn); 286 kernfs_get(kn);
299 inode->i_private = kn; 287 inode->i_private = kn;
300 inode->i_mapping->a_ops = &kernfs_aops; 288 inode->i_mapping->a_ops = &kernfs_aops;
301 inode->i_mapping->backing_dev_info = &kernfs_bdi; 289 inode->i_mapping->backing_dev_info = &noop_backing_dev_info;
302 inode->i_op = &kernfs_iops; 290 inode->i_op = &kernfs_iops;
303 291
304 set_default_inode_attr(inode, kn->mode); 292 set_default_inode_attr(inode, kn->mode);
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index dc84a3ef9ca2..af9fa7499919 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -88,7 +88,6 @@ int kernfs_iop_removexattr(struct dentry *dentry, const char *name);
88ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf, 88ssize_t kernfs_iop_getxattr(struct dentry *dentry, const char *name, void *buf,
89 size_t size); 89 size_t size);
90ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size); 90ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
91void kernfs_inode_init(void);
92 91
93/* 92/*
94 * dir.c 93 * dir.c
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index f973ae9b05f1..8eaf417187f1 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -246,5 +246,4 @@ void __init kernfs_init(void)
246 kernfs_node_cache = kmem_cache_create("kernfs_node_cache", 246 kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
247 sizeof(struct kernfs_node), 247 sizeof(struct kernfs_node),
248 0, SLAB_PANIC, NULL); 248 0, SLAB_PANIC, NULL);
249 kernfs_inode_init();
250} 249}
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 57c40e34f56f..6000d3029b26 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -390,12 +390,6 @@ clear_fields:
390 ip->ip_conn = NULL; 390 ip->ip_conn = NULL;
391} 391}
392 392
393static struct backing_dev_info dlmfs_backing_dev_info = {
394 .name = "ocfs2-dlmfs",
395 .ra_pages = 0, /* No readahead */
396 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
397};
398
399static struct inode *dlmfs_get_root_inode(struct super_block *sb) 393static struct inode *dlmfs_get_root_inode(struct super_block *sb)
400{ 394{
401 struct inode *inode = new_inode(sb); 395 struct inode *inode = new_inode(sb);
@@ -404,7 +398,7 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
404 if (inode) { 398 if (inode) {
405 inode->i_ino = get_next_ino(); 399 inode->i_ino = get_next_ino();
406 inode_init_owner(inode, NULL, mode); 400 inode_init_owner(inode, NULL, mode);
407 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 401 inode->i_mapping->backing_dev_info = &noop_backing_dev_info;
408 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 402 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
409 inc_nlink(inode); 403 inc_nlink(inode);
410 404
@@ -428,7 +422,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
428 422
429 inode->i_ino = get_next_ino(); 423 inode->i_ino = get_next_ino();
430 inode_init_owner(inode, parent, mode); 424 inode_init_owner(inode, parent, mode);
431 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 425 inode->i_mapping->backing_dev_info = &noop_backing_dev_info;
432 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 426 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
433 427
434 ip = DLMFS_I(inode); 428 ip = DLMFS_I(inode);
@@ -643,10 +637,6 @@ static int __init init_dlmfs_fs(void)
643 int status; 637 int status;
644 int cleanup_inode = 0, cleanup_worker = 0; 638 int cleanup_inode = 0, cleanup_worker = 0;
645 639
646 status = bdi_init(&dlmfs_backing_dev_info);
647 if (status)
648 return status;
649
650 dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache", 640 dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache",
651 sizeof(struct dlmfs_inode_private), 641 sizeof(struct dlmfs_inode_private),
652 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| 642 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
@@ -673,7 +663,6 @@ bail:
673 kmem_cache_destroy(dlmfs_inode_cache); 663 kmem_cache_destroy(dlmfs_inode_cache);
674 if (cleanup_worker) 664 if (cleanup_worker)
675 destroy_workqueue(user_dlm_worker); 665 destroy_workqueue(user_dlm_worker);
676 bdi_destroy(&dlmfs_backing_dev_info);
677 } else 666 } else
678 printk("OCFS2 User DLM kernel interface loaded\n"); 667 printk("OCFS2 User DLM kernel interface loaded\n");
679 return status; 668 return status;
@@ -693,7 +682,6 @@ static void __exit exit_dlmfs_fs(void)
693 rcu_barrier(); 682 rcu_barrier();
694 kmem_cache_destroy(dlmfs_inode_cache); 683 kmem_cache_destroy(dlmfs_inode_cache);
695 684
696 bdi_destroy(&dlmfs_backing_dev_info);
697} 685}
698 686
699MODULE_AUTHOR("Oracle"); 687MODULE_AUTHOR("Oracle");