Linux NILFS development
 help / color / mirror / Atom feed
* [PATCH 0/2] nilfs2: eliminate sparse warnings
@ 2010-10-08 13:37 Jiro SEKIBA
       [not found] ` <1286545048-21582-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2010-10-08 13:37 UTC (permalink / raw)
  To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA
  Cc: konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg, ryusuke-sG5X7nlA6pw,
	Jiro SEKIBA

Hi, these are trivial fixup to eliminate sparse warnings when
compiling with C=1.

First patch changes a variable and a function used only in a file static.
Second patch adds sparse annotations to stop warning for imbalance context
for lock variable.

 fs/nilfs2/dat.c     |    3 ++-
 fs/nilfs2/segment.c |   11 +++++++++++
 fs/nilfs2/super.c   |    2 +-
 3 files changed, 14 insertions(+), 2 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/2] nilfs2: eliminate sparse warnings - "symbol not declared"
       [not found] ` <1286545048-21582-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
@ 2010-10-08 13:37   ` Jiro SEKIBA
       [not found]     ` <1286545048-21582-2-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
  2010-10-08 13:37   ` [PATCH 2/2] nilfs2: eliminate sparse warning - "context imbalance" Jiro SEKIBA
  1 sibling, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2010-10-08 13:37 UTC (permalink / raw)
  To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA
  Cc: konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg, ryusuke-sG5X7nlA6pw,
	Jiro SEKIBA

change nilfs_dat_commit_free and nilfs_inode_cachep static
to fix following warnings

fs/nilfs2/super.c:72:19: warning: symbol 'nilfs_inode_cachep' was not declared. Should it be static?
fs/nilfs2/dat.c:106:6: warning: symbol 'nilfs_dat_commit_free' was not declared. Should it be static?

Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
---
 fs/nilfs2/dat.c   |    3 ++-
 fs/nilfs2/super.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
index ab04a68..49c844d 100644
--- a/fs/nilfs2/dat.c
+++ b/fs/nilfs2/dat.c
@@ -103,7 +103,8 @@ void nilfs_dat_abort_alloc(struct inode *dat, struct nilfs_palloc_req *req)
 	nilfs_palloc_abort_alloc_entry(dat, req);
 }
 
-void nilfs_dat_commit_free(struct inode *dat, struct nilfs_palloc_req *req)
+static void nilfs_dat_commit_free(struct inode *dat,
+				  struct nilfs_palloc_req *req)
 {
 	struct nilfs_dat_entry *entry;
 	void *kaddr;
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 027c7e8..1d506a5 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -69,7 +69,7 @@ MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem "
 		   "(NILFS)");
 MODULE_LICENSE("GPL");
 
-struct kmem_cache *nilfs_inode_cachep;
+static struct kmem_cache *nilfs_inode_cachep;
 struct kmem_cache *nilfs_transaction_cachep;
 struct kmem_cache *nilfs_segbuf_cachep;
 struct kmem_cache *nilfs_btree_path_cache;
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/2] nilfs2: eliminate sparse warning - "context imbalance"
       [not found] ` <1286545048-21582-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
  2010-10-08 13:37   ` [PATCH 1/2] nilfs2: eliminate sparse warnings - "symbol not declared" Jiro SEKIBA
@ 2010-10-08 13:37   ` Jiro SEKIBA
       [not found]     ` <1286545048-21582-3-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Jiro SEKIBA @ 2010-10-08 13:37 UTC (permalink / raw)
  To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA
  Cc: konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg, ryusuke-sG5X7nlA6pw,
	Jiro SEKIBA

insert sparse annotations to fix following sparse warning.

fs/nilfs2/segment.c:2681:3: warning: context imbalance in 'nilfs_segctor_kill_thread' - unexpected unlock

Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
---
 fs/nilfs2/segment.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 172ad42..c64f6e4 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -2677,12 +2677,23 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci)
 {
 	sci->sc_state |= NILFS_SEGCTOR_QUIT;
 
+	/* 
+	 * nilfs_segctor_kill_thread is only called inside sc_state_lock lock.
+	 * sparse doesn't detect the context and warn "unexpected unlock".
+	 * This pretends to lock the sc_state_lock for sparse.
+	 */
+	__acquire(&sci->sc_state_lock);
 	while (sci->sc_task) {
 		wake_up(&sci->sc_wait_daemon);
 		spin_unlock(&sci->sc_state_lock);
 		wait_event(sci->sc_wait_task, sci->sc_task == NULL);
 		spin_lock(&sci->sc_state_lock);
 	}
+	/*
+	 * Pretending to lock sc_state_lock will cause "wrong count" warning.
+	 * This pretends to unlock th sc_state_lock for sparse.
+	 */
+	__release(&sci->sc_state_lock);
 }
 
 /*
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] nilfs2: eliminate sparse warnings - "symbol not declared"
       [not found]     ` <1286545048-21582-2-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
