All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
@ 2015-06-02 19:57 Tolga Ceylan
  2015-06-03  6:42 ` Sudip Mukherjee
  0 siblings, 1 reply; 6+ messages in thread
From: Tolga Ceylan @ 2015-06-02 19:57 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Julia Lawall,
	Greg Donald, Joe Perches, Darshana Padmadas, Arjun AK,
	Tolga Ceylan, HPDD-discuss, devel, linux-kernel

In llog_cat_new_log(), sparse emits a context imbalance (unexpected lock)
warning due its inability to detect the noreturn attribute in
lbug_with_lock() function inside LBUG macro. Adding a never reached
return statement suppresses this warning.

Signed-off-by: Tolga Ceylan <tolga.ceylan@gmail.com>
---
 drivers/staging/lustre/lustre/obdclass/llog_cat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
index c8f6ab0..259947c 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
@@ -108,6 +108,7 @@ static int llog_cat_new_log(const struct lu_env *env,
 		       index);
 		spin_unlock(&loghandle->lgh_hdr_lock);
 		LBUG(); /* should never happen */
+		return -EINVAL;
 	}
 	spin_unlock(&loghandle->lgh_hdr_lock);
 
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
  2015-06-02 19:57 [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning Tolga Ceylan
@ 2015-06-03  6:42 ` Sudip Mukherjee
  2015-06-03 15:47   ` Tolga Ceylan
  0 siblings, 1 reply; 6+ messages in thread
From: Sudip Mukherjee @ 2015-06-03  6:42 UTC (permalink / raw)
  To: Tolga Ceylan
  Cc: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Julia Lawall,
	Greg Donald, Joe Perches, Darshana Padmadas, Arjun AK,
	HPDD-discuss, devel, linux-kernel

On Tue, Jun 02, 2015 at 12:57:20PM -0700, Tolga Ceylan wrote:
> In llog_cat_new_log(), sparse emits a context imbalance (unexpected lock)
> warning due its inability to detect the noreturn attribute in
> lbug_with_lock() function inside LBUG macro. Adding a never reached
> return statement suppresses this warning.
but adding a statement which never executes, is that the correct solution?
what about :

diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
index c8f6ab0..1cb3495 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
@@ -103,13 +103,12 @@ static int llog_cat_new_log(const struct lu_env *env,
 
 	spin_lock(&loghandle->lgh_hdr_lock);
 	llh->llh_count++;
-	if (ext2_set_bit(index, llh->llh_bitmap)) {
-		CERROR("argh, index %u already set in log bitmap?\n",
-		       index);
-		spin_unlock(&loghandle->lgh_hdr_lock);
+	rc = ext2_set_bit(index, llh->llh_bitmap);
+	spin_unlock(&loghandle->lgh_hdr_lock);
+	if (rc) {
+		CERROR("argh, index %u already set in log bitmap?\n", index);
 		LBUG(); /* should never happen */
 	}
-	spin_unlock(&loghandle->lgh_hdr_lock);
 
 	cathandle->lgh_last_idx = index;
 	llh->llh_tail.lrt_index = index;


regards
sudip	


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
  2015-06-03  6:42 ` Sudip Mukherjee
@ 2015-06-03 15:47   ` Tolga Ceylan
  2015-06-03 16:36     ` Sudip Mukherjee
  0 siblings, 1 reply; 6+ messages in thread
From: Tolga Ceylan @ 2015-06-03 15:47 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Julia Lawall,
	Greg Donald, Joe Perches, Darshana Padmadas, Arjun AK,
	HPDD-discuss, devel, linux-kernel

The second patch is better (it also keeps the lock locked shorter.) Do
I need to resend?

On Tue, Jun 2, 2015 at 11:42 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> On Tue, Jun 02, 2015 at 12:57:20PM -0700, Tolga Ceylan wrote:
>> In llog_cat_new_log(), sparse emits a context imbalance (unexpected lock)
>> warning due its inability to detect the noreturn attribute in
>> lbug_with_lock() function inside LBUG macro. Adding a never reached
>> return statement suppresses this warning.
> but adding a statement which never executes, is that the correct solution?
> what about :
>
> diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
> index c8f6ab0..1cb3495 100644
> --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c
> +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
> @@ -103,13 +103,12 @@ static int llog_cat_new_log(const struct lu_env *env,
>
>         spin_lock(&loghandle->lgh_hdr_lock);
>         llh->llh_count++;
> -       if (ext2_set_bit(index, llh->llh_bitmap)) {
> -               CERROR("argh, index %u already set in log bitmap?\n",
> -                      index);
> -               spin_unlock(&loghandle->lgh_hdr_lock);
> +       rc = ext2_set_bit(index, llh->llh_bitmap);
> +       spin_unlock(&loghandle->lgh_hdr_lock);
> +       if (rc) {
> +               CERROR("argh, index %u already set in log bitmap?\n", index);
>                 LBUG(); /* should never happen */
>         }
> -       spin_unlock(&loghandle->lgh_hdr_lock);
>
>         cathandle->lgh_last_idx = index;
>         llh->llh_tail.lrt_index = index;
>
>
> regards
> sudip
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
  2015-06-03 15:47   ` Tolga Ceylan
@ 2015-06-03 16:36     ` Sudip Mukherjee
  0 siblings, 0 replies; 6+ messages in thread
From: Sudip Mukherjee @ 2015-06-03 16:36 UTC (permalink / raw)
  To: Tolga Ceylan
  Cc: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Julia Lawall,
	Greg Donald, Joe Perches, Darshana Padmadas, Arjun AK,
	HPDD-discuss, devel, linux-kernel

On Wed, Jun 03, 2015 at 08:47:38AM -0700, Tolga Ceylan wrote:
> The second patch is better (it also keeps the lock locked shorter.) Do
> I need to resend?
yes, please, it was not formally submitted.

regards
sudip

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
  2015-06-03 20:20 Tolga Ceylan
@ 2015-06-08 19:35 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2015-06-08 19:35 UTC (permalink / raw)
  To: Tolga Ceylan
  Cc: Oleg Drokin, Andreas Dilger, Julia Lawall, Arjun AK, Greg Donald,
	Darshana Padmadas, Joe Perches, HPDD-discuss, devel,
	linux-kernel

On Wed, Jun 03, 2015 at 01:20:10PM -0700, Tolga Ceylan wrote:
> In llog_cat_new_log(), sparse emits a context imbalance (unexpected lock)
> warning due its inability to detect the noreturn attribute in
> lbug_with_lock() function inside LBUG macro. With this patch, we unlock
> the spinlock before checking the error condition to resolve this warning.

That's a bug in sparse, not in the code, please don't work around tool
bugs by changing kernel code.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning
@ 2015-06-03 20:20 Tolga Ceylan
  2015-06-08 19:35 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Tolga Ceylan @ 2015-06-03 20:20 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, Greg Kroah-Hartman, Julia Lawall,
	Arjun AK, Greg Donald, Darshana Padmadas, Tolga Ceylan,
	Joe Perches, HPDD-discuss, devel, linux-kernel

In llog_cat_new_log(), sparse emits a context imbalance (unexpected lock)
warning due its inability to detect the noreturn attribute in
lbug_with_lock() function inside LBUG macro. With this patch, we unlock
the spinlock before checking the error condition to resolve this warning.

Signed-off-by: Tolga Ceylan <tolga.ceylan@gmail.com>
---
 drivers/staging/lustre/lustre/obdclass/llog_cat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
index c8f6ab0..280e861 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c
@@ -103,13 +103,13 @@ static int llog_cat_new_log(const struct lu_env *env,
 
 	spin_lock(&loghandle->lgh_hdr_lock);
 	llh->llh_count++;
-	if (ext2_set_bit(index, llh->llh_bitmap)) {
+	rc = ext2_set_bit(index, llh->llh_bitmap);
+	spin_unlock(&loghandle->lgh_hdr_lock);
+	if (rc) {
 		CERROR("argh, index %u already set in log bitmap?\n",
 		       index);
-		spin_unlock(&loghandle->lgh_hdr_lock);
 		LBUG(); /* should never happen */
 	}
-	spin_unlock(&loghandle->lgh_hdr_lock);
 
 	cathandle->lgh_last_idx = index;
 	llh->llh_tail.lrt_index = index;
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-08 19:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02 19:57 [PATCH 1/1] staging: lustre/lustre/obdclass/llog_cat.c: get rid of sparse context imbalance warning Tolga Ceylan
2015-06-03  6:42 ` Sudip Mukherjee
2015-06-03 15:47   ` Tolga Ceylan
2015-06-03 16:36     ` Sudip Mukherjee
2015-06-03 20:20 Tolga Ceylan
2015-06-08 19:35 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.