Re: [PATCH v2 2/2] udf: support 2048-byte spacing of VRS descriptors on 4K media

From: Jan Kara
Date: Thu Jul 11 2019 - 11:12:44 EST


On Thu 11-07-19 08:38:52, Steven J. Magnani wrote:
> Some UDF creators (specifically Microsoft, but perhaps others) mishandle
> the ECMA-167 corner case that requires descriptors within a Volume
> Recognition Sequence to be placed at 4096-byte intervals on media where
> the block size is 4K. Instead, the descriptors are placed at the 2048-
> byte interval mandated for media with smaller blocks. This nonconformity
> currently prevents Linux from recognizing the filesystem as UDF.
>
> Modify the driver to tolerate a misformatted VRS on 4K media.
>
> Signed-off-by: Steven J. Magnani <steve@xxxxxxxxxxxxxxx>

Thanks for the patches! I've added them to my tree and somewhat simplified
the logic since we don't really care about nsr 2 vs 3 or whether we
actually saw BEA or not. Everything seems to work fine for me but I'd
appreciate if you could doublecheck - the result is pushed out to

git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git for_next

Thanks!

Honza
>
> --- a/fs/udf/super.c 2019-07-10 20:55:33.334359446 -0500
> +++ b/fs/udf/super.c 2019-07-10 21:20:58.138382326 -0500
> @@ -741,6 +741,7 @@ static int udf_check_vsd(struct super_bl
> int sectorsize;
> struct buffer_head *bh = NULL;
> int nsr = 0;
> + int quirk_nsr = 0;
> struct udf_sb_info *sbi;
>
> sbi = UDF_SB(sb);
> @@ -780,11 +781,27 @@ static int udf_check_vsd(struct super_bl
> if (vsd_id > nsr)
> nsr = vsd_id;
>
> + /* Special handling for improperly formatted VRS (e.g., Win10)
> + * where components are separated by 2048 bytes
> + * even though sectors are 4K
> + */
> + if ((sb->s_blocksize == 4096) && (quirk_nsr < 2)) {
> + vsd_id = identify_vsd(vsd + 1);
> + if ((nsr == 1) || (quirk_nsr == 1)) {
> + /* BEA01 has been seen, allow quirk NSR */
> + if (vsd_id > quirk_nsr)
> + quirk_nsr = vsd_id;
> + } else if (vsd_id > 3)
> + quirk_nsr = vsd_id; /* 0 -> 255 */
> + }
> +
> brelse(bh);
> }
>
> if ((nsr >= 2) && (nsr <= 3))
> return nsr;
> + else if ((quirk_nsr >= 2) && (quirk_nsr <= 3))
> + return quirk_nsr;
> else if (!bh && sector - (sbi->s_session << sb->s_blocksize_bits) ==
> VSD_FIRST_SECTOR_OFFSET)
> return -1;
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR