ext4: fix ZERO_RANGE test failure in data journalling mode
PATCH 2/3 ext4: fix ZERO_RANGE test failure in data journalling mode
From: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call ext4_force_commit as collapse range.
--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ext4/extents.c +7 -0
@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode); +/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + } +/* * Write out all dirty pages to avoid race conditions * Then release them.
Signature · 1 line
1.7.11-rc0
Quoted 26 lines · Namjae Jeon
Date: Thu, 17 Apr 2014 07:29:18 +0900
From: Namjae Jeon <[email protected]>
To: Theodore Ts'o <[email protected]>
Cc: linux-ext4 <[email protected]>,
Lukáš Czerner <[email protected]>
Subject: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeFrom: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call
ext4_force_commitas collapse range.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/ext4/extents.c +0
-0
fs/ext4/extents.c static long ext4_zero_range(struct file *file, loff_t offset, · line 4750
Quoted 9 lines
fs/ext4/extents.c +6
-0@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode); +/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + }
Hi,
it makes sense. But I have a question, maybe I do not understand it correctly but what protect us from other writes coming in after we force the commit ?
-Lukas
Quoted 5 lines
fs/ext4/extents.c +1
-0+/* * Write out all dirty pages to avoid race conditions * Then release them.
Quoted 32 lines · Namjae Jeon
Quoted 30 lines
Date: Thu, 17 Apr 2014 07:29:18 +0900
From: Namjae Jeon <[email protected]>
To: Theodore Ts'o <[email protected]>
Cc: linux-ext4 <[email protected]>,
Lukáš Czerner <[email protected]>
Subject: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeFrom: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call
ext4_force_commitas collapse range.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/ext4/extents.c +0
-0@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode);
Quoted 8 lines
fs/ext4/extents.c static long ext4_zero_range(struct file *file, loff_t offset, · line 4750
Quoted 6 lines
fs/ext4/extents.c +6
-0+/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + }Hi,
Hi Lukas.
Quoted 4 lines
it makes sense. But I have a question, maybe I do not understand it correctly but what protect us from other writes coming in after we force the commit ?
Yes, Currently new write can come between ext4_force_commit and till we acquire mutex_lock. But this window is already present even without patch. Its just that in case of data=journal mode, this window will become slightly bigger. one possible solution coming to my mind is one more time calling ext4_force_commit followed by a call to filemap_write_and_wait_range inside mutex_lock which would sync data that has dirtied after 1st call.
Thanks!
Quoted 8 lines
-Lukas
Quoted 5 lines
fs/ext4/extents.c +1
-0+/* * Write out all dirty pages to avoid race conditions * Then release them.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 52 lines · Namjae Jeon
Date: Thu, 17 Apr 2014 19:52:09 +0900
From: Namjae Jeon <[email protected]>
To: 'Lukáš Czerner' <[email protected]>
Cc: 'Theodore Ts'o' <[email protected]>, 'linux-ext4' <[email protected]>
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeQuoted 32 lines · Namjae Jeon
Quoted 30 lines
Date: Thu, 17 Apr 2014 07:29:18 +0900
From: Namjae Jeon <[email protected]>
To: Theodore Ts'o <[email protected]>
Cc: linux-ext4 <[email protected]>,
Lukáš Czerner <[email protected]>
Subject: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeFrom: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call
ext4_force_commitas collapse range.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/ext4/extents.c +0
-0@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode);Quoted 8 lines
fs/ext4/extents.c static long ext4_zero_range(struct file *file, loff_t offset, · line 4750
Quoted 6 lines
fs/ext4/extents.c +6
-0+/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + }Hi,
Hi Lukas.
Quoted 4 lines
it makes sense. But I have a question, maybe I do not understand it correctly but what protect us from other writes coming in after we force the commit ?
Quoted 7 lines
Yes, Currently new write can come between
ext4_force_commitand till we acquiremutex_lock. But this window is already present even without patch. Its just that in case of data=journal mode, this window will become slightly bigger. one possible solution coming to my mind is one more time callingext4_force_commitfollowed by a call tofilemap_write_and_wait_rangeinsidemutex_lockwhich would sync data that has dirtied after 1st call.
Can we really call ext4_force_commit() inside mutex_lock ?
-Lukas
Quoted 12 lines
Thanks!
Quoted 8 lines
-Lukas
Quoted 5 lines
fs/ext4/extents.c +1
-0+/* * Write out all dirty pages to avoid race conditions * Then release them.
Quoted 63 lines · Namjae Jeon
Quoted 53 lines
Date: Thu, 17 Apr 2014 19:52:09 +0900
From: Namjae Jeon <[email protected]>
To: 'Lukáš Czerner' <[email protected]>
Cc: 'Theodore Ts'o' <[email protected]>, 'linux-ext4' <[email protected]>
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeQuoted 32 lines · Namjae Jeon
Quoted 30 lines
Date: Thu, 17 Apr 2014 07:29:18 +0900
From: Namjae Jeon <[email protected]>
To: Theodore Ts'o <[email protected]>
Cc: linux-ext4 <[email protected]>,
Lukáš Czerner <[email protected]>
Subject: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeFrom: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call
ext4_force_commitas collapse range.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/ext4/extents.c +0
-0@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode);Quoted 8 lines
fs/ext4/extents.c static long ext4_zero_range(struct file *file, loff_t offset, · line 4750
Quoted 6 lines
fs/ext4/extents.c +6
-0+/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + }Hi,
Hi Lukas.
Quoted 4 lines
it makes sense. But I have a question, maybe I do not understand it correctly but what protect us from other writes coming in after we force the commit ?
Quoted 7 lines
Yes, Currently new write can come between
ext4_force_commitand till we acquiremutex_lock. But this window is already present even without patch. Its just that in case of data=journal mode, this window will become slightly bigger. one possible solution coming to my mind is one more time callingext4_force_commitfollowed by a call tofilemap_write_and_wait_rangeinsidemutex_lockwhich would sync data that has dirtied after 1st call.
Quoted 1 line
Can we really call
ext4_force_commit()insidemutex_lock?
Yes, I can see ext4_force_commit inside mutex_lock in ext4_sync_file().
Quoted 15 lines
-Lukas
Quoted 12 lines
Thanks!
Quoted 8 lines
-Lukas
Quoted 5 lines
fs/ext4/extents.c +1
-0+/* * Write out all dirty pages to avoid race conditions * Then release them.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 70 lines · Namjae Jeon
Date: Thu, 17 Apr 2014 21:01:25 +0900
From: Namjae Jeon <[email protected]>
To: 'Lukáš Czerner' <[email protected]>
Cc: 'Theodore Ts'o' <[email protected]>, 'linux-ext4' <[email protected]>
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeQuoted 63 lines · Namjae Jeon
Quoted 60 lines
Date: Thu, 17 Apr 2014 19:52:09 +0900
From: Namjae Jeon <[email protected]>
To: 'Lukáš Czerner' <[email protected]>
Cc: 'Theodore Ts'o' <[email protected]>, 'linux-ext4' <[email protected]>
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeQuoted 32 lines · Namjae Jeon
Quoted 30 lines
Date: Thu, 17 Apr 2014 07:29:18 +0900
From: Namjae Jeon <[email protected]>
To: Theodore Ts'o <[email protected]>
Cc: linux-ext4 <[email protected]>,
Lukáš Czerner <[email protected]>
Subject: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeFrom: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call
ext4_force_commitas collapse range.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/ext4/extents.c +0
-0@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode);Quoted 8 lines
fs/ext4/extents.c static long ext4_zero_range(struct file *file, loff_t offset, · line 4750
Quoted 6 lines
fs/ext4/extents.c +6
-0+/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + }Hi,
Hi Lukas.
Quoted 4 lines
it makes sense. But I have a question, maybe I do not understand it correctly but what protect us from other writes coming in after we force the commit ?
Yes, Currently new write can come between
ext4_force_commitand till we acquiremutex_lock. But this window is already present even without patch. Its just that in case of data=journal mode, this window will become slightly bigger. one possible solution coming to my mind is one more time callingext4_force_commitfollowed by a call tofilemap_write_and_wait_rangeinsidemutex_lockwhich would sync data that has dirtied after 1st call.
Quoted 2 lines
Quoted 1 line
Can we really call
ext4_force_commit()insidemutex_lock?Yes, I can see
ext4_force_commitinsidemutex_lockinext4_sync_file().
There might be some misunderstanding, are we talking about inode->i_mutex because that is certainly not held in ext4_sync_file() or am I missing something ?
-Lukas
Quoted 18 lines
Quoted 16 lines
-Lukas
Quoted 12 lines
Thanks!
Quoted 8 lines
-Lukas
Quoted 5 lines
fs/ext4/extents.c +1
-0+/* * Write out all dirty pages to avoid race conditions * Then release them.
Quoted 81 lines
-----Original Message-----
From: Lukáš Czerner [mailto:[email protected]]
Sent: Thursday, April 17, 2014 9:16 PM
To: Namjae Jeon
Cc: 'Theodore Ts'o'; 'linux-ext4'
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling modeQuoted 70 lines · Namjae Jeon
Date: Thu, 17 Apr 2014 21:01:25 +0900
From: Namjae Jeon <[email protected]>
To: 'Lukáš Czerner' <[email protected]>
Cc: 'Theodore Ts'o' <[email protected]>, 'linux-ext4' <[email protected]>
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeQuoted 63 lines · Namjae Jeon
Quoted 60 lines
Date: Thu, 17 Apr 2014 19:52:09 +0900
From: Namjae Jeon <[email protected]>
To: 'Lukáš Czerner' <[email protected]>
Cc: 'Theodore Ts'o' <[email protected]>, 'linux-ext4' <[email protected]>
Subject: RE: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeQuoted 32 lines · Namjae Jeon
Quoted 30 lines
Date: Thu, 17 Apr 2014 07:29:18 +0900
From: Namjae Jeon <[email protected]>
To: Theodore Ts'o <[email protected]>
Cc: linux-ext4 <[email protected]>,
Lukáš Czerner <[email protected]>
Subject: [PATCH 2/3] ext4: fixZERO_RANGEtest failure in data journalling
modeFrom: Namjae Jeon <[email protected]>
xfstests generic/091 is failing when mounting ext4 with data=journal. I think that this regression is same problem that occurred prior to collapse range issue. So ZERO RANGE also need to call
ext4_force_commitas collapse range.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>--- fs/ext4/extents.c | 7 +++++++ 1 file changed, 7 insertions(+)fs/ext4/extents.c +0
-0@@ -4742,6 +4742,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,trace_ext4_zero_range (inode, offset, len, mode);Quoted 8 lines
fs/ext4/extents.c static long ext4_zero_range(struct file *file, loff_t offset, · line 4750
Quoted 6 lines
fs/ext4/extents.c +6
-0+/* Call ext4_force_commit to flush all data in case of data=journal. */ +if (ext4_should_journal_data (inode)) { + ret =ext4_force_commit (inode->i_sb); +if (ret) +return ret; + }Hi,
Hi Lukas.
Quoted 4 lines
it makes sense. But I have a question, maybe I do not understand it correctly but what protect us from other writes coming in after we force the commit ?
Yes, Currently new write can come between
ext4_force_commitand till we acquiremutex_lock. But this window is already present even without patch. Its just that in case of data=journal mode, this window will become slightly bigger. one possible solution coming to my mind is one more time callingext4_force_commitfollowed by a call tofilemap_write_and_wait_rangeinsidemutex_lockwhich would sync data that has dirtied after 1st call.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Can we really call
ext4_force_commit()insidemutex_lock?Yes, I can see
ext4_force_commitinsidemutex_lockinext4_sync_file().There might be some misunderstanding, are we talking about
inode->i_mutexbecause that is certainly not held inext4_sync_file()or am I missing something ?
Ah. Sorry, I checked old kernel source(v3.10)i_mutex was removed from ext4_sync_file by Jan.
But that does not mean we can't call ext4_force_commit from within i_mutex.
Hi Jan.
Am I missing something ?
Thanks.
Quoted 21 lines
-Lukas
Quoted 18 lines
Quoted 16 lines
-Lukas
Quoted 12 lines
Thanks!
Quoted 8 lines
-Lukas
Quoted 5 lines
fs/ext4/extents.c +1
-0+/* * Write out all dirty pages to avoid race conditions * Then release them.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Theodore Ts'o
maintainerSo a couple of things. First of all, ext4_force_commit() is a very expensive call, so calling it twice is really not a good idea.
Secondly, in the ext4_collapse_range() you are calling ext4_force_commit() before filemap_write_and_wait_range().
/* Call ext4_force_commit to flush all data in case of data=journal. */
if (ext4_should_journal_data(inode)) {
ret = ext4_force_commit(inode->i_sb);
if (ret)
return ret;
}
/* Write out all dirty pages */
ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1);
if (ret)
return ret;Shouldn't we reverse these two calls?
Finally, I'm wondering if we would be better off creating a new explicit EXT4_I(inode)->i_write_mutex which is used to block new writes from starting. This could also be used to subsume the ext4_aio_mutex.
- Ted
Quoted 26 lines · Theodore Ts'o
Date: Fri, 18 Apr 2014 10:37:11 -0400
From: Theodore Ts'o <[email protected]>
To: Namjae Jeon <[email protected]>
Cc: 'Lukáš Czerner' <[email protected]>, 'Jan Kara' <[email protected]>,'linux-ext4' <[email protected]>Subject: Re: [PATCH 2/3] ext4: fix
ZERO_RANGEtest failure in data journalling
modeSo a couple of things. First of all,
ext4_force_commit()is a very expensive call, so calling it twice is really not a good idea.Secondly, in the
ext4_collapse_range()you are callingext4_force_commit()beforefilemap_write_and_wait_range()./* Call ext4_force_commit to flush all data in case of data=journal. */ if (ext4_should_journal_data(inode)) { ret = ext4_force_commit(inode->i_sb); if (ret) return ret; } /* Write out all dirty pages */ ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1); if (ret) return ret;
Quoted 6 lines
Shouldn't we reverse these two calls?
Finally, I'm wondering if we would be better off creating a new explicit EXT4_I(inode)->i_write_mutex which is used to block new writes from starting. This could also be used to subsume the
ext4_aio_mutex.
We can maybe use something similar xfs has with their XFS_IOLOCK
-Lukas
Quoted 2 lines
- Ted
Quoted 2 lines
So a couple of things. First of all,
ext4_force_commit()is a very expensive call, so calling it twice is really not a good idea.
Yes, Right.
Quoted 16 lines
Secondly, in the
ext4_collapse_range()you are callingext4_force_commit()beforefilemap_write_and_wait_range()./* Call ext4_force_commit to flush all data in case of data=journal. */ if (ext4_should_journal_data(inode)) { ret = ext4_force_commit(inode->i_sb); if (ret) return ret; } /* Write out all dirty pages */ ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1); if (ret) return ret;
Quoted 1 line
Shouldn't we reverse these two calls?
Yes, The original problem will occur again if we reverse these calls. ext4_force_commit will mark the buffers as dirty during commit transcation. So we should sync it using filemap_write_and_wait_range later.
Quoted 5 lines
Finally, I'm wondering if we would be better off creating a new explicit EXT4_I(inode)->i_write_mutex which is used to block new writes from starting. This could also be used to subsume the
ext4_aio_mutex.
Right. It is better method. I will check your point. :)
Thanks Ted!!
Quoted 2 lines
- Ted