aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2007-10-17 02:25:46 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:45 -0400
commite0bf68ddec4f4f90e5871404be4f1854c17f3120 (patch)
tree36203a3558cbe26d698bed18be69b3822fb5eef2 /fs
parentdc62a30e274d003a4d08fb888f1520add4b21373 (diff)
mm: bdi init hooks
provide BDI constructor/destructor hooks [akpm@linux-foundation.org: compile fix] Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/char_dev.c1
-rw-r--r--fs/configfs/configfs_internal.h2
-rw-r--r--fs/configfs/inode.c8
-rw-r--r--fs/configfs/mount.c9
-rw-r--r--fs/fuse/inode.c9
-rw-r--r--fs/hugetlbfs/inode.c9
-rw-r--r--fs/nfs/client.c6
-rw-r--r--fs/ocfs2/dlm/dlmfs.c9
-rw-r--r--fs/ramfs/inode.c12
-rw-r--r--fs/sysfs/inode.c5
-rw-r--r--fs/sysfs/mount.c4
-rw-r--r--fs/sysfs/sysfs.h1
12 files changed, 72 insertions, 3 deletions
diff --git a/fs/char_dev.c b/fs/char_dev.c
index bbbf07baa145..c3bfa76765c4 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -545,6 +545,7 @@ static struct kobject *base_probe(dev_t dev, int *part, void *data)
545void __init chrdev_init(void) 545void __init chrdev_init(void)
546{ 546{
547 cdev_map = kobj_map_init(base_probe, &chrdevs_lock); 547 cdev_map = kobj_map_init(base_probe, &chrdevs_lock);
548 bdi_init(&directly_mappable_cdev_bdi);
548} 549}
549 550
550 551
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 3b0185fdf9a4..cca98609aa7f 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -56,6 +56,8 @@ extern int configfs_is_root(struct config_item *item);
56 56
57extern struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent *); 57extern struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent *);
58extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 58extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *));
59extern int configfs_inode_init(void);
60extern void configfs_inode_exit(void);
59 61
60extern int configfs_create_file(struct config_item *, const struct configfs_attribute *); 62extern int configfs_create_file(struct config_item *, const struct configfs_attribute *);
61extern int configfs_make_dirent(struct configfs_dirent *, 63extern int configfs_make_dirent(struct configfs_dirent *,
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index dbd257d956c4..4c1ebff778ee 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -256,4 +256,12 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name)
256 mutex_unlock(&dir->d_inode->i_mutex); 256 mutex_unlock(&dir->d_inode->i_mutex);
257} 257}
258 258
259int __init configfs_inode_init(void)
260{
261 return bdi_init(&configfs_backing_dev_info);
262}
259 263
264void __exit configfs_inode_exit(void)
265{
266 bdi_destroy(&configfs_backing_dev_info);
267}
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 871b0cb61839..3bf0278ea843 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -154,8 +154,16 @@ static int __init configfs_init(void)
154 subsystem_unregister(&config_subsys); 154 subsystem_unregister(&config_subsys);
155 kmem_cache_destroy(configfs_dir_cachep); 155 kmem_cache_destroy(configfs_dir_cachep);
156 configfs_dir_cachep = NULL; 156 configfs_dir_cachep = NULL;
157 goto out;
157 } 158 }
158 159
160 err = configfs_inode_init();
161 if (err) {
162 unregister_filesystem(&configfs_fs_type);
163 subsystem_unregister(&config_subsys);
164 kmem_cache_destroy(configfs_dir_cachep);
165 configfs_dir_cachep = NULL;
166 }
159out: 167out:
160 return err; 168 return err;
161} 169}
@@ -166,6 +174,7 @@ static void __exit configfs_exit(void)
166 subsystem_unregister(&config_subsys); 174 subsystem_unregister(&config_subsys);
167 kmem_cache_destroy(configfs_dir_cachep); 175 kmem_cache_destroy(configfs_dir_cachep);
168 configfs_dir_cachep = NULL; 176 configfs_dir_cachep = NULL;
177 configfs_inode_exit();
169} 178}
170 179
171MODULE_AUTHOR("Oracle"); 180MODULE_AUTHOR("Oracle");
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 5448f625ab56..ca30b6ac03f0 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -401,6 +401,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
401static struct fuse_conn *new_conn(void) 401static struct fuse_conn *new_conn(void)
402{ 402{
403 struct fuse_conn *fc; 403 struct fuse_conn *fc;
404 int err;
404 405
405 fc = kzalloc(sizeof(*fc), GFP_KERNEL); 406 fc = kzalloc(sizeof(*fc), GFP_KERNEL);
406 if (fc) { 407 if (fc) {
@@ -416,10 +417,17 @@ static struct fuse_conn *new_conn(void)
416 atomic_set(&fc->num_waiting, 0); 417 atomic_set(&fc->num_waiting, 0);
417 fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; 418 fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
418 fc->bdi.unplug_io_fn = default_unplug_io_fn; 419 fc->bdi.unplug_io_fn = default_unplug_io_fn;
420 err = bdi_init(&fc->bdi);
421 if (err) {
422 kfree(fc);
423 fc = NULL;
424 goto out;
425 }
419 fc->reqctr = 0; 426 fc->reqctr = 0;
420 fc->blocked = 1; 427 fc->blocked = 1;
421 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); 428 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
422 } 429 }
430out:
423 return fc; 431 return fc;
424} 432}
425 433
@@ -429,6 +437,7 @@ void fuse_conn_put(struct fuse_conn *fc)
429 if (fc->destroy_req) 437 if (fc->destroy_req)
430 fuse_request_free(fc->destroy_req); 438 fuse_request_free(fc->destroy_req);
431 mutex_destroy(&fc->inst_mutex); 439 mutex_destroy(&fc->inst_mutex);
440 bdi_destroy(&fc->bdi);
432 kfree(fc); 441 kfree(fc);
433 } 442 }
434} 443}
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 04598e12c489..0d9a2055ddee 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -974,11 +974,15 @@ static int __init init_hugetlbfs_fs(void)
974 int error; 974 int error;
975 struct vfsmount *vfsmount; 975 struct vfsmount *vfsmount;
976 976
977 error = bdi_init(&hugetlbfs_backing_dev_info);
978 if (error)
979 return error;
980
977 hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache", 981 hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache",
978 sizeof(struct hugetlbfs_inode_info), 982 sizeof(struct hugetlbfs_inode_info),
979 0, 0, init_once); 983 0, 0, init_once);
980 if (hugetlbfs_inode_cachep == NULL) 984 if (hugetlbfs_inode_cachep == NULL)
981 return -ENOMEM; 985 goto out2;
982 986
983 error = register_filesystem(&hugetlbfs_fs_type); 987 error = register_filesystem(&hugetlbfs_fs_type);
984 if (error) 988 if (error)
@@ -996,6 +1000,8 @@ static int __init init_hugetlbfs_fs(void)
996 out: 1000 out:
997 if (error) 1001 if (error)
998 kmem_cache_destroy(hugetlbfs_inode_cachep); 1002 kmem_cache_destroy(hugetlbfs_inode_cachep);
1003 out2:
1004 bdi_destroy(&hugetlbfs_backing_dev_info);
999 return error; 1005 return error;
1000} 1006}
1001 1007
@@ -1003,6 +1009,7 @@ static void __exit exit_hugetlbfs_fs(void)
1003{ 1009{
1004 kmem_cache_destroy(hugetlbfs_inode_cachep); 1010 kmem_cache_destroy(hugetlbfs_inode_cachep);
1005 unregister_filesystem(&hugetlbfs_fs_type); 1011 unregister_filesystem(&hugetlbfs_fs_type);
1012 bdi_destroy(&hugetlbfs_backing_dev_info);
1006} 1013}
1007 1014
1008module_init(init_hugetlbfs_fs) 1015module_init(init_hugetlbfs_fs)
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index a532ee12740a..70587f383f10 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -627,6 +627,7 @@ static void nfs_server_set_fsinfo(struct nfs_server *server, struct nfs_fsinfo *
627 if (server->rsize > NFS_MAX_FILE_IO_SIZE) 627 if (server->rsize > NFS_MAX_FILE_IO_SIZE)
628 server->rsize = NFS_MAX_FILE_IO_SIZE; 628 server->rsize = NFS_MAX_FILE_IO_SIZE;
629 server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 629 server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
630
630 server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; 631 server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD;
631 632
632 if (server->wsize > max_rpc_payload) 633 if (server->wsize > max_rpc_payload)
@@ -677,6 +678,10 @@ static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, str
677 goto out_error; 678 goto out_error;
678 679
679 nfs_server_set_fsinfo(server, &fsinfo); 680 nfs_server_set_fsinfo(server, &fsinfo);
681 error = bdi_init(&server->backing_dev_info);
682 if (error)
683 goto out_error;
684
680 685
681 /* Get some general file system info */ 686 /* Get some general file system info */
682 if (server->namelen == 0) { 687 if (server->namelen == 0) {
@@ -756,6 +761,7 @@ void nfs_free_server(struct nfs_server *server)
756 nfs_put_client(server->nfs_client); 761 nfs_put_client(server->nfs_client);
757 762
758 nfs_free_iostats(server->io_stats); 763 nfs_free_iostats(server->io_stats);
764 bdi_destroy(&server->backing_dev_info);
759 kfree(server); 765 kfree(server);
760 nfs_release_automount_timer(); 766 nfs_release_automount_timer();
761 dprintk("<-- nfs_free_server()\n"); 767 dprintk("<-- nfs_free_server()\n");
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 7418dc83de1c..1150412758ac 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -588,13 +588,17 @@ static int __init init_dlmfs_fs(void)
588 588
589 dlmfs_print_version(); 589 dlmfs_print_version();
590 590
591 status = bdi_init(&dlmfs_backing_dev_info);
592 if (status)
593 return status;
594
591 dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache", 595 dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache",
592 sizeof(struct dlmfs_inode_private), 596 sizeof(struct dlmfs_inode_private),
593 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| 597 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
594 SLAB_MEM_SPREAD), 598 SLAB_MEM_SPREAD),
595 dlmfs_init_once); 599 dlmfs_init_once);
596 if (!dlmfs_inode_cache) 600 if (!dlmfs_inode_cache)
597 return -ENOMEM; 601 goto bail;
598 cleanup_inode = 1; 602 cleanup_inode = 1;
599 603
600 user_dlm_worker = create_singlethread_workqueue("user_dlm"); 604 user_dlm_worker = create_singlethread_workqueue("user_dlm");
@@ -611,6 +615,7 @@ bail:
611 kmem_cache_destroy(dlmfs_inode_cache); 615 kmem_cache_destroy(dlmfs_inode_cache);
612 if (cleanup_worker) 616 if (cleanup_worker)
613 destroy_workqueue(user_dlm_worker); 617 destroy_workqueue(user_dlm_worker);
618 bdi_destroy(&dlmfs_backing_dev_info);
614 } else 619 } else
615 printk("OCFS2 User DLM kernel interface loaded\n"); 620 printk("OCFS2 User DLM kernel interface loaded\n");
616 return status; 621 return status;
@@ -624,6 +629,8 @@ static void __exit exit_dlmfs_fs(void)
624 destroy_workqueue(user_dlm_worker); 629 destroy_workqueue(user_dlm_worker);
625 630
626 kmem_cache_destroy(dlmfs_inode_cache); 631 kmem_cache_destroy(dlmfs_inode_cache);
632
633 bdi_destroy(&dlmfs_backing_dev_info);
627} 634}
628 635
629MODULE_AUTHOR("Oracle"); 636MODULE_AUTHOR("Oracle");
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index ef2b46d099ff..8428d5b2711d 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -223,7 +223,17 @@ module_exit(exit_ramfs_fs)
223 223
224int __init init_rootfs(void) 224int __init init_rootfs(void)
225{ 225{
226 return register_filesystem(&rootfs_fs_type); 226 int err;
227
228 err = bdi_init(&ramfs_backing_dev_info);
229 if (err)
230 return err;
231
232 err = register_filesystem(&rootfs_fs_type);
233 if (err)
234 bdi_destroy(&ramfs_backing_dev_info);
235
236 return err;
227} 237}
228 238
229MODULE_LICENSE("GPL"); 239MODULE_LICENSE("GPL");
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index c4ef945d39c8..d9262f74f94e 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -37,6 +37,11 @@ static const struct inode_operations sysfs_inode_operations ={
37 .setattr = sysfs_setattr, 37 .setattr = sysfs_setattr,
38}; 38};
39 39
40int __init sysfs_inode_init(void)
41{
42 return bdi_init(&sysfs_backing_dev_info);
43}
44
40int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) 45int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
41{ 46{
42 struct inode * inode = dentry->d_inode; 47 struct inode * inode = dentry->d_inode;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index c76c540be3c8..74168266cd59 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -92,6 +92,10 @@ int __init sysfs_init(void)
92 if (!sysfs_dir_cachep) 92 if (!sysfs_dir_cachep)
93 goto out; 93 goto out;
94 94
95 err = sysfs_inode_init();
96 if (err)
97 goto out_err;
98
95 err = register_filesystem(&sysfs_fs_type); 99 err = register_filesystem(&sysfs_fs_type);
96 if (!err) { 100 if (!err) {
97 sysfs_mount = kern_mount(&sysfs_fs_type); 101 sysfs_mount = kern_mount(&sysfs_fs_type);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index f0326f281d1c..f8417988f6b0 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -146,6 +146,7 @@ static inline void sysfs_put(struct sysfs_dirent *sd)
146struct inode *sysfs_get_inode(struct sysfs_dirent *sd); 146struct inode *sysfs_get_inode(struct sysfs_dirent *sd);
147int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); 147int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
148int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name); 148int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name);
149int sysfs_inode_init(void);
149 150
150/* 151/*
151 * file.c 152 * file.c