All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Namjae Jeon <namjae.jeon@samsung.com>,
	'Namjae Jeon' <linkinjeon@kernel.org>
Cc: 'linux-fsdevel' <linux-fsdevel@vger.kernel.org>,
	'Pavel Reichl' <preichl@redhat.com>,
	chritophe.vu-brugier@seagate.com,
	'Hyeoncheol Lee' <hyc.lee@gmail.com>
Subject: Re: problem with exfat on 4k logical sector devices
Date: Tue, 11 May 2021 18:57:22 -0500	[thread overview]
Message-ID: <b3015dc1-07a9-0c14-857a-9562a9007fb6@sandeen.net> (raw)
In-Reply-To: <001201d746c0$cc8da8e0$65a8faa0$@samsung.com>

On 5/11/21 6:53 PM, Namjae Jeon wrote:

>> One other thing that I ran across is that fsck seems to validate an image against the sector size of
>> the device hosting the image rather than the sector size found in the boot sector, which seems like
>> another issue that will come up:
>>
>> # fsck/fsck.exfat /dev/sdb
>> exfatprogs version : 1.1.1
>> /dev/sdb: clean. directories 1, files 0
>>
>> # dd if=/dev/sdb of=test.img
>> 524288+0 records in
>> 524288+0 records out
>> 268435456 bytes (268 MB) copied, 1.27619 s, 210 MB/s
>>
>> # fsck.exfat test.img
>> exfatprogs version : 1.1.1
>> checksum of boot region is not correct. 0, but expected 0x3ee721 boot region is corrupted. try to
>> restore the region from backup. Fix (y/N)? n
>>
>> Right now the utilities seem to assume that the device they're pointed at is always a block device,
>> and image files are problematic.
> Okay, Will fix it.

Right now I have a hack like this.

1) don't validate the in-image sector size against the host device size
(maybe should only skip this check if it's not a bdev? Or is it OK to have
a 4k sector size fs on a 512 device? Probably?)

2) populate the "bd" sector size information from the values read from the image.

It feels a bit messy, but it works so far. I guess the messiness stems from
assuming that we always have a "bd" block device.

-Eric

diff --git a/dump/dump.c b/dump/dump.c
index 85d5101..30ec8cb 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -100,6 +100,9 @@ static int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd)
 		goto free_ppbr;
 	}
 
+	bd->sector_size_bits = pbsx->sect_size_bits;
+	bd->sector_size = 1 << pbsx->sect_size_bits;
+
 	if (pbsx->sect_per_clus_bits > 25 - pbsx->sect_size_bits) {
 		exfat_err("bogus sectors bits per cluster : %u\n",
 				pbsx->sect_per_clus_bits);
@@ -107,13 +110,6 @@ static int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd)
 		goto free_ppbr;
 	}
 
-	if (bd->sector_size != 1 << pbsx->sect_size_bits) {
-		exfat_err("bogus sector size : %u (sector size bits : %u)\n",
-				bd->sector_size, pbsx->sect_size_bits);
-		ret = -EINVAL;
-		goto free_ppbr;
-	}
-
 	clu_offset = le32_to_cpu(pbsx->clu_offset);
 	total_clus = le32_to_cpu(pbsx->clu_count);
 	root_clu = le32_to_cpu(pbsx->root_cluster);
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 747a771..5ea8278 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -682,6 +682,9 @@ static int read_boot_region(struct exfat_blk_dev *bd, struct pbr **pbr,
 		goto err;
 	}
 
+	bd->sector_size_bits = bs->bsx.sect_size_bits;
+	bd->sector_size = 1 << bs->bsx.sect_size_bits;
+
 	ret = boot_region_checksum(bd, bs_offset);
 	if (ret < 0)
 		goto err;



  reply	other threads:[~2021-05-11 23:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 17:28 problem with exfat on 4k logical sector devices Eric Sandeen
2021-05-11 21:21 ` Namjae Jeon
2021-05-11 23:33   ` Eric Sandeen
2021-05-11 23:53     ` Namjae Jeon
2021-05-11 23:57       ` Eric Sandeen [this message]
2021-05-12 14:09         ` Hyunchul Lee
2021-05-12 16:44           ` Eric Sandeen
2021-05-12 17:56             ` Eric Sandeen
2021-05-13  6:53               ` Namjae Jeon
2021-05-13  6:52             ` Namjae Jeon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b3015dc1-07a9-0c14-857a-9562a9007fb6@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=chritophe.vu-brugier@seagate.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=namjae.jeon@samsung.com \
    --cc=preichl@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.