* [PATCH] ext4: Unmap metadata when zeroing blocks
@ 2016-09-27 16:15 Jan Kara
2016-09-29 13:14 ` Lukas Czerner
2016-09-30 6:03 ` Theodore Ts'o
0 siblings, 2 replies; 4+ messages in thread
From: Jan Kara @ 2016-09-27 16:15 UTC (permalink / raw
To: Ted Tso; +Cc: linux-ext4, Jan Kara
When zeroing blocks for DAX allocations, we also have to unmap aliases
in the block device mappings. Otherwise writeback can overwrite zeros
with stale data from block device page cache.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
Ted, can you merge this patch please? It's a data corruption issue for DAX.
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c6ea25a190f8..87150122d361 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -647,11 +647,19 @@ found:
/*
* We have to zeroout blocks before inserting them into extent
* status tree. Otherwise someone could look them up there and
- * use them before they are really zeroed.
+ * use them before they are really zeroed. We also have to
+ * unmap metadata before zeroing as otherwise writeback can
+ * overwrite zeros with stale data from block device.
*/
if (flags & EXT4_GET_BLOCKS_ZERO &&
map->m_flags & EXT4_MAP_MAPPED &&
map->m_flags & EXT4_MAP_NEW) {
+ ext4_lblk_t i;
+
+ for (i = 0; i < map->m_len; i++) {
+ unmap_underlying_metadata(inode->i_sb->s_bdev,
+ map->m_pblk + i);
+ }
ret = ext4_issue_zeroout(inode, map->m_lblk,
map->m_pblk, map->m_len);
if (ret) {
--
2.6.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Unmap metadata when zeroing blocks
2016-09-27 16:15 [PATCH] ext4: Unmap metadata when zeroing blocks Jan Kara
@ 2016-09-29 13:14 ` Lukas Czerner
2016-10-03 7:18 ` Jan Kara
2016-09-30 6:03 ` Theodore Ts'o
1 sibling, 1 reply; 4+ messages in thread
From: Lukas Czerner @ 2016-09-29 13:14 UTC (permalink / raw
To: Jan Kara; +Cc: Ted Tso, linux-ext4
Hi Jan,
do we have a xfstest case for this particular problem ?
Thanks!
-Lukas
On Tue, Sep 27, 2016 at 06:15:18PM +0200, Jan Kara wrote:
> When zeroing blocks for DAX allocations, we also have to unmap aliases
> in the block device mappings. Otherwise writeback can overwrite zeros
> with stale data from block device page cache.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/ext4/inode.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> Ted, can you merge this patch please? It's a data corruption issue for DAX.
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index c6ea25a190f8..87150122d361 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -647,11 +647,19 @@ found:
> /*
> * We have to zeroout blocks before inserting them into extent
> * status tree. Otherwise someone could look them up there and
> - * use them before they are really zeroed.
> + * use them before they are really zeroed. We also have to
> + * unmap metadata before zeroing as otherwise writeback can
> + * overwrite zeros with stale data from block device.
> */
> if (flags & EXT4_GET_BLOCKS_ZERO &&
> map->m_flags & EXT4_MAP_MAPPED &&
> map->m_flags & EXT4_MAP_NEW) {
> + ext4_lblk_t i;
> +
> + for (i = 0; i < map->m_len; i++) {
> + unmap_underlying_metadata(inode->i_sb->s_bdev,
> + map->m_pblk + i);
> + }
> ret = ext4_issue_zeroout(inode, map->m_lblk,
> map->m_pblk, map->m_len);
> if (ret) {
> --
> 2.6.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Unmap metadata when zeroing blocks
2016-09-27 16:15 [PATCH] ext4: Unmap metadata when zeroing blocks Jan Kara
2016-09-29 13:14 ` Lukas Czerner
@ 2016-09-30 6:03 ` Theodore Ts'o
1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2016-09-30 6:03 UTC (permalink / raw
To: Jan Kara; +Cc: linux-ext4
On Tue, Sep 27, 2016 at 06:15:18PM +0200, Jan Kara wrote:
> When zeroing blocks for DAX allocations, we also have to unmap aliases
> in the block device mappings. Otherwise writeback can overwrite zeros
> with stale data from block device page cache.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: Unmap metadata when zeroing blocks
2016-09-29 13:14 ` Lukas Czerner
@ 2016-10-03 7:18 ` Jan Kara
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2016-10-03 7:18 UTC (permalink / raw
To: Lukas Czerner; +Cc: Jan Kara, Ted Tso, linux-ext4
Hi,
On Thu 29-09-16 15:14:57, Lukas Czerner wrote:
> do we have a xfstest case for this particular problem ?
Not specifically, but some of the existing xfstests did trigger this
problem for me which is how I found it out...
Honza
> On Tue, Sep 27, 2016 at 06:15:18PM +0200, Jan Kara wrote:
> > When zeroing blocks for DAX allocations, we also have to unmap aliases
> > in the block device mappings. Otherwise writeback can overwrite zeros
> > with stale data from block device page cache.
> >
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> > fs/ext4/inode.c | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > Ted, can you merge this patch please? It's a data corruption issue for DAX.
> >
> > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> > index c6ea25a190f8..87150122d361 100644
> > --- a/fs/ext4/inode.c
> > +++ b/fs/ext4/inode.c
> > @@ -647,11 +647,19 @@ found:
> > /*
> > * We have to zeroout blocks before inserting them into extent
> > * status tree. Otherwise someone could look them up there and
> > - * use them before they are really zeroed.
> > + * use them before they are really zeroed. We also have to
> > + * unmap metadata before zeroing as otherwise writeback can
> > + * overwrite zeros with stale data from block device.
> > */
> > if (flags & EXT4_GET_BLOCKS_ZERO &&
> > map->m_flags & EXT4_MAP_MAPPED &&
> > map->m_flags & EXT4_MAP_NEW) {
> > + ext4_lblk_t i;
> > +
> > + for (i = 0; i < map->m_len; i++) {
> > + unmap_underlying_metadata(inode->i_sb->s_bdev,
> > + map->m_pblk + i);
> > + }
> > ret = ext4_issue_zeroout(inode, map->m_lblk,
> > map->m_pblk, map->m_len);
> > if (ret) {
> > --
> > 2.6.6
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-03 7:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-27 16:15 [PATCH] ext4: Unmap metadata when zeroing blocks Jan Kara
2016-09-29 13:14 ` Lukas Czerner
2016-10-03 7:18 ` Jan Kara
2016-09-30 6:03 ` Theodore Ts'o
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.