]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gfs2: Truncate address space when flipping GFS2_DIF_JDATA flag
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 13 Jan 2025 18:31:28 +0000 (19:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Feb 2025 17:22:32 +0000 (18:22 +0100)
commit 7c9d9223802fbed4dee1ae301661bf346964c9d2 upstream.

Truncate an inode's address space when flipping the GFS2_DIF_JDATA flag:
depending on that flag, the pages in the address space will either use
buffer heads or iomap_folio_state structs, and we cannot mix the two.

Reported-by: Kun Hu <huk23@m.fudan.edu.cn>, Jiaji Qin <jjtan24@m.fudan.edu.cn>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/gfs2/file.c

index 55a8eb3c196341ebfca0cde0aa443d76b55f8dc9..5e2fe456ed922768fd0eb208d93d9dcbf9fbf628 100644 (file)
@@ -271,6 +271,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask,
                error = filemap_fdatawait(inode->i_mapping);
                if (error)
                        goto out;
+               truncate_inode_pages(inode->i_mapping, 0);
                if (new_flags & GFS2_DIF_JDATA)
                        gfs2_ordered_del_inode(ip);
        }