From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38B95808 for ; Sat, 21 Oct 2023 05:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Vy9fRtEK" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED231BF; Fri, 20 Oct 2023 22:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=z8f9uaKwD9ppL0C1CqjKBJdH1gJN+2UHJiY2wGmwdxA=; b=Vy9fRtEKCTjI8FDUW5pt/h3hbe NhaaVm6bQmr6DXy+p81klmEehmrI35qJ7hxpaIt5/jEHYZ6b1pXPBZ/bsp2h6VvyVr861ZOV3ePas B1zk1Ho42Kue7H7KhuAkoNKrHZcQXTOrmpa0z+9hLsu2LaDUYmwMqBGWItieLEvVKLJ7DOj+yvx78 LiPoXYyuw83dGgyxDZXnMGQW4Aj0Y1hT2KflGs7MPM4RXDAkoIboGQ2G81yttk3KhIQF+4iMe3Dp3 BE/mmXWZyoOeRHiCuUnTjmxg9Tx+Tj7uf0+uvW80odS6yZ+dZ86ylW83eWDM+bjAtQXhM+u9UUxpH K9utjqJg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qu4E1-00HIF4-NU; Sat, 21 Oct 2023 05:08:37 +0000 Date: Sat, 21 Oct 2023 06:08:37 +0100 From: Matthew Wilcox To: Hannes Reinecke Cc: Luis Chamberlain , Christoph Hellwig , Jens Axboe , Pankaj Raghav , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 04/18] fs/buffer.c: use accessor function to translate page index to sectors Message-ID: References: <20230918110510.66470-1-hare@suse.de> <20230918110510.66470-5-hare@suse.de> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Oct 20, 2023 at 08:37:26PM +0100, Matthew Wilcox wrote: > On Mon, Sep 18, 2023 at 01:04:56PM +0200, Hannes Reinecke wrote: > > Use accessor functions block_index_to_sector() and block_sector_to_index() > > to translate the page index into the block sector and vice versa. > > You missed two in grow_dev_page() (which I just happened upon): I have fixes here. The key part of the first patch is: static sector_t folio_init_buffers(struct folio *folio, - struct block_device *bdev, sector_t block, int size) + struct block_device *bdev, int size) { struct buffer_head *head = folio_buffers(folio); struct buffer_head *bh = head; bool uptodate = folio_test_uptodate(folio); + sector_t block = folio_pos(folio) / size; sector_t end_block = blkdev_max_block(bdev, size); (and then there's the cruft of removing the arguments from folio_init_buffers) The second patch is: static bool grow_buffers(struct block_device *bdev, sector_t block, unsigned size, gfp_t gfp) { - pgoff_t index; - int sizebits; - - sizebits = PAGE_SHIFT - __ffs(size); - index = block >> sizebits; + loff_t pos; [...] - if (unlikely(index != block >> sizebits)) { + if (check_mul_overflow(block, size, &pos) || pos > MAX_LFS_FILESIZE) { I'll send a proper patch series tomorrow once the fstests are done running.