Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check
authorKsenija Stanojevic <ksenija.stanojevic@gmail.com>
Mon, 26 Oct 2015 15:05:57 +0000 (08:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Oct 2015 05:37:09 +0000 (14:37 +0900)
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>
drivers/staging/lustre/lustre/include/lprocfs_status.h
drivers/staging/lustre/lustre/include/obd_class.h
drivers/staging/lustre/lustre/mgc/mgc_request.c
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c

index 6e4112986664f45365474f074257b76d9538b1cf..089e5a38562cc0c7c08904c60344ad2f0c0de753 100644 (file)
@@ -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)
 
index ceb3137f577c533dfc2274210de3563a700256bf..fd5f3731db9264e54a2cc7b574929e21cda1954b 100644 (file)
@@ -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;
index 7315733bc5b0392a423ca35b473f8a0bd750e236..b81efcd997aee821093e4b907e5c5ecacc7496cd 100644 (file)
@@ -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;
 
index 047ced5c52304203ab47f16e318b8aaad7ded269..333ac7d269b7ed3ae5667a0c8eccc5bc4894bba4 100644 (file)
@@ -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");
index 35044634c9db09f549c8d032d49863447634ecb4..afab0dee7a5ce0603bb26b1636c0dbb58b3aae66 100644 (file)
@@ -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);