From: Ksenija Stanojevic Date: Mon, 26 Oct 2015 15:05:57 +0000 (-0700) Subject: Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=a15b2225dd504d6fb5eb4b5a1b29b71cdc9b1f06;p=openwrt%2Fstaging%2Fblogic.git Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check Static inline functions are preferred over macros. The function is placed in obd_class.h instead lprocfs_status.h because obd_class.h includes header obd.h which contains definition of struct obd_device and in that way avoids build error: Dereferencing pointer to incomplete type. Also remove macro LPROCFS_CLIMP_CHECK since it's no longer used. Signed-off-by: Ksenija Stanojevic Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 6e4112986664..089e5a38562c 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -626,16 +626,6 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, int lprocfs_single_release(struct inode *, struct file *); int lprocfs_seq_release(struct inode *, struct file *); -/* You must use these macros when you want to refer to - * the import in a client obd_device for a lprocfs entry */ -#define LPROCFS_CLIMP_CHECK(obd) do { \ - typecheck(struct obd_device *, obd); \ - down_read(&(obd)->u.cli.cl_sem); \ - if ((obd)->u.cli.cl_import == NULL) { \ - up_read(&(obd)->u.cli.cl_sem); \ - return -ENODEV; \ - } \ -} while (0) #define LPROCFS_CLIMP_EXIT(obd) \ up_read(&(obd)->u.cli.cl_sem) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index ceb3137f577c..fd5f3731db92 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -251,6 +251,16 @@ static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) 0); } +static inline int lprocfs_climp_check(struct obd_device *obd) +{ + down_read(&(obd)->u.cli.cl_sem); + if (!(obd)->u.cli.cl_import) { + up_read(&(obd)->u.cli.cl_sem); + return -ENODEV; + } + return 0; +} + struct inode; struct lu_attr; struct obdo; diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 7315733bc5b0..b81efcd997ae 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -440,8 +440,12 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) struct obd_import *imp; struct obd_connect_data *ocd; struct config_llog_data *cld; + int rc; + + rc = lprocfs_climp_check(obd); + if (rc) + return rc; - LPROCFS_CLIMP_CHECK(obd); imp = obd->u.cli.cl_import; ocd = &imp->imp_connect_data; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 047ced5c5230..333ac7d269b7 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -489,9 +489,13 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data) struct obd_device *obd = data; struct obd_import *imp; char *imp_state_name = NULL; + int rc; LASSERT(obd != NULL); - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + imp = obd->u.cli.cl_import; imp_state_name = ptlrpc_import_state_name(imp->imp_state); seq_printf(m, "%s\t%s%s\n", @@ -508,10 +512,14 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data) { struct obd_device *obd = data; struct ptlrpc_connection *conn; + int rc; LASSERT(obd != NULL); - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + conn = obd->u.cli.cl_import->imp_connection; if (conn && obd->u.cli.cl_import) seq_printf(m, "%s\n", conn->c_remote_uuid.uuid); @@ -619,9 +627,13 @@ int lprocfs_rd_import(struct seq_file *m, void *data) int j; int k; int rw = 0; + int rc; LASSERT(obd != NULL); - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + imp = obd->u.cli.cl_import; seq_printf(m, @@ -762,10 +774,13 @@ int lprocfs_rd_state(struct seq_file *m, void *data) { struct obd_device *obd = data; struct obd_import *imp; - int j, k; + int j, k, rc; LASSERT(obd != NULL); - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + imp = obd->u.cli.cl_import; seq_printf(m, "current_state: %s\n", @@ -805,10 +820,13 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) unsigned int cur, worst; time64_t now, worstt; struct dhms ts; - int i; + int i, rc; LASSERT(obd != NULL); - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + imp = obd->u.cli.cl_import; now = ktime_get_real_seconds(); @@ -848,8 +866,12 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) { struct obd_device *obd = data; __u64 flags; + int rc; + + rc = lprocfs_climp_check(obd); + if (rc) + return rc; - LPROCFS_CLIMP_CHECK(obd); flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags; seq_printf(m, "flags=%#llx\n", flags); obd_connect_seq_flags2str(m, flags, "\n"); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 35044634c9db..afab0dee7a5c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1192,7 +1192,10 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, struct ptlrpc_request *req; int rc; - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + req = ptlrpc_prep_ping(obd->u.cli.cl_import); LPROCFS_CLIMP_EXIT(obd); if (req == NULL) @@ -1281,8 +1284,12 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) { struct obd_device *obd = m->private; struct obd_import *imp = obd->u.cli.cl_import; + int rc; + + rc = lprocfs_climp_check(obd); + if (rc) + return rc; - LPROCFS_CLIMP_CHECK(obd); seq_printf(m, "%d\n", !imp->imp_no_pinger_recover); LPROCFS_CLIMP_EXIT(obd); @@ -1305,7 +1312,10 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, if (val != 0 && val != 1) return -ERANGE; - LPROCFS_CLIMP_CHECK(obd); + rc = lprocfs_climp_check(obd); + if (rc) + return rc; + spin_lock(&imp->imp_lock); imp->imp_no_pinger_recover = !val; spin_unlock(&imp->imp_lock);