gfs2: More gfs2_find_jhead fixes
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 27 Apr 2020 23:15:41 +0000 (01:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 May 2020 06:20:22 +0000 (08:20 +0200)
commitf256dea077747840a6738533f917dcd1a818eed3
tree50c0bddc3cbdfe51f0f085baf0ff4460bef132ac
parent18541e49f70bb7dfdb74f4da04697465aae4d2b3
gfs2: More gfs2_find_jhead fixes

[ Upstream commit aa83da7f47b26c9587bade6c4bc4736ffa308f0a ]

It turns out that when extending an existing bio, gfs2_find_jhead fails to
check if the block number is consecutive, which leads to incorrect reads for
fragmented journals.

In addition, limit the maximum bio size to an arbitrary value of 2 megabytes:
since commit 07173c3ec276 ("block: enable multipage bvecs"), if we just keep
adding pages until bio_add_page fails, bios will grow much larger than useful,
which pins more memory than necessary with barely any additional performance
gains.

Fixes: f4686c26ecc3 ("gfs2: read journal in large chunks")
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/gfs2/lops.c