linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/1] jffs2: fix sparse warning: unexpected unlock
       [not found] <1411065976-20386-1-git-send-email-fabf@skynet.be>
@ 2014-09-22 18:12 ` Brian Norris
  2014-09-26 23:17   ` josh
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2014-09-22 18:12 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, linux-mtd, David Woodhouse, linux-sparse

+ linux-sparse

On Thu, Sep 18, 2014 at 08:46:16PM +0200, Fabian Frederick wrote:
> fs/jffs2/summary.c:846:5: warning: context imbalance in 'jffs2_sum_write_sumnode' - unexpected unlock
> 
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
>  fs/jffs2/summary.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
> index c522d09..a0bac7b 100644
> --- a/fs/jffs2/summary.c
> +++ b/fs/jffs2/summary.c
> @@ -844,6 +844,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
>  /* Write out summary information - called from jffs2_do_reserve_space */
>  
>  int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
> +	__releases(&c->erase_completion_lock)
> +	__acquires(&c->erase_completion_lock)

I'm not too familiar with sparse notations, but Documentation/sparse.txt
suggests the above is wrong, and the following is more accurate:

	__must_hold(&c->erase_completion_lock)

But it looks like there are several other examples which do this.
Anyway, here's the relevant doc text, in case someone wants to clarify
it for me, or else tell me the documentation is wrong:

    __must_hold - The specified lock is held on function entry and exit.

    __acquires - The specified lock is held on function exit, but not entry.

    __releases - The specified lock is held on function entry, but not exit.

So __acquires and __releases look mutually exclusive, but it's not clear
if __must_hold will actually cover what we want. (I haven't tested it.)

>  {
>  	int datasize, infosize, padsize;
>  	struct jffs2_eraseblock *jeb;

Brian

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

* Re: [PATCH 1/1] jffs2: fix sparse warning: unexpected unlock
  2014-09-22 18:12 ` [PATCH 1/1] jffs2: fix sparse warning: unexpected unlock Brian Norris
@ 2014-09-26 23:17   ` josh
  2014-09-27  8:41     ` Fabian Frederick
  0 siblings, 1 reply; 4+ messages in thread
From: josh @ 2014-09-26 23:17 UTC (permalink / raw)
  To: Brian Norris
  Cc: Fabian Frederick, linux-kernel, linux-mtd, David Woodhouse,
	linux-sparse

On Mon, Sep 22, 2014 at 11:12:50AM -0700, Brian Norris wrote:
> + linux-sparse
> 
> On Thu, Sep 18, 2014 at 08:46:16PM +0200, Fabian Frederick wrote:
> > fs/jffs2/summary.c:846:5: warning: context imbalance in 'jffs2_sum_write_sumnode' - unexpected unlock
> > 
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > ---
> >  fs/jffs2/summary.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
> > index c522d09..a0bac7b 100644
> > --- a/fs/jffs2/summary.c
> > +++ b/fs/jffs2/summary.c
> > @@ -844,6 +844,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock
> >  /* Write out summary information - called from jffs2_do_reserve_space */
> >  
> >  int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
> > +	__releases(&c->erase_completion_lock)
> > +	__acquires(&c->erase_completion_lock)
> 
> I'm not too familiar with sparse notations, but Documentation/sparse.txt
> suggests the above is wrong, and the following is more accurate:
> 
> 	__must_hold(&c->erase_completion_lock)
> 
> But it looks like there are several other examples which do this.
> Anyway, here's the relevant doc text, in case someone wants to clarify
> it for me, or else tell me the documentation is wrong:
> 
>     __must_hold - The specified lock is held on function entry and exit.
> 
>     __acquires - The specified lock is held on function exit, but not entry.
> 
>     __releases - The specified lock is held on function entry, but not exit.
> 
> So __acquires and __releases look mutually exclusive, but it's not clear
> if __must_hold will actually cover what we want. (I haven't tested it.)

__must_hold is indeed the correct annotation.  (There isn't currently
anything enforcing that, though.)

- Josh Triplett

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

* Re: [PATCH 1/1] jffs2: fix sparse warning: unexpected unlock
  2014-09-26 23:17   ` josh
@ 2014-09-27  8:41     ` Fabian Frederick
  2014-09-28  9:56       ` Josh Triplett
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Frederick @ 2014-09-27  8:41 UTC (permalink / raw)
  To: josh, Brian Norris; +Cc: linux-mtd, David Woodhouse, linux-kernel, linux-sparse



> On 27 September 2014 at 01:17 josh@joshtriplett.org wrote:
>
>
> On Mon, Sep 22, 2014 at 11:12:50AM -0700, Brian Norris wrote:
> > + linux-sparse
> >
> > On Thu, Sep 18, 2014 at 08:46:16PM +0200, Fabian Frederick wrote:
> > > fs/jffs2/summary.c:846:5: warning: context imbalance in
> > > 'jffs2_sum_write_sumnode' - unexpected unlock
> > >
> > > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > > ---
> > >  fs/jffs2/summary.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
> > > index c522d09..a0bac7b 100644
> > > --- a/fs/jffs2/summary.c
> > > +++ b/fs/jffs2/summary.c
> > > @@ -844,6 +844,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info
> > > *c, struct jffs2_eraseblock
> > >  /* Write out summary information - called from jffs2_do_reserve_space */
> > > 
> > >  int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
> > > + __releases(&c->erase_completion_lock)
> > > + __acquires(&c->erase_completion_lock)
> >
> > I'm not too familiar with sparse notations, but Documentation/sparse.txt
> > suggests the above is wrong, and the following is more accurate:
> >
> >     __must_hold(&c->erase_completion_lock)
> >
> > But it looks like there are several other examples which do this.
> > Anyway, here's the relevant doc text, in case someone wants to clarify
> > it for me, or else tell me the documentation is wrong:
> >
> >     __must_hold - The specified lock is held on function entry and exit.
> >
> >     __acquires - The specified lock is held on function exit, but not entry.
> >
> >     __releases - The specified lock is held on function entry, but not exit.
> >
> > So __acquires and __releases look mutually exclusive, but it's not clear
> > if __must_hold will actually cover what we want. (I haven't tested it.)
>
> __must_hold is indeed the correct annotation.  (There isn't currently
> anything enforcing that, though.)
>
> - Josh Triplett

There are 137 __releases && __acquires annotated functions in stable.

AFAICS those are based on lock held on function entry / lock held on exit

See
fs/fuse/file.c:1527
fs/kernfs/dir.c:341
drivers/block/nbd.c:564

Does it mean that all of these should be updated to __must_hold ?

Fabian

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

* Re: [PATCH 1/1] jffs2: fix sparse warning: unexpected unlock
  2014-09-27  8:41     ` Fabian Frederick
@ 2014-09-28  9:56       ` Josh Triplett
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Triplett @ 2014-09-28  9:56 UTC (permalink / raw)
  To: Fabian Frederick
  Cc: Brian Norris, linux-mtd, David Woodhouse, linux-kernel,
	linux-sparse

On Sat, Sep 27, 2014 at 10:41:55AM +0200, Fabian Frederick wrote:
> 
> 
> > On 27 September 2014 at 01:17 josh@joshtriplett.org wrote:
> >
> >
> > On Mon, Sep 22, 2014 at 11:12:50AM -0700, Brian Norris wrote:
> > > + linux-sparse
> > >
> > > On Thu, Sep 18, 2014 at 08:46:16PM +0200, Fabian Frederick wrote:
> > > > fs/jffs2/summary.c:846:5: warning: context imbalance in
> > > > 'jffs2_sum_write_sumnode' - unexpected unlock
> > > >
> > > > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > > > ---
> > > >  fs/jffs2/summary.c | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
> > > > index c522d09..a0bac7b 100644
> > > > --- a/fs/jffs2/summary.c
> > > > +++ b/fs/jffs2/summary.c
> > > > @@ -844,6 +844,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info
> > > > *c, struct jffs2_eraseblock
> > > >  /* Write out summary information - called from jffs2_do_reserve_space */
> > > > 
> > > >  int jffs2_sum_write_sumnode(struct jffs2_sb_info *c)
> > > > + __releases(&c->erase_completion_lock)
> > > > + __acquires(&c->erase_completion_lock)
> > >
> > > I'm not too familiar with sparse notations, but Documentation/sparse.txt
> > > suggests the above is wrong, and the following is more accurate:
> > >
> > >     __must_hold(&c->erase_completion_lock)
> > >
> > > But it looks like there are several other examples which do this.
> > > Anyway, here's the relevant doc text, in case someone wants to clarify
> > > it for me, or else tell me the documentation is wrong:
> > >
> > >     __must_hold - The specified lock is held on function entry and exit.
> > >
> > >     __acquires - The specified lock is held on function exit, but not entry.
> > >
> > >     __releases - The specified lock is held on function entry, but not exit.
> > >
> > > So __acquires and __releases look mutually exclusive, but it's not clear
> > > if __must_hold will actually cover what we want. (I haven't tested it.)
> >
> > __must_hold is indeed the correct annotation.  (There isn't currently
> > anything enforcing that, though.)
> >
> > - Josh Triplett
> 
> There are 137 __releases && __acquires annotated functions in stable.
> 
> AFAICS those are based on lock held on function entry / lock held on exit
> 
> See
> fs/fuse/file.c:1527
> fs/kernfs/dir.c:341
> drivers/block/nbd.c:564
> 
> Does it mean that all of these should be updated to __must_hold ?

Not really worth changing yet until something actually pays closer
attention to those annotations.

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

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

end of thread, other threads:[~2014-09-28  9:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1411065976-20386-1-git-send-email-fabf@skynet.be>
2014-09-22 18:12 ` [PATCH 1/1] jffs2: fix sparse warning: unexpected unlock Brian Norris
2014-09-26 23:17   ` josh
2014-09-27  8:41     ` Fabian Frederick
2014-09-28  9:56       ` Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).