* [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN.
@ 2011-08-16 6:37 Tao Ma
2011-08-16 14:06 ` Eric Sandeen
2011-08-16 18:29 ` Ted Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Tao Ma @ 2011-08-16 6:37 UTC (permalink / raw)
To: linux-ext4; +Cc: sandeen, mjt, tytso
From: Tao Ma <boyu.mt@taobao.com>
EXT4_IO_END_UNWRITTEN flag set and the increase of i_aiodio_unwritten should
be done simultaneously since ext4_end_io_nolock always clear the flag and
decrease the counter in the same time.
We don't increase i_aiodio_unwritten when setting EXT4_IO_END_UNWRITTEN so
it will go nagative and causes some process to wait forever.
Part of the patch came from Eric in his e-mail, but it doesn't fix the problem
met by Michael actually.
http://marc.info/?l=linux-ext4&m=131316851417460&w=2
Reported-and-Tested-by: Michael Tokarev<mjt@tls.msk.ru>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
Eric talked about creating a helper for this and I feel that it looks
like a new functionality not a bug fix and decided to leave it to the
next merge window.
fs/ext4/inode.c | 9 ++++++++-
fs/ext4/page-io.c | 6 ++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d47264c..40c0b10 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2668,8 +2668,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate)
goto out;
}
- io_end->flag = EXT4_IO_END_UNWRITTEN;
+ /*
+ * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now,
+ * but being more careful is always safe for the future change.
+ */
inode = io_end->inode;
+ if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
+ io_end->flag |= EXT4_IO_END_UNWRITTEN;
+ atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
+ }
/* Add the io_end to per-inode completed io list*/
spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags);
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 430c401..78839af 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -334,8 +334,10 @@ submit_and_retry:
if ((io_end->num_io_pages >= MAX_IO_PAGES) &&
(io_end->pages[io_end->num_io_pages-1] != io_page))
goto submit_and_retry;
- if (buffer_uninit(bh))
- io->io_end->flag |= EXT4_IO_END_UNWRITTEN;
+ if (buffer_uninit(bh) && !(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
+ io_end->flag |= EXT4_IO_END_UNWRITTEN;
+ atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
+ }
io->io_end->size += bh->b_size;
io->io_next_block++;
ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh));
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN.
2011-08-16 6:37 [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN Tao Ma
@ 2011-08-16 14:06 ` Eric Sandeen
2011-08-16 18:29 ` Ted Ts'o
1 sibling, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2011-08-16 14:06 UTC (permalink / raw)
To: Tao Ma; +Cc: linux-ext4, mjt, tytso
On 8/16/11 1:37 AM, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
>
> EXT4_IO_END_UNWRITTEN flag set and the increase of i_aiodio_unwritten should
> be done simultaneously since ext4_end_io_nolock always clear the flag and
> decrease the counter in the same time.
>
> We don't increase i_aiodio_unwritten when setting EXT4_IO_END_UNWRITTEN so
> it will go nagative and causes some process to wait forever.
>
> Part of the patch came from Eric in his e-mail, but it doesn't fix the problem
> met by Michael actually.
> http://marc.info/?l=linux-ext4&m=131316851417460&w=2
>
> Reported-and-Tested-by: Michael Tokarev<mjt@tls.msk.ru>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Yes, this looks right to me. It's the patch I meant to send, but
I missed one spot in my haste. ;) Thanks.
-Eric
> ---
> Eric talked about creating a helper for this and I feel that it looks
> like a new functionality not a bug fix and decided to leave it to the
> next merge window.
>
> fs/ext4/inode.c | 9 ++++++++-
> fs/ext4/page-io.c | 6 ++++--
> 2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d47264c..40c0b10 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2668,8 +2668,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate)
> goto out;
> }
>
> - io_end->flag = EXT4_IO_END_UNWRITTEN;
> + /*
> + * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now,
> + * but being more careful is always safe for the future change.
> + */
> inode = io_end->inode;
> + if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
> + io_end->flag |= EXT4_IO_END_UNWRITTEN;
> + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
> + }
>
> /* Add the io_end to per-inode completed io list*/
> spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags);
> diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
> index 430c401..78839af 100644
> --- a/fs/ext4/page-io.c
> +++ b/fs/ext4/page-io.c
> @@ -334,8 +334,10 @@ submit_and_retry:
> if ((io_end->num_io_pages >= MAX_IO_PAGES) &&
> (io_end->pages[io_end->num_io_pages-1] != io_page))
> goto submit_and_retry;
> - if (buffer_uninit(bh))
> - io->io_end->flag |= EXT4_IO_END_UNWRITTEN;
> + if (buffer_uninit(bh) && !(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
> + io_end->flag |= EXT4_IO_END_UNWRITTEN;
> + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
> + }
> io->io_end->size += bh->b_size;
> io->io_next_block++;
> ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN.
2011-08-16 6:37 [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN Tao Ma
2011-08-16 14:06 ` Eric Sandeen
@ 2011-08-16 18:29 ` Ted Ts'o
2011-08-17 2:32 ` Tao Ma
1 sibling, 1 reply; 4+ messages in thread
From: Ted Ts'o @ 2011-08-16 18:29 UTC (permalink / raw)
To: Tao Ma; +Cc: linux-ext4, sandeen, mjt
On Tue, Aug 16, 2011 at 02:37:53PM +0800, Tao Ma wrote:
> From: Tao Ma <boyu.mt@taobao.com>
>
> EXT4_IO_END_UNWRITTEN flag set and the increase of i_aiodio_unwritten should
> be done simultaneously since ext4_end_io_nolock always clear the flag and
> decrease the counter in the same time.
>
> We don't increase i_aiodio_unwritten when setting EXT4_IO_END_UNWRITTEN so
> it will go nagative and causes some process to wait forever.
>
> Part of the patch came from Eric in his e-mail, but it doesn't fix the problem
> met by Michael actually.
> http://marc.info/?l=linux-ext4&m=131316851417460&w=2
>
> Reported-and-Tested-by: Michael Tokarev<mjt@tls.msk.ru>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Thanks I've taken this into the ext4 tree. I am a bit worried this
will trigger a GCC warning:
+ /*
+ * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now,
+ * but being more careful is always safe for the future change.
+ */
inode = io_end->inode;
+ if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
+ io_end->flag |= EXT4_IO_END_UNWRITTEN;
+ atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
+ }
/* Add the io_end to per-inode completed io list*/
spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags);
... since in Google we've been compiling with -Werror, but it's not
causing an error on gcc 4.4, which is what I still have on my laptop.
It may be that newer versions of GCC are smart enough to notice tha
the above is dead code, and then complain with a warning.
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN.
2011-08-16 18:29 ` Ted Ts'o
@ 2011-08-17 2:32 ` Tao Ma
0 siblings, 0 replies; 4+ messages in thread
From: Tao Ma @ 2011-08-17 2:32 UTC (permalink / raw)
To: Ted Ts'o; +Cc: linux-ext4, sandeen
On 08/17/2011 02:29 AM, Ted Ts'o wrote:
> On Tue, Aug 16, 2011 at 02:37:53PM +0800, Tao Ma wrote:
>> From: Tao Ma <boyu.mt@taobao.com>
>>
>> EXT4_IO_END_UNWRITTEN flag set and the increase of i_aiodio_unwritten should
>> be done simultaneously since ext4_end_io_nolock always clear the flag and
>> decrease the counter in the same time.
>>
>> We don't increase i_aiodio_unwritten when setting EXT4_IO_END_UNWRITTEN so
>> it will go nagative and causes some process to wait forever.
>>
>> Part of the patch came from Eric in his e-mail, but it doesn't fix the problem
>> met by Michael actually.
>> http://marc.info/?l=linux-ext4&m=131316851417460&w=2
>>
>> Reported-and-Tested-by: Michael Tokarev<mjt@tls.msk.ru>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
>
> Thanks I've taken this into the ext4 tree. I am a bit worried this
> will trigger a GCC warning:
>
> + /*
> + * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now,
> + * but being more careful is always safe for the future change.
> + */
> inode = io_end->inode;
> + if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) {
> + io_end->flag |= EXT4_IO_END_UNWRITTEN;
> + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten);
> + }
>
> /* Add the io_end to per-inode completed io list*/
> spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags);
>
> ... since in Google we've been compiling with -Werror, but it's not
> causing an error on gcc 4.4, which is what I still have on my laptop.
> It may be that newer versions of GCC are smart enough to notice tha
> the above is dead code, and then complain with a warning.
Sorry for my bluntness. But where is the 'dead code' you mean?
Thanks
Tao
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-17 2:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-16 6:37 [PATCH] ext4: Resolve the hang of direct i/o read in handling EXT4_IO_END_UNWRITTEN Tao Ma
2011-08-16 14:06 ` Eric Sandeen
2011-08-16 18:29 ` Ted Ts'o
2011-08-17 2:32 ` Tao Ma
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.