1ec26815aSDavid Howells /* AFS client file system 21da177e4SLinus Torvalds * 31da177e4SLinus Torvalds * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. 41da177e4SLinus Torvalds * Written by David Howells (dhowells@redhat.com) 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or 71da177e4SLinus Torvalds * modify it under the terms of the GNU General Public License 81da177e4SLinus Torvalds * as published by the Free Software Foundation; either version 91da177e4SLinus Torvalds * 2 of the License, or (at your option) any later version. 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #include <linux/module.h> 131da177e4SLinus Torvalds #include <linux/moduleparam.h> 141da177e4SLinus Torvalds #include <linux/init.h> 151da177e4SLinus Torvalds #include <linux/completion.h> 161da177e4SLinus Torvalds #include "internal.h" 171da177e4SLinus Torvalds 181da177e4SLinus Torvalds MODULE_DESCRIPTION("AFS Client File System"); 191da177e4SLinus Torvalds MODULE_AUTHOR("Red Hat, Inc."); 201da177e4SLinus Torvalds MODULE_LICENSE("GPL"); 211da177e4SLinus Torvalds 22*08e0e7c8SDavid Howells unsigned afs_debug; 23*08e0e7c8SDavid Howells module_param_named(debug, afs_debug, uint, S_IWUSR | S_IRUGO); 24*08e0e7c8SDavid Howells MODULE_PARM_DESC(afs_debug, "AFS debugging mask"); 25*08e0e7c8SDavid Howells 261da177e4SLinus Torvalds static char *rootcell; 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds module_param(rootcell, charp, 0); 291da177e4SLinus Torvalds MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list"); 301da177e4SLinus Torvalds 311da177e4SLinus Torvalds #ifdef AFS_CACHING_SUPPORT 321da177e4SLinus Torvalds static struct cachefs_netfs_operations afs_cache_ops = { 331da177e4SLinus Torvalds .get_page_cookie = afs_cache_get_page_cookie, 341da177e4SLinus Torvalds }; 351da177e4SLinus Torvalds 361da177e4SLinus Torvalds struct cachefs_netfs afs_cache_netfs = { 371da177e4SLinus Torvalds .name = "afs", 381da177e4SLinus Torvalds .version = 0, 391da177e4SLinus Torvalds .ops = &afs_cache_ops, 401da177e4SLinus Torvalds }; 411da177e4SLinus Torvalds #endif 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds /* 441da177e4SLinus Torvalds * initialise the AFS client FS module 451da177e4SLinus Torvalds */ 461da177e4SLinus Torvalds static int __init afs_init(void) 471da177e4SLinus Torvalds { 48*08e0e7c8SDavid Howells int ret; 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 registering.\n"); 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds /* register the /proc stuff */ 531da177e4SLinus Torvalds ret = afs_proc_init(); 541da177e4SLinus Torvalds if (ret < 0) 551da177e4SLinus Torvalds return ret; 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds #ifdef AFS_CACHING_SUPPORT 581da177e4SLinus Torvalds /* we want to be able to cache */ 591da177e4SLinus Torvalds ret = cachefs_register_netfs(&afs_cache_netfs, 601da177e4SLinus Torvalds &afs_cache_cell_index_def); 611da177e4SLinus Torvalds if (ret < 0) 621da177e4SLinus Torvalds goto error_cache; 631da177e4SLinus Torvalds #endif 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds /* initialise the cell DB */ 661da177e4SLinus Torvalds ret = afs_cell_init(rootcell); 671da177e4SLinus Torvalds if (ret < 0) 68ec26815aSDavid Howells goto error_cell_init; 691da177e4SLinus Torvalds 70*08e0e7c8SDavid Howells /* initialise the VL update process */ 71*08e0e7c8SDavid Howells ret = afs_vlocation_update_init(); 721da177e4SLinus Torvalds if (ret < 0) 73*08e0e7c8SDavid Howells goto error_vl_update_init; 741da177e4SLinus Torvalds 75*08e0e7c8SDavid Howells /* initialise the callback update process */ 76*08e0e7c8SDavid Howells ret = afs_callback_update_init(); 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds /* create the RxRPC transport */ 79*08e0e7c8SDavid Howells ret = afs_open_socket(); 801da177e4SLinus Torvalds if (ret < 0) 81*08e0e7c8SDavid Howells goto error_open_socket; 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds /* register the filesystems */ 841da177e4SLinus Torvalds ret = afs_fs_init(); 851da177e4SLinus Torvalds if (ret < 0) 86ec26815aSDavid Howells goto error_fs; 871da177e4SLinus Torvalds 881da177e4SLinus Torvalds return ret; 891da177e4SLinus Torvalds 90ec26815aSDavid Howells error_fs: 91*08e0e7c8SDavid Howells afs_close_socket(); 92*08e0e7c8SDavid Howells error_open_socket: 93*08e0e7c8SDavid Howells error_vl_update_init: 94ec26815aSDavid Howells error_cell_init: 951da177e4SLinus Torvalds #ifdef AFS_CACHING_SUPPORT 961da177e4SLinus Torvalds cachefs_unregister_netfs(&afs_cache_netfs); 97ec26815aSDavid Howells error_cache: 981da177e4SLinus Torvalds #endif 99*08e0e7c8SDavid Howells afs_callback_update_kill(); 100*08e0e7c8SDavid Howells afs_vlocation_purge(); 1011da177e4SLinus Torvalds afs_cell_purge(); 1021da177e4SLinus Torvalds afs_proc_cleanup(); 1031da177e4SLinus Torvalds printk(KERN_ERR "kAFS: failed to register: %d\n", ret); 1041da177e4SLinus Torvalds return ret; 105ec26815aSDavid Howells } 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvalds /* XXX late_initcall is kludgy, but the only alternative seems to create 1081da177e4SLinus Torvalds * a transport upon the first mount, which is worse. Or is it? 1091da177e4SLinus Torvalds */ 1101da177e4SLinus Torvalds late_initcall(afs_init); /* must be called after net/ to create socket */ 111ec26815aSDavid Howells 1121da177e4SLinus Torvalds /* 1131da177e4SLinus Torvalds * clean up on module removal 1141da177e4SLinus Torvalds */ 1151da177e4SLinus Torvalds static void __exit afs_exit(void) 1161da177e4SLinus Torvalds { 1171da177e4SLinus Torvalds printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n"); 1181da177e4SLinus Torvalds 1191da177e4SLinus Torvalds afs_fs_exit(); 120*08e0e7c8SDavid Howells afs_close_socket(); 121*08e0e7c8SDavid Howells afs_purge_servers(); 122*08e0e7c8SDavid Howells afs_callback_update_kill(); 123*08e0e7c8SDavid Howells afs_vlocation_purge(); 124*08e0e7c8SDavid Howells flush_scheduled_work(); 1251da177e4SLinus Torvalds afs_cell_purge(); 1261da177e4SLinus Torvalds #ifdef AFS_CACHING_SUPPORT 1271da177e4SLinus Torvalds cachefs_unregister_netfs(&afs_cache_netfs); 1281da177e4SLinus Torvalds #endif 1291da177e4SLinus Torvalds afs_proc_cleanup(); 130ec26815aSDavid Howells } 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds module_exit(afs_exit); 133