All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate()
@ 2012-01-16  8:47 Zheng Liu
  2012-05-23  1:19 ` Zheng Liu
  2012-06-14  0:15 ` Ted Ts'o
  0 siblings, 2 replies; 4+ messages in thread
From: Zheng Liu @ 2012-01-16  8:47 UTC (permalink / raw)
  To: linux-ext4; +Cc: Zheng Liu, Theodore Ts'o

Ext4 must make sure the transaction to be commited to the disk when user opens
a file with O_(D)SYNC flag and do a fallocate(2) call.

This problem had been reported by Christoph Hellwig in this thread:
http://www.spinics.net/lists/linux-btrfs/msg13621.html

CC: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
---
 fs/ext4/extents.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 74f23c2..00e32d9 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4356,6 +4356,8 @@ retry:
 			ret = PTR_ERR(handle);
 			break;
 		}
+		if (file->f_flags & O_SYNC)
+			ext4_handle_sync(handle);
 		ret = ext4_map_blocks(handle, inode, &map, flags);
 		if (ret <= 0) {
 #ifdef EXT4FS_DEBUG
-- 
1.7.4.1


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

* Re: [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate()
  2012-01-16  8:47 [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate() Zheng Liu
@ 2012-05-23  1:19 ` Zheng Liu
  2012-06-14  0:15 ` Ted Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: Zheng Liu @ 2012-05-23  1:19 UTC (permalink / raw)
  To: linux-ext4; +Cc: Zheng Liu, Theodore Ts'o

On Mon, Jan 16, 2012 at 04:47:43PM +0800, Zheng Liu wrote:
> Ext4 must make sure the transaction to be commited to the disk when user opens
> a file with O_(D)SYNC flag and do a fallocate(2) call.
> 
> This problem had been reported by Christoph Hellwig in this thread:
> http://www.spinics.net/lists/linux-btrfs/msg13621.html

Hi Ted,

Could you please review this patch?  Thank you.

Regards,
Zheng  

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

* Re: [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate()
  2012-01-16  8:47 [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate() Zheng Liu
  2012-05-23  1:19 ` Zheng Liu
@ 2012-06-14  0:15 ` Ted Ts'o
  2012-06-14  2:43   ` Zheng Liu
  1 sibling, 1 reply; 4+ messages in thread
From: Ted Ts'o @ 2012-06-14  0:15 UTC (permalink / raw)
  To: Zheng Liu; +Cc: linux-ext4, Zheng Liu

Hi Zheng,

I finally got around to reviewing this patch and I had one comment

> Ext4 must make sure the transaction to be commited to the disk when
> user opens a file with O_(D)SYNC flag and do a fallocate(2) call.
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 74f23c2..00e32d9 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4356,6 +4356,8 @@ retry:
>  			ret = PTR_ERR(handle);
>  			break;
>  		}
> +		if (file->f_flags & O_SYNC)
> +			ext4_handle_sync(handle);
>  		ret = ext4_map_blocks(handle, inode, &map, flags);
>  		if (ret <= 0) {
>  #ifdef EXT4FS_DEBUG

For a large fallocate(), it can require multiple calls to
ext4_map_blocks(), and we should only sync after we've allocated the
last segment.  We should also not force a sync if there is an error
allocating blocks.  So it seems to me this patch would be better; what
do you think?

						- Ted

commit b790d70be9515dfaba59b0be0aff373e6867826d
Author: Zheng Liu <gnehzuil.liu@gmail.com>
Date:   Wed Jun 13 20:15:01 2012 -0400

    ext4: honor O_(D)SYNC semantic in ext4_fallocate()
    
    Ext4 must make sure the transaction to be commited to the disk when
    user opens a file with O_(D)SYNC flag and do a fallocate(2) call.
    
    This problem had been reported by Christoph Hellwig in this thread:
    http://www.spinics.net/lists/linux-btrfs/msg13621.html
    
    Reported-by: Christoph Hellwig <hch@infradead.org>
    Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 91341ec..f1089cb 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4420,6 +4420,8 @@ retry:
 		ext4_falloc_update_inode(inode, mode, new_size,
 					 (map.m_flags & EXT4_MAP_NEW));
 		ext4_mark_inode_dirty(handle, inode);
+		if ((file->f_flags & O_SYNC) && ret >= max_blocks)
+			ext4_handle_sync(handle);
 		ret2 = ext4_journal_stop(handle);
 		if (ret2)
 			break;

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

* Re: [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate()
  2012-06-14  0:15 ` Ted Ts'o
@ 2012-06-14  2:43   ` Zheng Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Zheng Liu @ 2012-06-14  2:43 UTC (permalink / raw)
  To: Ted Ts'o; +Cc: linux-ext4, Zheng Liu

On Wed, Jun 13, 2012 at 08:15:31PM -0400, Ted Ts'o wrote:
> Hi Zheng,
> 
> I finally got around to reviewing this patch and I had one comment
> 
> > Ext4 must make sure the transaction to be commited to the disk when
> > user opens a file with O_(D)SYNC flag and do a fallocate(2) call.
> > 
> > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> > index 74f23c2..00e32d9 100644
> > --- a/fs/ext4/extents.c
> > +++ b/fs/ext4/extents.c
> > @@ -4356,6 +4356,8 @@ retry:
> >  			ret = PTR_ERR(handle);
> >  			break;
> >  		}
> > +		if (file->f_flags & O_SYNC)
> > +			ext4_handle_sync(handle);
> >  		ret = ext4_map_blocks(handle, inode, &map, flags);
> >  		if (ret <= 0) {
> >  #ifdef EXT4FS_DEBUG
> 
> For a large fallocate(), it can require multiple calls to
> ext4_map_blocks(), and we should only sync after we've allocated the
> last segment.  We should also not force a sync if there is an error
> allocating blocks.  So it seems to me this patch would be better; what
> do you think?

Hi Ted,

Thank you for your review.  I agree with you that the following patch is
better.

Regards,
Zheng

> commit b790d70be9515dfaba59b0be0aff373e6867826d
> Author: Zheng Liu <gnehzuil.liu@gmail.com>
> Date:   Wed Jun 13 20:15:01 2012 -0400
> 
>     ext4: honor O_(D)SYNC semantic in ext4_fallocate()
>     
>     Ext4 must make sure the transaction to be commited to the disk when
>     user opens a file with O_(D)SYNC flag and do a fallocate(2) call.
>     
>     This problem had been reported by Christoph Hellwig in this thread:
>     http://www.spinics.net/lists/linux-btrfs/msg13621.html
>     
>     Reported-by: Christoph Hellwig <hch@infradead.org>
>     Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
>     Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 91341ec..f1089cb 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -4420,6 +4420,8 @@ retry:
>  		ext4_falloc_update_inode(inode, mode, new_size,
>  					 (map.m_flags & EXT4_MAP_NEW));
>  		ext4_mark_inode_dirty(handle, inode);
> +		if ((file->f_flags & O_SYNC) && ret >= max_blocks)
> +			ext4_handle_sync(handle);
>  		ret2 = ext4_journal_stop(handle);
>  		if (ret2)
>  			break;

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

end of thread, other threads:[~2012-06-14  2:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-16  8:47 [PATCH RESEND] ext4: make sure O_(D)SYNC semantic in ext4_fallocate() Zheng Liu
2012-05-23  1:19 ` Zheng Liu
2012-06-14  0:15 ` Ted Ts'o
2012-06-14  2:43   ` Zheng Liu

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.