]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
Btrfs: fix copy_items() return value when logging an inode
authorFilipe Manana <fdmanana@suse.com>
Mon, 26 Mar 2018 22:59:12 +0000 (23:59 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 27 Aug 2018 14:40:05 +0000 (16:40 +0200)
commitbb65067ecdc63f803947ca884406e52e29f65bb6
tree7bb0d417e1f1bd74a1137ba0443c78bd77e9dd3a
parent39acd60cc07bafb05f37a9468966114e65c5d71c
Btrfs: fix copy_items() return value when logging an inode

BugLink: http://bugs.launchpad.net/bugs/1786352
[ Upstream commit 8434ec46c6e3232cebc25a910363b29f5c617820 ]

When logging an inode, at tree-log.c:copy_items(), if we call
btrfs_next_leaf() at the loop which checks for the need to log holes, we
need to make sure copy_items() returns the value 1 to its caller and
not 0 (on success). This is because the path the caller passed was
released and is now different from what is was before, and the caller
expects a return value of 0 to mean both success and that the path
has not changed, while a return value of 1 means both success and
signals the caller that it can not reuse the path, it has to perform
another tree search.

Even though this is a case that should not be triggered on normal
circumstances or very rare at least, its consequences can be very
unpredictable (especially when replaying a log tree).

Fixes: 16e7549f045d ("Btrfs: incompatible format change to remove hole extents")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/tree-log.c