Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932640AbdHWTx5 (ORCPT ); Wed, 23 Aug 2017 15:53:57 -0400 Received: from wdc011.relay.arandomserver.com ([208.43.115.130]:55654 "EHLO wdc011.relay.arandomserver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932531AbdHWTxz (ORCPT ); Wed, 23 Aug 2017 15:53:55 -0400 X-Greylist: delayed 2313 seconds by postgrey-1.27 at vger.kernel.org; Wed, 23 Aug 2017 15:53:55 EDT Subject: Re: Kernels v4.9+ cause short reads of block devices To: Linus Torvalds , Al Viro Cc: Linux Kernel Mailing List , Wei Fang , linux-fsdevel References: <1ae53e17-e455-4f17-0280-b0dae183a449@nazar.ca> From: Doug Nazar Message-ID: Date: Wed, 23 Aug 2017 15:53:44 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Thunderbird/54.0a2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: 173.192.232.254 X-SpamExperts-Domain: wdc006.hawkhost.com X-SpamExperts-Username: relay Authentication-Results: arandomserver.com; auth=pass (login) smtp.auth=relay@wdc006.hawkhost.com X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.02) X-Recommended-Action: accept X-Filter-ID: PqwsvolAWURa0gwxuN3S5YEa3T7JuZT23fGO2rGt3ZiXrQymdGY8qNmNJwTfl2xJ192kNgbkumUo HMCUQ8HXGkAwPN4M+BNtq20Hh3O6Az8x54JCQSpSh9ixc9o3H3wVCZryIsNFvaBrlzs70sT7iKmx j3Zz/WM/IwRyPjIHIwBwG0YNbzEmaSKSjgh8RBin/Dl/jJx0k76Rt87AzywMoh5e973vehgRRMJd d1x498S74wSyuIO3aP1OlGnjG3GEK7n9JUG0tkF/jEO0NY30aYoNYUbVrTtEe3GW4LV9k5TlgTl6 fJxyntEfhZCKje4ZEejqcvF9whXmqNO3rZfNMqIdXj9EdeaBLWNm5S1nFwnQ08vWrPDgMXSp0PD/ +0YjMeeCQkEqUofYsXPaNx98FfQeXbCuryvNiGYRcw2pVekSMBaNT3w80AsNCBGDGO973EZ3c03K mQHvcGpw5pMrZzzdszYTPUJn/O7ckTYakO3W5j/4CzrmNymzPa3B4u6viTf5rRxafI3VERBHrL3V 0w7knaJOHXyb74CkvMRWnDsj+EHzOAOcJGTZeiAp3tyaP9NmbLEzYUBlJj1Mw1Gk9U21bJJYEvQ+ mjkfiZQwN2Ycnj95DBfxzNqou21wZgZ/vfLvzYWTBDhTssaXQYgNf1fgqDNXxZTBdyz2DdhKjV2t I4g+l6rCWbY0MZcgnbHsF7a8xU3eZ693aRr6FKdtTEat6v5OMq1/dYjI7gDgNzRmECOLfSc7+bxa CQW0rIMZQnTIgDfxZ2/WGqYvyOVteVOdo6Dvr8fbMJVJ9/erL6/4IvMfhB2h/z0m0D607pH+bbcn JMMuYxnpWh/BX5m30581doKaMMHQ+5JvvyEOHexzhSsXFiSDkTVkCkszBB9G8qN+F4qdUnhmNihU ZaffS6G6WGNm9YD6a31App4D4Z5xJ4RGzhM5OcgfWRzUhZzlEpwHJhzhpRFuH/T1TpBaybd01LvX ffaG7BTa9OIWwPNmWhbtwk4CVUxZImV0v1p74oj0h+DxjN4rdwq9UTvXru+r48YuTBQcIPAkZZI6 4CI= X-Report-Abuse-To: spam@se001.arandomserver.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1532 Lines: 38 On 8/23/17 3:37 PM, Linus Torvalds wrote: > On Wed, Aug 23, 2017 at 12:15 PM, Doug Nazar wrote: >> The following commits cause short reads of block devices, however writes are >> still allowed. >> >> c2a9737f45e2 ("vfs,mm: fix a dead loop in truncate_inode_pages_range()") >> d05c5f7ba164 ("vfs,mm: fix return value of read() at s_maxbytes") >> >> When e2fsck sees this, it thinks it's a bad sector and tries to write a >> block of nulls which overwrites the valid data. > Hmm. Block devices shouldn't have issues with s_maxbytes, and I'm > surprised that nobody has seen that before. > >> Device is LVM over 2 x RAID-5 on an old 32bit desktop. >> >> RO RA SSZ BSZ StartSec Size Device >> rw 4096 512 4096 0 9748044840960 /dev/Storage/Main > .. and the problem may be as simple as just a missing initialization > of s_maxbytes for blockdev_superblock. > > Does the attcahed trivial one-liner fix things for you? > > Al, if it really is this simple, how come nobody even noticed? > > Also, I do wonder if that check in do_generic_file_read() should just > unconditionally use MAX_LFS_FILESIZE, since the whole point there is > really about the index wrap-around, not about any underlying > filesystem limits per se. > > And that's exactly what MAX_LFS_FILESIZE is - the maximum size that > fits in the page index. It's compiling now, but I think it's already set to MAX_LFS_FILESIZE. [ 169.095127] ppos=80180006000, s_maxbytes=7ffffffffff, magic=0x62646576, type=bdev Doug