Commit a15b2225 authored by Ksenija Stanojevic's avatar Ksenija Stanojevic Committed by Greg Kroah-Hartman

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: default avatarKsenija Stanojevic <ksenija.stanojevic@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8d816fb6
...@@ -626,16 +626,6 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, ...@@ -626,16 +626,6 @@ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
int lprocfs_single_release(struct inode *, struct file *); int lprocfs_single_release(struct inode *, struct file *);
int lprocfs_seq_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) \ #define LPROCFS_CLIMP_EXIT(obd) \
up_read(&(obd)->u.cli.cl_sem) up_read(&(obd)->u.cli.cl_sem)
......
...@@ -251,6 +251,16 @@ static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) ...@@ -251,6 +251,16 @@ static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
0); 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 inode;
struct lu_attr; struct lu_attr;
struct obdo; struct obdo;
......
...@@ -440,8 +440,12 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) ...@@ -440,8 +440,12 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
struct obd_import *imp; struct obd_import *imp;
struct obd_connect_data *ocd; struct obd_connect_data *ocd;
struct config_llog_data *cld; 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; imp = obd->u.cli.cl_import;
ocd = &imp->imp_connect_data; ocd = &imp->imp_connect_data;
......
...@@ -489,9 +489,13 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data) ...@@ -489,9 +489,13 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
struct obd_device *obd = data; struct obd_device *obd = data;
struct obd_import *imp; struct obd_import *imp;
char *imp_state_name = NULL; char *imp_state_name = NULL;
int rc;
LASSERT(obd != NULL); LASSERT(obd != NULL);
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
imp = obd->u.cli.cl_import; imp = obd->u.cli.cl_import;
imp_state_name = ptlrpc_import_state_name(imp->imp_state); imp_state_name = ptlrpc_import_state_name(imp->imp_state);
seq_printf(m, "%s\t%s%s\n", seq_printf(m, "%s\t%s%s\n",
...@@ -508,10 +512,14 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data) ...@@ -508,10 +512,14 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
{ {
struct obd_device *obd = data; struct obd_device *obd = data;
struct ptlrpc_connection *conn; struct ptlrpc_connection *conn;
int rc;
LASSERT(obd != NULL); LASSERT(obd != NULL);
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
conn = obd->u.cli.cl_import->imp_connection; conn = obd->u.cli.cl_import->imp_connection;
if (conn && obd->u.cli.cl_import) if (conn && obd->u.cli.cl_import)
seq_printf(m, "%s\n", conn->c_remote_uuid.uuid); seq_printf(m, "%s\n", conn->c_remote_uuid.uuid);
...@@ -619,9 +627,13 @@ int lprocfs_rd_import(struct seq_file *m, void *data) ...@@ -619,9 +627,13 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
int j; int j;
int k; int k;
int rw = 0; int rw = 0;
int rc;
LASSERT(obd != NULL); LASSERT(obd != NULL);
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
imp = obd->u.cli.cl_import; imp = obd->u.cli.cl_import;
seq_printf(m, seq_printf(m,
...@@ -762,10 +774,13 @@ int lprocfs_rd_state(struct seq_file *m, void *data) ...@@ -762,10 +774,13 @@ int lprocfs_rd_state(struct seq_file *m, void *data)
{ {
struct obd_device *obd = data; struct obd_device *obd = data;
struct obd_import *imp; struct obd_import *imp;
int j, k; int j, k, rc;
LASSERT(obd != NULL); LASSERT(obd != NULL);
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
imp = obd->u.cli.cl_import; imp = obd->u.cli.cl_import;
seq_printf(m, "current_state: %s\n", seq_printf(m, "current_state: %s\n",
...@@ -805,10 +820,13 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) ...@@ -805,10 +820,13 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data)
unsigned int cur, worst; unsigned int cur, worst;
time64_t now, worstt; time64_t now, worstt;
struct dhms ts; struct dhms ts;
int i; int i, rc;
LASSERT(obd != NULL); LASSERT(obd != NULL);
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
imp = obd->u.cli.cl_import; imp = obd->u.cli.cl_import;
now = ktime_get_real_seconds(); now = ktime_get_real_seconds();
...@@ -848,8 +866,12 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data) ...@@ -848,8 +866,12 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
{ {
struct obd_device *obd = data; struct obd_device *obd = data;
__u64 flags; __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; flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags;
seq_printf(m, "flags=%#llx\n", flags); seq_printf(m, "flags=%#llx\n", flags);
obd_connect_seq_flags2str(m, flags, "\n"); obd_connect_seq_flags2str(m, flags, "\n");
......
...@@ -1192,7 +1192,10 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer, ...@@ -1192,7 +1192,10 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer,
struct ptlrpc_request *req; struct ptlrpc_request *req;
int rc; int rc;
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
req = ptlrpc_prep_ping(obd->u.cli.cl_import); req = ptlrpc_prep_ping(obd->u.cli.cl_import);
LPROCFS_CLIMP_EXIT(obd); LPROCFS_CLIMP_EXIT(obd);
if (req == NULL) if (req == NULL)
...@@ -1281,8 +1284,12 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n) ...@@ -1281,8 +1284,12 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
{ {
struct obd_device *obd = m->private; struct obd_device *obd = m->private;
struct obd_import *imp = obd->u.cli.cl_import; 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); seq_printf(m, "%d\n", !imp->imp_no_pinger_recover);
LPROCFS_CLIMP_EXIT(obd); LPROCFS_CLIMP_EXIT(obd);
...@@ -1305,7 +1312,10 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer, ...@@ -1305,7 +1312,10 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
if (val != 0 && val != 1) if (val != 0 && val != 1)
return -ERANGE; return -ERANGE;
LPROCFS_CLIMP_CHECK(obd); rc = lprocfs_climp_check(obd);
if (rc)
return rc;
spin_lock(&imp->imp_lock); spin_lock(&imp->imp_lock);
imp->imp_no_pinger_recover = !val; imp->imp_no_pinger_recover = !val;
spin_unlock(&imp->imp_lock); spin_unlock(&imp->imp_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment