Re: Kernels v4.9+ cause short reads of block devices

From: Doug Nazar
Date: Thu Aug 24 2017 - 06:03:51 EST


On 8/23/17 4:13 PM, Linus Torvalds wrote:

Oh, right you are - I'm much too used to 64-bit, where
MAX_LFS_FILESIZE is basically infinite, and was jusr assuming that it
was something like the UFS bug we had not that long ago that was due
to the 32-bit limit.

But yes, on 32-bit, we are limited by the 32-bit index into the page
cache, and we limit the index to 31 bits too, so we have (PAGE_SIZE <<
31) -1, which is that 7ffffffffff.

Yeah, it's an old organically grown storage server (install images, old vms, etc.) that
I can't convince myself it's worth upgrading.

The *right* patch is likely to just this instead:

-#define MAX_LFS_FILESIZE (((loff_t)PAGE_SIZE << (BITS_PER_LONG-1))-1)
+#define MAX_LFS_FILESIZE (((loff_t)PAGE_SIZE <<
BITS_PER_LONG)-PAGE_SIZE)

which should make MAX_LFS_FILESIZE be 0xffffffff000 and you disk size
should be ok.

That solves my issue. I'm curious if that check should also be in the write path. If the
check had been there too I wouldn't have ended up with any corruption.

I'm not sure if anything over 16TB will create/assemble (or if anybody else is crazy like me).

Doug