* [REVIEW] Fix end of device zeroing with > 1K sector sizes
@ 2008-02-22 3:56 Barry Naujok
2008-02-22 4:13 ` Eric Sandeen
0 siblings, 1 reply; 2+ messages in thread
From: Barry Naujok @ 2008-02-22 3:56 UTC (permalink / raw)
To: xfs@oss.sgi.com
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
It has been found that mkfs with big sector sizes and devices/partitions
that aren't aligned to the sector size can cause short writes when zeroing
the end of the device. As mkfs.xfs didn't complete, the filesystem is
unmountable.
Eg:
# mkfs.xfs -f -L fs_1 -s size=4096 -l size=64m,sunit=512 /dev/hdd1
mkfs.xfs: error - wrote only 130048 of 131072 bytes
The attached patch rounds down the device size to either 1K or
the sector size, whichever is greater.
Barry.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix_eodev_zeroing.patch --]
[-- Type: text/x-patch; name=fix_eodev_zeroing.patch, Size: 1248 bytes --]
--- a/xfsprogs/mkfs/xfs_mkfs.c 2008-02-22 14:48:27.000000000 +1100
+++ b/xfsprogs/mkfs/xfs_mkfs.c 2008-02-22 14:41:38.093984235 +1100
@@ -703,6 +703,7 @@ main(
int sectoralign;
int sectorlog;
unsigned int sectorsize;
+ __uint64_t sector_mask;
int slflag;
int ssflag;
__uint64_t tmp_agsize;
@@ -1637,12 +1638,18 @@ main(
* Ok, Linux only has a 1024-byte resolution on device _size_,
* and the sizes below are in basic 512-byte blocks,
* so if we have (size % 2), on any partition, we can't get
- * to the last 512 bytes. Just chop it down by a block.
+ * to the last 512 bytes. The same issue exists for larger
+ * sector sizes - we cannot write past the last sector.
+ *
+ * So, we reduce the size (in basic blocks) to a perfect
+ * multiple of the sector size, or 1024, whichever is larger.
*/
- xi.dsize -= (xi.dsize % 2);
- xi.rtsize -= (xi.rtsize % 2);
- xi.logBBsize -= (xi.logBBsize % 2);
+ sector_mask = xfs_mask64hi((sectorlog < 10 ? 10 : sectorlog) - BBSHIFT);
+ xi.dsize &= sector_mask;
+ xi.rtsize &= sector_mask;
+ xi.logBBsize &= xfs_mask64hi((lsectorlog < 10 ? 10 : lsectorlog) -
+ BBSHIFT);
if (!force_overwrite) {
if (check_overwrite(dfile) ||
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [REVIEW] Fix end of device zeroing with > 1K sector sizes
2008-02-22 3:56 [REVIEW] Fix end of device zeroing with > 1K sector sizes Barry Naujok
@ 2008-02-22 4:13 ` Eric Sandeen
0 siblings, 0 replies; 2+ messages in thread
From: Eric Sandeen @ 2008-02-22 4:13 UTC (permalink / raw)
To: Barry Naujok; +Cc: xfs@oss.sgi.com
Barry Naujok wrote:
> It has been found that mkfs with big sector sizes and devices/partitions
> that aren't aligned to the sector size can cause short writes when zeroing
> the end of the device. As mkfs.xfs didn't complete, the filesystem is
> unmountable.
>
> Eg:
>
> # mkfs.xfs -f -L fs_1 -s size=4096 -l size=64m,sunit=512 /dev/hdd1
> mkfs.xfs: error - wrote only 130048 of 131072 bytes
>
>
> The attached patch rounds down the device size to either 1K or
> the sector size, whichever is greater.
Hopefully to a multiple thereof ;)
Looks good to me... and strangely familiar!
-Eric
> Barry.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-22 4:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-22 3:56 [REVIEW] Fix end of device zeroing with > 1K sector sizes Barry Naujok
2008-02-22 4:13 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox