* [PATCH] ext4: fix warning when turn on dioread_nolock and inline_data
@ 2019-07-04 12:50 yangerkun
2019-07-04 14:55 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: yangerkun @ 2019-07-04 12:50 UTC (permalink / raw)
To: tytso, jack; +Cc: linux-ext4, yangerkun, houtao1, yi.zhang, miaoxie
mkfs.ext4 -O inline_data /dev/vdb
mount -o dioread_nolock /dev/vdb /mnt
echo "some inline data..." >> /mnt/test-file
echo "some inline data..." >> /mnt/test-file
sync
With upon script, system will trigger
"WARN_ON(!io_end->handle && sbi->s_journal)" since the wrong order
between rsv_blocks calculate and destroy inline data for dealloc.
Signed-off-by: yangerkun <yangerkun@huawei.com>
---
fs/ext4/inode.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c7f77c6..3f2a366 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2769,15 +2769,6 @@ static int ext4_writepages(struct address_space *mapping,
goto out_writepages;
}
- if (ext4_should_dioread_nolock(inode)) {
- /*
- * We may need to convert up to one extent per block in
- * the page and we may dirty the inode.
- */
- rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
- PAGE_SIZE >> inode->i_blkbits);
- }
-
/*
* If we have inline data and arrive here, it means that
* we will soon create the block for the 1st page, so
@@ -2796,6 +2787,15 @@ static int ext4_writepages(struct address_space *mapping,
ext4_journal_stop(handle);
}
+ if (ext4_should_dioread_nolock(inode)) {
+ /*
+ * We may need to convert up to one extent per block in
+ * the page and we may dirty the inode.
+ */
+ rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
+ PAGE_SIZE >> inode->i_blkbits);
+ }
+
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
range_whole = 1;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: fix warning when turn on dioread_nolock and inline_data
2019-07-04 12:50 [PATCH] ext4: fix warning when turn on dioread_nolock and inline_data yangerkun
@ 2019-07-04 14:55 ` Jan Kara
2019-07-05 7:52 ` yangerkun
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2019-07-04 14:55 UTC (permalink / raw)
To: yangerkun; +Cc: tytso, Jan Kara, houtao1, miaoxie, yi.zhang, linux-ext4
On Thu 04-07-19 20:50:32, yangerkun wrote:
> mkfs.ext4 -O inline_data /dev/vdb
> mount -o dioread_nolock /dev/vdb /mnt
> echo "some inline data..." >> /mnt/test-file
> echo "some inline data..." >> /mnt/test-file
> sync
>
> With upon script, system will trigger
> "WARN_ON(!io_end->handle && sbi->s_journal)" since the wrong order
> between rsv_blocks calculate and destroy inline data for dealloc.
Thanks for the patch! Good catch! I'd just rephrase the last paragraph as:
The above script will trigger "WARN_ON(!io_end->handle && sbi->s_journal)"
because ext4_should_dioread_nolock() returns false for a file with inline
data. Move the check to a place after we have already removed the inline
data and prepared inode to write normal pages.
Otherwise the patch looks good to me so feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
>
> Signed-off-by: yangerkun <yangerkun@huawei.com>
> ---
> fs/ext4/inode.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index c7f77c6..3f2a366 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2769,15 +2769,6 @@ static int ext4_writepages(struct address_space *mapping,
> goto out_writepages;
> }
>
> - if (ext4_should_dioread_nolock(inode)) {
> - /*
> - * We may need to convert up to one extent per block in
> - * the page and we may dirty the inode.
> - */
> - rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
> - PAGE_SIZE >> inode->i_blkbits);
> - }
> -
> /*
> * If we have inline data and arrive here, it means that
> * we will soon create the block for the 1st page, so
> @@ -2796,6 +2787,15 @@ static int ext4_writepages(struct address_space *mapping,
> ext4_journal_stop(handle);
> }
>
> + if (ext4_should_dioread_nolock(inode)) {
> + /*
> + * We may need to convert up to one extent per block in
> + * the page and we may dirty the inode.
> + */
> + rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
> + PAGE_SIZE >> inode->i_blkbits);
> + }
> +
> if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
> range_whole = 1;
>
> --
> 2.7.4
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: fix warning when turn on dioread_nolock and inline_data
2019-07-04 14:55 ` Jan Kara
@ 2019-07-05 7:52 ` yangerkun
0 siblings, 0 replies; 3+ messages in thread
From: yangerkun @ 2019-07-05 7:52 UTC (permalink / raw)
To: Jan Kara; +Cc: tytso, Jan Kara, houtao1, miaoxie, yi.zhang, linux-ext4
Thanks a lot! Will resend the patch soon!
On 2019/7/4 22:55, Jan Kara wrote:
> On Thu 04-07-19 20:50:32, yangerkun wrote:
>> mkfs.ext4 -O inline_data /dev/vdb
>> mount -o dioread_nolock /dev/vdb /mnt
>> echo "some inline data..." >> /mnt/test-file
>> echo "some inline data..." >> /mnt/test-file
>> sync
>>
>> With upon script, system will trigger
>> "WARN_ON(!io_end->handle && sbi->s_journal)" since the wrong order
>> between rsv_blocks calculate and destroy inline data for dealloc.
> Thanks for the patch! Good catch! I'd just rephrase the last paragraph as:
>
> The above script will trigger "WARN_ON(!io_end->handle && sbi->s_journal)"
> because ext4_should_dioread_nolock() returns false for a file with inline
> data. Move the check to a place after we have already removed the inline
> data and prepared inode to write normal pages.
>
> Otherwise the patch looks good to me so feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
> Honza
>
>> Signed-off-by: yangerkun <yangerkun@huawei.com>
>> ---
>> fs/ext4/inode.c | 18 +++++++++---------
>> 1 file changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
>> index c7f77c6..3f2a366 100644
>> --- a/fs/ext4/inode.c
>> +++ b/fs/ext4/inode.c
>> @@ -2769,15 +2769,6 @@ static int ext4_writepages(struct address_space *mapping,
>> goto out_writepages;
>> }
>>
>> - if (ext4_should_dioread_nolock(inode)) {
>> - /*
>> - * We may need to convert up to one extent per block in
>> - * the page and we may dirty the inode.
>> - */
>> - rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
>> - PAGE_SIZE >> inode->i_blkbits);
>> - }
>> -
>> /*
>> * If we have inline data and arrive here, it means that
>> * we will soon create the block for the 1st page, so
>> @@ -2796,6 +2787,15 @@ static int ext4_writepages(struct address_space *mapping,
>> ext4_journal_stop(handle);
>> }
>>
>> + if (ext4_should_dioread_nolock(inode)) {
>> + /*
>> + * We may need to convert up to one extent per block in
>> + * the page and we may dirty the inode.
>> + */
>> + rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
>> + PAGE_SIZE >> inode->i_blkbits);
>> + }
>> +
>> if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
>> range_whole = 1;
>>
>> --
>> 2.7.4
>>
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-05 7:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 12:50 [PATCH] ext4: fix warning when turn on dioread_nolock and inline_data yangerkun
2019-07-04 14:55 ` Jan Kara
2019-07-05 7:52 ` yangerkun
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).