[PATCH] libblkid: (xfs) external log: check for regular xfs on more sectors

The xfs external log probe only checks for regular xfs on sector zero,
but then checks for valid log record headers on all first 512 sectors.

This can incorrectly detect an xfs external log if a regular xfs (i.e.
with internal log) is shifted by up to 512 sectors; it may happen with
bcache and LVM1 for example, as the regular xfs is found later in disk.

This results in ambivalent filesystem detection, thus no UUID for udev.

Fix this problem by checking for regular xfs on all sectors considered
by the xfs external log probe.

Test-case with bcache:

Gbp-Pq: Name libblkid-xfs-log-check-for-reg-xfs-on-more-sectors.patch
This commit is contained in:
Mauricio Faria de Oliveira 2020-01-07 18:53:51 -03:00 committed by openKylinBot
parent 8de924cffc
commit 38aa4e64b8
1 changed files with 4 additions and 3 deletions

View File

@ -252,11 +252,12 @@ static int probe_xfs_log(blkid_probe pr,
if (!buf)
return errno ? -errno : 1;
if (memcmp(buf, "XFSB", 4) == 0)
return 1; /* this is regular XFS, ignore */
/* check the first 512 512-byte sectors */
for (i = 0; i < 512; i++) {
/* this is regular XFS (maybe with some sectors shift), ignore */
if (memcmp(&buf[i*512], "XFSB", 4) == 0)
return 1;
rhead = (struct xlog_rec_header *)&buf[i*512];
if (xlog_valid_rec_header(rhead)) {