@ 2010-10-12  5:03       ` Ryusuke Konishi
  0 siblings, 0 replies; 6+ messages in thread
From: Ryusuke Konishi @ 2010-10-12  5:03 UTC (permalink / raw)
  To: jir-hfpbi5WX9J54Eiagz67IpQ
  Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
	konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg

On Fri,  8 Oct 2010 22:37:27 +0900, Jiro SEKIBA wrote:
> change nilfs_dat_commit_free and nilfs_inode_cachep static
> to fix following warnings
> 
> fs/nilfs2/super.c:72:19: warning: symbol 'nilfs_inode_cachep' was not declared. Should it be static?
> fs/nilfs2/dat.c:106:6: warning: symbol 'nilfs_dat_commit_free' was not declared. Should it be static?
> 
> Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>

Applied.

Thanks,
Ryusuke Konishi

> ---
>  fs/nilfs2/dat.c   |    3 ++-
>  fs/nilfs2/super.c |    2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nilfs2/dat.c b/fs/nilfs2/dat.c
> index ab04a68..49c844d 100644
> --- a/fs/nilfs2/dat.c
> +++ b/fs/nilfs2/dat.c
> @@ -103,7 +103,8 @@ void nilfs_dat_abort_alloc(struct inode *dat, struct nilfs_palloc_req *req)
>  	nilfs_palloc_abort_alloc_entry(dat, req);
>  }
>  
> -void nilfs_dat_commit_free(struct inode *dat, struct nilfs_palloc_req *req)
> +static void nilfs_dat_commit_free(struct inode *dat,
> +				  struct nilfs_palloc_req *req)
>  {
>  	struct nilfs_dat_entry *entry;
>  	void *kaddr;
> diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
> index 027c7e8..1d506a5 100644
> --- a/fs/nilfs2/super.c
> +++ b/fs/nilfs2/super.c
> @@ -69,7 +69,7 @@ MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem "
>  		   "(NILFS)");
>  MODULE_LICENSE("GPL");
>  
> -struct kmem_cache *nilfs_inode_cachep;
> +static struct kmem_cache *nilfs_inode_cachep;
>  struct kmem_cache *nilfs_transaction_cachep;
>  struct kmem_cache *nilfs_segbuf_cachep;
>  struct kmem_cache *nilfs_btree_path_cache;
> -- 
> 1.5.6.5
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] nilfs2: eliminate sparse warning - "context imbalance"
       [not found]     ` <1286545048-21582-3-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
@ 2010-10-12  5:15       ` Ryusuke Konishi
       [not found]         ` <20101012.141544.180421617.ryusuke-sG5X7nlA6pw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Ryusuke Konishi @ 2010-10-12  5:15 UTC (permalink / raw)
  To: jir-hfpbi5WX9J54Eiagz67IpQ
  Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
	konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg

On Fri,  8 Oct 2010 22:37:28 +0900, Jiro SEKIBA wrote:
> insert sparse annotations to fix following sparse warning.
> 
> fs/nilfs2/segment.c:2681:3: warning: context imbalance in 'nilfs_segctor_kill_thread' - unexpected unlock
> 
> Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
> ---
>  fs/nilfs2/segment.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
> index 172ad42..c64f6e4 100644
> --- a/fs/nilfs2/segment.c
> +++ b/fs/nilfs2/segment.c
> @@ -2677,12 +2677,23 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci)
>  {
>  	sci->sc_state |= NILFS_SEGCTOR_QUIT;
>  
> +	/* 
> +	 * nilfs_segctor_kill_thread is only called inside sc_state_lock lock.
> +	 * sparse doesn't detect the context and warn "unexpected unlock".
> +	 * This pretends to lock the sc_state_lock for sparse.
> +	 */
> +	__acquire(&sci->sc_state_lock);
>  	while (sci->sc_task) {
>  		wake_up(&sci->sc_wait_daemon);
>  		spin_unlock(&sci->sc_state_lock);
>  		wait_event(sci->sc_wait_task, sci->sc_task == NULL);
>  		spin_lock(&sci->sc_state_lock);
>  	}
> +	/*
> +	 * Pretending to lock sc_state_lock will cause "wrong count" warning.
> +	 * This pretends to unlock th sc_state_lock for sparse.
> +	 */
> +	__release(&sci->sc_state_lock);
>  }
>  
>  /*
> -- 
> 1.5.6.5

Thanks, but you don't have to insert __acquire() and __release() calls
in the function.  Just declare __releases() and __acquires() as below.

 static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci)
+       __releases(&sci->sc_state_lock)
+       __acquires(&sci->sc_state_lock)
 {

You can find this style of examples in other sites in the kernel.

Thanks,
Ryusuke Konishi
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/2] nilfs2: eliminate sparse warning - "context imbalance"
       [not found]         ` <20101012.141544.180421617.ryusuke-sG5X7nlA6pw@public.gmane.org>
@ 2010-10-13  3:18           ` Jiro SEKIBA
  0 siblings, 0 replies; 6+ messages in thread
From: Jiro SEKIBA @ 2010-10-13  3:18 UTC (permalink / raw)
  To: Ryusuke Konishi
  Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA,
	konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg

At Tue, 12 Oct 2010 14:15:44 +0900 (JST),
Ryusuke Konishi wrote:
> 
> On Fri,  8 Oct 2010 22:37:28 +0900, Jiro SEKIBA wrote:
> > insert sparse annotations to fix following sparse warning.
> > 
> > fs/nilfs2/segment.c:2681:3: warning: context imbalance in 'nilfs_segctor_kill_thread' - unexpected unlock
> > 
> > Signed-off-by: Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
> > ---
> >  fs/nilfs2/segment.c |   11 +++++++++++
> >  1 files changed, 11 insertions(+), 0 deletions(-)
> > 
> > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
> > index 172ad42..c64f6e4 100644
> > --- a/fs/nilfs2/segment.c
> > +++ b/fs/nilfs2/segment.c
> > @@ -2677,12 +2677,23 @@ static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci)
> >  {
> >  	sci->sc_state |= NILFS_SEGCTOR_QUIT;
> >  
> > +	/* 
> > +	 * nilfs_segctor_kill_thread is only called inside sc_state_lock lock.
> > +	 * sparse doesn't detect the context and warn "unexpected unlock".
> > +	 * This pretends to lock the sc_state_lock for sparse.
> > +	 */
> > +	__acquire(&sci->sc_state_lock);
> >  	while (sci->sc_task) {
> >  		wake_up(&sci->sc_wait_daemon);
> >  		spin_unlock(&sci->sc_state_lock);
> >  		wait_event(sci->sc_wait_task, sci->sc_task == NULL);
> >  		spin_lock(&sci->sc_state_lock);
> >  	}
> > +	/*
> > +	 * Pretending to lock sc_state_lock will cause "wrong count" warning.
> > +	 * This pretends to unlock th sc_state_lock for sparse.
> > +	 */
> > +	__release(&sci->sc_state_lock);
> >  }
> >  
> >  /*
> > -- 
> > 1.5.6.5
> 
> Thanks, but you don't have to insert __acquire() and __release() calls
> in the function.  Just declare __releases() and __acquires() as below.
> 
>  static void nilfs_segctor_kill_thread(struct nilfs_sc_info *sci)
> +       __releases(&sci->sc_state_lock)
> +       __acquires(&sci->sc_state_lock)
>  {

Ahh, OK.  Shall I do that fix or are you gonna fix it?
Well, anyway I'll revise and resend it.

thanks,

regards

> You can find this style of examples in other sites in the kernel.
> 
> Thanks,
> Ryusuke Konishi
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 


-- 
Jiro SEKIBA <jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2010-10-13  3:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-08 13:37 [PATCH 0/2] nilfs2: eliminate sparse warnings Jiro SEKIBA
     [not found] ` <1286545048-21582-1-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2010-10-08 13:37   ` [PATCH 1/2] nilfs2: eliminate sparse warnings - "symbol not declared" Jiro SEKIBA
     [not found]     ` <1286545048-21582-2-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2010-10-12  5:03       ` Ryusuke Konishi
2010-10-08 13:37   ` [PATCH 2/2] nilfs2: eliminate sparse warning - "context imbalance" Jiro SEKIBA
     [not found]     ` <1286545048-21582-3-git-send-email-jir-hfpbi5WX9J54Eiagz67IpQ@public.gmane.org>
2010-10-12  5:15       ` Ryusuke Konishi
     [not found]         ` <20101012.141544.180421617.ryusuke-sG5X7nlA6pw@public.gmane.org>
2010-10-13  3:18           ` Jiro SEKIBA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox