From: adilger Date: Mon, 6 Jan 2003 09:12:32 +0000 (+0000) Subject: - Fix module use counts (bug 581, 22). This makes it impossible to unload X-Git-Tag: v1_7_0_51~2^13~83 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=674a375c0c431ffb9d9d4f752f180d763a70ec78;p=fs%2Flustre-release.git - Fix module use counts (bug 581, 22). This makes it impossible to unload a module while it is in use, and also removes a bunch of code (125 lines). - Update 2.5 ll_clear_inode() to match 2.4 code (cancel locks). Currently commented out, because I'm not sure why it is different (on purpose or just omission?). - Add types to obd_{un,}pack_ioo(). --- diff --git a/lustre/cobd/cache_obd.c b/lustre/cobd/cache_obd.c index 721b01d..ac921d8 100644 --- a/lustre/cobd/cache_obd.c +++ b/lustre/cobd/cache_obd.c @@ -60,9 +60,8 @@ cobd_setup (struct obd_device *dev, obd_count len, void *buf) rc = obd_connect (&cobd->cobd_cache, cache, NULL, NULL, NULL); if (rc != 0) goto fail_0; - - MOD_INC_USE_COUNT; - return (0); + + return (0); fail_0: obd_disconnect (&cobd->cobd_target); @@ -85,17 +84,16 @@ cobd_cleanup (struct obd_device *dev) rc = obd_disconnect (&cobd->cobd_target); if (rc != 0) CERROR ("error %d disconnecting target\n", rc); - - MOD_DEC_USE_COUNT; - return (0); + + return (0); } static int cobd_connect (struct lustre_handle *conn, struct obd_device *obd, - obd_uuid_t cluuid, struct recovd_obd *recovd, - ptlrpc_recovery_cb_t recover) + obd_uuid_t cluuid, struct recovd_obd *recovd, + ptlrpc_recovery_cb_t recover) { - int rc = class_connect (conn, obd, cluuid); + int rc = class_connect (conn, obd, cluuid); CERROR ("rc %d\n", rc); return (rc); @@ -281,17 +279,18 @@ cobd_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, } static struct obd_ops cobd_ops = { - o_attach: cobd_attach, - o_detach: cobd_detach, + o_owner: THIS_MODULE, + o_attach: cobd_attach, + o_detach: cobd_detach, - o_setup: cobd_setup, - o_cleanup: cobd_cleanup, + o_setup: cobd_setup, + o_cleanup: cobd_cleanup, - o_connect: cobd_connect, - o_disconnect: cobd_disconnect, + o_connect: cobd_connect, + o_disconnect: cobd_disconnect, - o_get_info: cobd_get_info, - o_statfs: cobd_statfs, + o_get_info: cobd_get_info, + o_statfs: cobd_statfs, o_getattr: cobd_getattr, o_open: cobd_open, @@ -299,7 +298,7 @@ static struct obd_ops cobd_ops = { o_preprw: cobd_preprw, o_commitrw: cobd_commitrw, o_brw: cobd_brw, - o_iocontrol: cobd_iocontrol, + o_iocontrol: cobd_iocontrol, }; static int __init diff --git a/lustre/cobd/lproc_cache.c b/lustre/cobd/lproc_cache.c index b20eff4..5adcaf8 100644 --- a/lustre/cobd/lproc_cache.c +++ b/lustre/cobd/lproc_cache.c @@ -28,18 +28,16 @@ * Common STATUS namespace */ -static int -rd_uuid (char *page, char **start, off_t off, int count, - int *eof, void *data) +static int rd_uuid (char *page, char **start, off_t off, int count, + int *eof, void *data) { struct obd_device* dev = (struct obd_device*)data; - + return (snprintf(page, count, "%s\n", dev->obd_uuid)); } -static int -rd_target (char *page, char **start, off_t off, int count, - int *eof, void *data) +static int rd_target (char *page, char **start, off_t off, int count, + int *eof, void *data) { struct obd_device *dev = (struct obd_device*)data; struct cache_obd *cobd = &dev->u.cobd; @@ -57,16 +55,15 @@ rd_target (char *page, char **start, off_t off, int count, return (rc); } -static int -rd_cache (char *page, char **start, off_t off, int count, - int *eof, void *data) +static int rd_cache(char *page, char **start, off_t off, int count, + int *eof, void *data) { struct obd_device *dev = (struct obd_device*)data; struct cache_obd *cobd = &dev->u.cobd; struct lustre_handle *conn = &cobd->cobd_cache; struct obd_export *exp; int rc; - + if ((dev->obd_flags & OBD_SET_UP) == 0) rc = snprintf (page, count, "not set up\n"); else { @@ -81,13 +78,11 @@ struct lprocfs_vars status_var_nm_1[] = { {"status/uuid", rd_uuid, 0, 0}, {"status/target_uuid", rd_target, 0, 0}, {"status/cache_uuid", rd_cache, 0, 0}, - {0} }; -int -rd_numrefs (char* page, char **start, off_t off, int count, - int *eof, void *data) +int rd_numrefs(char *page, char **start, off_t off, int count, + int *eof, void *data) { struct obd_type* class = (struct obd_type*)data; diff --git a/lustre/ptlbd/client.c b/lustre/ptlbd/client.c index 3aad2b8..d57e001 100644 --- a/lustre/ptlbd/client.c +++ b/lustre/ptlbd/client.c @@ -119,11 +119,12 @@ static int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd, #endif static struct obd_ops ptlbd_cl_obd_ops = { - o_setup: ptlbd_cl_setup, - o_cleanup: ptlbd_cl_cleanup, + o_owner: THIS_MODULE, + o_setup: ptlbd_cl_setup, + o_cleanup: ptlbd_cl_cleanup, #if 0 - o_connect: ptlbd_cl_connect, - o_disconnect: class_disconnect + o_connect: ptlbd_cl_connect, + o_disconnect: class_disconnect #endif }; diff --git a/lustre/ptlbd/server.c b/lustre/ptlbd/server.c index 5de0732..422f0e1 100644 --- a/lustre/ptlbd/server.c +++ b/lustre/ptlbd/server.c @@ -62,16 +62,15 @@ static int ptlbd_sv_setup(struct obd_device *obddev, obd_count len, void *buf) int rc; ENTRY; - MOD_INC_USE_COUNT; #if 0 if (data->ioc_inllen1 < 1) { CERROR("requires a PTLBD server UUID\n"); - GOTO(out_dec, rc = -EINVAL); + RETURN(rc = -EINVAL); } if (data->ioc_inllen1 > 37) { CERROR("PTLBD server UUID must be less than 38 characters\n"); - GOTO(out_dec, rc = -EINVAL); + RETURN(rc = -EINVAL); } memcpy(server_uuid, data->ioc_inlbuf1, MIN(data->ioc_inllen1, @@ -86,7 +85,7 @@ static int ptlbd_sv_setup(struct obd_device *obddev, obd_count len, void *buf) if (!ptlbd->ptlbd_service) { CERROR("failed to start service\n"); - GOTO(out_dec, rc = -ENOMEM); + RETURN(rc = -ENOMEM); } rc = ptlrpc_start_thread(obddev, ptlbd->ptlbd_service, "ptldb"); @@ -104,8 +103,6 @@ static int ptlbd_sv_setup(struct obd_device *obddev, obd_count len, void *buf) ptlrpc_stop_all_threads(ptlbd->ptlbd_service); ptlrpc_unregister_service(ptlbd->ptlbd_service); - out_dec: - MOD_DEC_USE_COUNT; return rc; } @@ -120,7 +117,6 @@ static int ptlbd_sv_cleanup(struct obd_device *obddev) ptlrpc_unregister_service(ptlbd->ptlbd_service); ptlbd_sv_already_setup = 0; - MOD_DEC_USE_COUNT; RETURN(0); } @@ -134,12 +130,13 @@ static int ptlbd_sv_connect(struct lustre_handle *conn, struct obd_device *src, #endif static struct obd_ops ptlbd_sv_obd_ops = { -/* o_iocontrol: ptlbd_iocontrol,*/ - o_setup: ptlbd_sv_setup, - o_cleanup: ptlbd_sv_cleanup, + o_owner: THIS_MODULE, +/* o_iocontrol: ptlbd_iocontrol,*/ + o_setup: ptlbd_sv_setup, + o_cleanup: ptlbd_sv_cleanup, #if 0 - o_connect: ptlbd_sv_connect, - o_disconnect: class_disconnect + o_connect: ptlbd_sv_connect, + o_disconnect: class_disconnect #endif };