* [PATCH 1/3] Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check
2015-10-21 21:18 [PATCH 0/3] Staging: lustre: Replace macros with static inline functions Ksenija Stanojevic
@ 2015-10-21 21:19 ` Ksenija Stanojevic
2015-10-25 1:50 ` [Outreachy kernel] " Greg KH
2015-10-21 21:20 ` [PATCH 2/3] Staging: lustre: Replace LPROCFS_CLIMP_EXIT with lprocfs_climp_exit Ksenija Stanojevic
2015-10-21 21:21 ` [PATCH 3/3] Staging: lustre: Remove unused macros Ksenija Stanojevic
2 siblings, 1 reply; 7+ messages in thread
From: Ksenija Stanojevic @ 2015-10-21 21:19 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Ksenija Stanojevic
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.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
---
drivers/staging/lustre/lustre/include/obd_class.h | 11 +++++++
drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +++-
.../lustre/lustre/obdclass/lprocfs_status.c | 38 +++++++++++++++++-----
.../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 16 +++++++--
4 files changed, 59 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index bf2bde5..56c2096 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -251,6 +251,17 @@ static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
0);
}
+static inline int lprocfs_climp_check(struct obd_device *obd)
+{
+ typecheck(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 7315733..b81efcd 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 3228fee..4494096 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);
@@ -618,9 +626,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,
@@ -759,10 +771,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",
@@ -802,10 +817,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();
@@ -845,8 +863,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 415817c..33184c7 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1189,7 +1189,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)
@@ -1278,8 +1281,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);
@@ -1302,7 +1309,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);
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [Outreachy kernel] [PATCH 1/3] Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check
2015-10-21 21:19 ` [PATCH 1/3] Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check Ksenija Stanojevic
@ 2015-10-25 1:50 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2015-10-25 1:50 UTC (permalink / raw)
To: Ksenija Stanojevic; +Cc: outreachy-kernel
On Wed, Oct 21, 2015 at 11:19:41PM +0200, Ksenija Stanojevic wrote:
> 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.
>
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> ---
> drivers/staging/lustre/lustre/include/obd_class.h | 11 +++++++
> drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 +++-
> .../lustre/lustre/obdclass/lprocfs_status.c | 38 +++++++++++++++++-----
> .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 16 +++++++--
> 4 files changed, 59 insertions(+), 12 deletions(-)
Why haven't you deleted the macro as well? It's hard to validate this
patch is correct without seeing the macro removed.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] Staging: lustre: Replace LPROCFS_CLIMP_EXIT with lprocfs_climp_exit
2015-10-21 21:18 [PATCH 0/3] Staging: lustre: Replace macros with static inline functions Ksenija Stanojevic
2015-10-21 21:19 ` [PATCH 1/3] Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check Ksenija Stanojevic
@ 2015-10-21 21:20 ` Ksenija Stanojevic
2015-10-25 1:51 ` [Outreachy kernel] " Greg KH
2015-10-21 21:21 ` [PATCH 3/3] Staging: lustre: Remove unused macros Ksenija Stanojevic
2 siblings, 1 reply; 7+ messages in thread
From: Ksenija Stanojevic @ 2015-10-21 21:20 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Ksenija Stanojevic
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.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
---
drivers/staging/lustre/lustre/include/obd_class.h | 5 +++++
drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 12 ++++++------
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 6 +++---
4 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 56c2096..ad15a10 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -262,6 +262,11 @@ static inline int lprocfs_climp_check(struct obd_device *obd)
return 0;
}
+static inline void lprocfs_climp_exit(struct obd_device *obd)
+{
+ up_read(&(obd)->u.cli.cl_sem);
+}
+
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 b81efcd..82faabc 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -463,7 +463,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
}
spin_unlock(&config_list_lock);
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 4494096..a096fac 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -502,7 +502,7 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
obd2cli_tgt(obd), imp_state_name,
imp->imp_deactive ? "\tDEACTIVATED" : "");
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
@@ -526,7 +526,7 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
else
seq_puts(m, "<none>\n");
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
@@ -762,7 +762,7 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
}
out_climp:
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
EXPORT_SYMBOL(lprocfs_rd_import);
@@ -793,7 +793,7 @@ int lprocfs_rd_state(struct seq_file *m, void *data)
ptlrpc_import_state_name(ish->ish_state));
}
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
EXPORT_SYMBOL(lprocfs_rd_state);
@@ -854,7 +854,7 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data)
lprocfs_at_hist_helper(m, &imp->imp_at.iat_service_estimate[i]);
}
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
EXPORT_SYMBOL(lprocfs_rd_timeouts);
@@ -873,7 +873,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
seq_printf(m, "flags=%#llx\n", flags);
obd_connect_seq_flags2str(m, flags, "\n");
seq_printf(m, "\n");
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
EXPORT_SYMBOL(lprocfs_rd_connect_flags);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 33184c7..b431c3b 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -1194,7 +1194,7 @@ int lprocfs_wr_ping(struct file *file, const char __user *buffer,
return rc;
req = ptlrpc_prep_ping(obd->u.cli.cl_import);
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
if (req == NULL)
return -ENOMEM;
@@ -1288,7 +1288,7 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
return rc;
seq_printf(m, "%d\n", !imp->imp_no_pinger_recover);
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return 0;
}
@@ -1316,7 +1316,7 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
spin_lock(&imp->imp_lock);
imp->imp_no_pinger_recover = !val;
spin_unlock(&imp->imp_lock);
- LPROCFS_CLIMP_EXIT(obd);
+ lprocfs_climp_exit(obd);
return count;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [Outreachy kernel] [PATCH 2/3] Staging: lustre: Replace LPROCFS_CLIMP_EXIT with lprocfs_climp_exit
2015-10-21 21:20 ` [PATCH 2/3] Staging: lustre: Replace LPROCFS_CLIMP_EXIT with lprocfs_climp_exit Ksenija Stanojevic
@ 2015-10-25 1:51 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2015-10-25 1:51 UTC (permalink / raw)
To: Ksenija Stanojevic; +Cc: outreachy-kernel
On Wed, Oct 21, 2015 at 11:20:34PM +0200, Ksenija Stanojevic wrote:
> 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.
>
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> ---
> drivers/staging/lustre/lustre/include/obd_class.h | 5 +++++
> drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
> drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 12 ++++++------
> drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 6 +++---
> 4 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
> index 56c2096..ad15a10 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -262,6 +262,11 @@ static inline int lprocfs_climp_check(struct obd_device *obd)
> return 0;
> }
>
> +static inline void lprocfs_climp_exit(struct obd_device *obd)
> +{
> + up_read(&(obd)->u.cli.cl_sem);
> +}
Why not just use up_read() everywhere instead? You'll just be removing
this wrapper function in a later patch anyway :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] Staging: lustre: Remove unused macros
2015-10-21 21:18 [PATCH 0/3] Staging: lustre: Replace macros with static inline functions Ksenija Stanojevic
2015-10-21 21:19 ` [PATCH 1/3] Staging: lustre: Replace LPROCFS_CLIMP_CHECK with lprocfs_climp_check Ksenija Stanojevic
2015-10-21 21:20 ` [PATCH 2/3] Staging: lustre: Replace LPROCFS_CLIMP_EXIT with lprocfs_climp_exit Ksenija Stanojevic
@ 2015-10-21 21:21 ` Ksenija Stanojevic
2015-10-25 1:51 ` [Outreachy kernel] " Greg KH
2 siblings, 1 reply; 7+ messages in thread
From: Ksenija Stanojevic @ 2015-10-21 21:21 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Ksenija Stanojevic
Macros LPROCFS_CLIMP_CHECK and LPROCFS_CLIMP_EXIT are not used anymore,
therefore remove them along with the comment.
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
---
drivers/staging/lustre/lustre/include/lprocfs_status.h | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 6e41129..532d195 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -626,19 +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)
-
/* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
proc entries; otherwise, you will define name##_seq_write function also for
a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [Outreachy kernel] [PATCH 3/3] Staging: lustre: Remove unused macros
2015-10-21 21:21 ` [PATCH 3/3] Staging: lustre: Remove unused macros Ksenija Stanojevic
@ 2015-10-25 1:51 ` Greg KH
0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2015-10-25 1:51 UTC (permalink / raw)
To: Ksenija Stanojevic; +Cc: outreachy-kernel
On Wed, Oct 21, 2015 at 11:21:53PM +0200, Ksenija Stanojevic wrote:
> Macros LPROCFS_CLIMP_CHECK and LPROCFS_CLIMP_EXIT are not used anymore,
> therefore remove them along with the comment.
>
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> ---
> drivers/staging/lustre/lustre/include/lprocfs_status.h | 13 -------------
> 1 file changed, 13 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> index 6e41129..532d195 100644
> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
> @@ -626,19 +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); \
Note, when you turn this into an inline function, you don't need the
typecheck() call anymore, right?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread