mirror of https://gitee.com/openkylin/linux.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 <ksenija.stanojevic@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8d816fb6cd
commit
a15b2225dd
|
@ -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)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue