* [PATCH 2/3] ext4: remove incorrect check for inode journal mode in ext4_writepages()
2015-11-18 1:34 [PATCH 1/3] ext4: handle unwritten or delalloc buffers before enabling per-file data journaling Daeho Jeong
@ 2015-11-18 1:34 ` Daeho Jeong
2015-11-30 14:08 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Daeho Jeong @ 2015-11-18 1:34 UTC (permalink / raw)
To: tytso, linux-ext4, daeho.jeong
Now, in ext4, there is only one writepages() function and it is shared
by all the inode modes. Therefore, BUG_ON() for checking journaled
inode mode in ext4_writepages() is not correct anymore because, if
per-file data journaling of a file is enabled while ext4_writepages()
is being executed, this BUG_ON() function can cause a kernel panic
unintentionally even on "nodelalloc" mode.
Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
---
fs/ext4/inode.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 1f9458e..db24348 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2480,13 +2480,11 @@ retry:
}
/*
- * We have two constraints: We find one extent to map and we
+ * We have a constraint: We find one extent to map and we
* must always write out whole page (makes a difference when
* blocksize < pagesize) so that we don't block on IO when we
- * try to write out the rest of the page. Journalled mode is
- * not supported by delalloc.
+ * try to write out the rest of the page.
*/
- BUG_ON(ext4_should_journal_data(inode));
needed_blocks = ext4_da_writepages_trans_blocks(inode);
/* start a new transaction */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/3] ext4: remove incorrect check for inode journal mode in ext4_writepages()
2015-11-18 1:34 ` [PATCH 2/3] ext4: remove incorrect check for inode journal mode in ext4_writepages() Daeho Jeong
@ 2015-11-30 14:08 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2015-11-30 14:08 UTC (permalink / raw)
To: Daeho Jeong; +Cc: tytso, linux-ext4
On Wed 18-11-15 10:34:33, Daeho Jeong wrote:
> Now, in ext4, there is only one writepages() function and it is shared
> by all the inode modes. Therefore, BUG_ON() for checking journaled
> inode mode in ext4_writepages() is not correct anymore because, if
> per-file data journaling of a file is enabled while ext4_writepages()
> is being executed, this BUG_ON() function can cause a kernel panic
> unintentionally even on "nodelalloc" mode.
>
> Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
> ---
> fs/ext4/inode.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 1f9458e..db24348 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2480,13 +2480,11 @@ retry:
> }
>
> /*
> - * We have two constraints: We find one extent to map and we
> + * We have a constraint: We find one extent to map and we
> * must always write out whole page (makes a difference when
> * blocksize < pagesize) so that we don't block on IO when we
> - * try to write out the rest of the page. Journalled mode is
> - * not supported by delalloc.
> + * try to write out the rest of the page.
> */
Well, it is still true that journalled mode is not supported by delalloc so
I would not delete the comment.
Actually what you do only hides the real problem - that ext4_writepages()
in non-journalled mode can be still running for an inode which is already
switched to journalled mode. In theory if we manage to dirty some pages
after the switch, non-journalled writepages *can* see them an try to write
them back which will break spectacularly. So to fix this we need something
like a writeback barrier for the inode - make sure all ext4_writepages()
calls have completed before switching aops. Now I'd hate to grow struct
ext4_inode_info only for this extra rare case so we could probably
implement the barrier on per-filesystem basis - a fs-wide per-cpu rw
semaphore acquired for reading while ext4_writepages() runs and acquired
for writing when we switch aops for some inode.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/3] ext4: remove incorrect check for inode journal mode in ext4_writepages()
@ 2015-12-01 4:50 Daeho Jeong
0 siblings, 0 replies; 3+ messages in thread
From: Daeho Jeong @ 2015-12-01 4:50 UTC (permalink / raw)
To: Jan Kara
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org,
정대호
> Actually what you do only hides the real problem - that ext4_writepages()
> in non-journalled mode can be still running for an inode which is already
> switched to journalled mode. In theory if we manage to dirty some pages
> after the switch, non-journalled writepages *can* see them an try to write
> them back which will break spectacularly. So to fix this we need something
> like a writeback barrier for the inode - make sure all ext4_writepages()
> calls have completed before switching aops. Now I'd hate to grow struct
> ext4_inode_info only for this extra rare case so we could probably
> implement the barrier on per-filesystem basis - a fs-wide per-cpu rw
> semaphore acquired for reading while ext4_writepages() runs and acquired
> for writing when we switch aops for some inode.
Yes, there is another issue that newly dirtied pages after the switch can be
shown in ext4_writepages() in non-journalled mode. I overlooked that point.
According to your comment, I will modify this patch.
Thank you, again.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-01 4:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-01 4:50 [PATCH 2/3] ext4: remove incorrect check for inode journal mode in ext4_writepages() Daeho Jeong
-- strict thread matches above, loose matches on Subject: below --
2015-11-18 1:34 [PATCH 1/3] ext4: handle unwritten or delalloc buffers before enabling per-file data journaling Daeho Jeong
2015-11-18 1:34 ` [PATCH 2/3] ext4: remove incorrect check for inode journal mode in ext4_writepages() Daeho Jeong
2015-11-30 14:08 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox