linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/01] quota: atomic dq_flags operations in do_set_dqblk
@ 2010-04-12 18:16 Andrew Perepechko
  2010-04-12 19:09 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Perepechko @ 2010-04-12 18:16 UTC (permalink / raw)
  To: jack; +Cc: Johann Lombardi, linux-fsdevel

From: Andrew Perepechko <andrew.perepechko@sun.com>

Non-atomic __set_bit calls are replaced with atomic set_bit calls in do_set_dqblk
so that individual bits should not be lost in a possible race condition.

Signed-off-by: Andrew Perepechko <andrew.perepechko@sun.com>
---
diff -puN fs/dquot.c fs/dquot.c
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -2065,32 +2065,32 @@ static int do_set_dqblk(struct dquot *dq
 	if (di->dqb_valid & QIF_SPACE) {
 		dm->dqb_curspace = di->dqb_curspace;
 		check_blim = 1;
-		__set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
+		set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
 	}
 	if (di->dqb_valid & QIF_BLIMITS) {
 		dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
 		dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
 		check_blim = 1;
-		__set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
+		set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
 	}
 	if (di->dqb_valid & QIF_INODES) {
 		dm->dqb_curinodes = di->dqb_curinodes;
 		check_ilim = 1;
-		__set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
+		set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
 	}
 	if (di->dqb_valid & QIF_ILIMITS) {
 		dm->dqb_isoftlimit = di->dqb_isoftlimit;
 		dm->dqb_ihardlimit = di->dqb_ihardlimit;
 		check_ilim = 1;
-		__set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
+		set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
 	}
 	if (di->dqb_valid & QIF_BTIME) {
 		dm->dqb_btime = di->dqb_btime;
-		__set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
+		set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
 	}
 	if (di->dqb_valid & QIF_ITIME) {
 		dm->dqb_itime = di->dqb_itime;
-		__set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
+		set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
 	}
 
 	if (check_blim) {

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

* Re: [PATCH 01/01] quota: atomic dq_flags operations in do_set_dqblk
  2010-04-12 18:16 [PATCH 01/01] quota: atomic dq_flags operations in do_set_dqblk Andrew Perepechko
@ 2010-04-12 19:09 ` Jan Kara
  2010-04-12 19:39   ` Andrew Perepechko
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2010-04-12 19:09 UTC (permalink / raw)
  To: Andrew Perepechko; +Cc: jack, Johann Lombardi, linux-fsdevel

On Mon 12-04-10 22:16:50, Andrew Perepechko wrote:
> From: Andrew Perepechko <andrew.perepechko@sun.com>
> 
> Non-atomic __set_bit calls are replaced with atomic set_bit calls in do_set_dqblk
> so that individual bits should not be lost in a possible race condition.
  I took a liberty of modifying the changelog to be more descriptive:

quota: Fix possible dq_flags corruption
    
dq_flags are modified non-atomically in do_set_dqblk via __set_bit calls
and atomically for example in mark_dquot_dirty or clear_dquot_dirty.  Hence
a change done by an atomic operation can be overwritten by a change done by
a non-atomic one. Fix the problem by using atomic bitops even in
do_set_dqblk.

  Otherwise I've merged the patch.

								Honza

> Signed-off-by: Andrew Perepechko <andrew.perepechko@sun.com>
> ---
> diff -puN fs/dquot.c fs/dquot.c
> --- a/fs/dquot.c
> +++ b/fs/dquot.c
> @@ -2065,32 +2065,32 @@ static int do_set_dqblk(struct dquot *dq
>  	if (di->dqb_valid & QIF_SPACE) {
>  		dm->dqb_curspace = di->dqb_curspace;
>  		check_blim = 1;
> -		__set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
> +		set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
>  	}
>  	if (di->dqb_valid & QIF_BLIMITS) {
>  		dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
>  		dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
>  		check_blim = 1;
> -		__set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
> +		set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
>  	}
>  	if (di->dqb_valid & QIF_INODES) {
>  		dm->dqb_curinodes = di->dqb_curinodes;
>  		check_ilim = 1;
> -		__set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
> +		set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
>  	}
>  	if (di->dqb_valid & QIF_ILIMITS) {
>  		dm->dqb_isoftlimit = di->dqb_isoftlimit;
>  		dm->dqb_ihardlimit = di->dqb_ihardlimit;
>  		check_ilim = 1;
> -		__set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
> +		set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
>  	}
>  	if (di->dqb_valid & QIF_BTIME) {
>  		dm->dqb_btime = di->dqb_btime;
> -		__set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
> +		set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
>  	}
>  	if (di->dqb_valid & QIF_ITIME) {
>  		dm->dqb_itime = di->dqb_itime;
> -		__set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
> +		set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
>  	}
>  
>  	if (check_blim) {
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* Re: [PATCH 01/01] quota: atomic dq_flags operations in do_set_dqblk
  2010-04-12 19:09 ` Jan Kara
@ 2010-04-12 19:39   ` Andrew Perepechko
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Perepechko @ 2010-04-12 19:39 UTC (permalink / raw)
  To: Jan Kara; +Cc: Johann Lombardi, linux-fsdevel

Thanks a lot, Jan!

Andrew.

On Monday 12 April 2010 11:09:17 pm Jan Kara wrote:
> On Mon 12-04-10 22:16:50, Andrew Perepechko wrote:
> > From: Andrew Perepechko <andrew.perepechko@sun.com>
> > 
> > Non-atomic __set_bit calls are replaced with atomic set_bit calls in
> > do_set_dqblk so that individual bits should not be lost in a possible
> > race condition.
> 
>   I took a liberty of modifying the changelog to be more descriptive:
> 
> quota: Fix possible dq_flags corruption
> 
> dq_flags are modified non-atomically in do_set_dqblk via __set_bit calls
> and atomically for example in mark_dquot_dirty or clear_dquot_dirty.  Hence
> a change done by an atomic operation can be overwritten by a change done by
> a non-atomic one. Fix the problem by using atomic bitops even in
> do_set_dqblk.
> 
>   Otherwise I've merged the patch.
> 
> 								Honza
> 
> > Signed-off-by: Andrew Perepechko <andrew.perepechko@sun.com>
> > ---
> > diff -puN fs/dquot.c fs/dquot.c
> > --- a/fs/dquot.c
> > +++ b/fs/dquot.c
> > @@ -2065,32 +2065,32 @@ static int do_set_dqblk(struct dquot *dq
> > 
> >  	if (di->dqb_valid & QIF_SPACE) {
> >  	
> >  		dm->dqb_curspace = di->dqb_curspace;
> >  		check_blim = 1;
> > 
> > -		__set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
> > +		set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
> > 
> >  	}
> >  	if (di->dqb_valid & QIF_BLIMITS) {
> >  	
> >  		dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
> >  		dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
> >  		check_blim = 1;
> > 
> > -		__set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
> > +		set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
> > 
> >  	}
> >  	if (di->dqb_valid & QIF_INODES) {
> >  	
> >  		dm->dqb_curinodes = di->dqb_curinodes;
> >  		check_ilim = 1;
> > 
> > -		__set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
> > +		set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
> > 
> >  	}
> >  	if (di->dqb_valid & QIF_ILIMITS) {
> >  	
> >  		dm->dqb_isoftlimit = di->dqb_isoftlimit;
> >  		dm->dqb_ihardlimit = di->dqb_ihardlimit;
> >  		check_ilim = 1;
> > 
> > -		__set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
> > +		set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
> > 
> >  	}
> >  	if (di->dqb_valid & QIF_BTIME) {
> >  	
> >  		dm->dqb_btime = di->dqb_btime;
> > 
> > -		__set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
> > +		set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
> > 
> >  	}
> >  	if (di->dqb_valid & QIF_ITIME) {
> >  	
> >  		dm->dqb_itime = di->dqb_itime;
> > 
> > -		__set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
> > +		set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
> > 
> >  	}
> >  	
> >  	if (check_blim) {

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

end of thread, other threads:[~2010-04-12 19:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-12 18:16 [PATCH 01/01] quota: atomic dq_flags operations in do_set_dqblk Andrew Perepechko
2010-04-12 19:09 ` Jan Kara
2010-04-12 19:39   ` Andrew Perepechko

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).