public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* Re: a suspected data race bug in Ext4 file system
       [not found] <2014bcab0811061809vca13befn813440a32dda3914@mail.gmail.com>
@ 2008-11-07  2:51 ` Andrew Morton
  2008-11-07 18:56   ` Mingming Cao
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2008-11-07  2:51 UTC (permalink / raw)
  To:  홍신 shin hong ; +Cc: adilger, linux-ext4

On Fri, 7 Nov 2008 11:09:49 +0900 "______ shin hong" <hongshin@gmail.com> wrote:

> Dear Ext4 maintainer,
> 
> I found a suspected data race bug at ext4_release_file() in ext4/file.c .
> 
> Is it necessary to re-check whether the if-statement's
> condition(atomic_read(&inode->i_writecount) == 1) is satisifed after
> semaphore down operation?
> 
> It seems to use "test and test and set" pattern(double-checking)
>  but the second "test" seems to be missed.
> 
> Please examine this function. Thank you.
> 
> p.s. I sent the same report to sct@redhat.com. But I did not received
> any reply.
>        I think my mail was discarded so I am sending the same again.
> 

An appropriate way to report this possible bug is to Cc: the ext4 mailing
list, which I have cc'ed here.

Thanks.

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

* Re: a suspected data race bug in Ext4 file system
  2008-11-07  2:51 ` a suspected data race bug in Ext4 file system Andrew Morton
@ 2008-11-07 18:56   ` Mingming Cao
  0 siblings, 0 replies; 2+ messages in thread
From: Mingming Cao @ 2008-11-07 18:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: hongshin, adilger, linux-ext4


On Thu, 2008-11-06 at 18:51 -0800, Andrew Morton wrote:
> On Fri, 7 Nov 2008 11:09:49 +0900 "______ shin hong" <hongshin@gmail.com> wrote:
> 
> > Dear Ext4 maintainer,
> > 
> > I found a suspected data race bug at ext4_release_file() in ext4/file.c .
> > 
> > Is it necessary to re-check whether the if-statement's
> > condition(atomic_read(&inode->i_writecount) == 1) is satisifed after
> > semaphore down operation?
> > 
> > It seems to use "test and test and set" pattern(double-checking)
> >  but the second "test" seems to be missed.
> > 
> > Please examine this function. Thank you.
> > 
> > p.s. I sent the same report to sct@redhat.com. But I did not received
> > any reply.
> >        I think my mail was discarded so I am sending the same again.
> > 
> 
> An appropriate way to report this possible bug is to Cc: the ext4 mailing
> list, which I have cc'ed here.

I guess we could add the check after grab the i_data_sem, but not sure
how useful is that, there is always a window that during the process of
freeing preallocation, another new writer to the same inode. The
i_data_sem semaphore is hold to prevent race between discard
preallocation and use of preallocation, not to protect i_writecount.

The check of inode's i_writecount is to avoid doing discard for every
file close, the idea is only try to discard the preallocation for the
last writer of the file. But the i_writecount could be >1 at the time of
discard preallocation. If a new writer comes in after i_data_sem is hold
then the preallocation is freed, then by the time the new writer comes
in and need block allocation, the preallocate gets build up
atomatically.

 
Mingming


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

end of thread, other threads:[~2008-11-07 18:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <2014bcab0811061809vca13befn813440a32dda3914@mail.gmail.com>
2008-11-07  2:51 ` a suspected data race bug in Ext4 file system Andrew Morton
2008-11-07 18:56   ` Mingming Cao

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