]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
libxfs: always initialize internal buffer map
authorDarrick J. Wong <djwong@kernel.org>
Mon, 31 Jan 2022 22:46:05 +0000 (17:46 -0500)
committerEric Sandeen <sandeen@redhat.com>
Mon, 31 Jan 2022 22:46:05 +0000 (17:46 -0500)
commitf043c63e38c9582deac85053a6c8a737482983b1
treecd819e14b3af1ba2aeefeb559fab0ac31c6d64f0
parente42c53f3d72da12da46bd3d264e14fb8b432f68d
libxfs: always initialize internal buffer map

The __initbuf function is responsible for initializing the fields of an
xfs_buf.  Buffers are always required to have a mapping, though in the
typical case there's only one mapping, so we can use the internal one.

The single-mapping b_maps init code at the end of the function doesn't
quite get this right though -- if a single-mapping buffer in the cache
was allowed to expire and now is being repurposed, it'll come out with
b_maps == &__b_map, in which case we incorrectly skip initializing the
map.  This has gone unnoticed until now because (AFAICT) the code paths
that use b_maps are the same ones that are called with multi-mapping
buffers, which are initialized correctly.

Anyway, the improperly initialized single-mappings will cause problems
in upcoming patches where we turn b_bn into the cache key and require
the use of b_maps[0].bm_bn for the buffer LBA.  Fix this.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/rdwr.c