From patchwork Sun Jun 4 22:06:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 9765287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 89D906032D for ; Sun, 4 Jun 2017 22:06:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D22926E40 for ; Sun, 4 Jun 2017 22:06:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F73926E69; Sun, 4 Jun 2017 22:06:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E62F626E40 for ; Sun, 4 Jun 2017 22:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751198AbdFDWGF (ORCPT ); Sun, 4 Jun 2017 18:06:05 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:38668 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbdFDWGE (ORCPT ); Sun, 4 Jun 2017 18:06:04 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1dHdes-0006nq-LW; Sun, 04 Jun 2017 22:06:02 +0000 Date: Sun, 4 Jun 2017 23:06:02 +0100 From: Al Viro To: Linus Torvalds Cc: Richard Narron , Will B , linux-fsdevel Subject: Re: UFS s_maxbytes bogosity Message-ID: <20170604220602.GN6365@ZenIV.linux.org.uk> References: <20170604213736.GM6365@ZenIV.linux.org.uk> <20170604215838.GA24416@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170604215838.GA24416@ZenIV.linux.org.uk> User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, Jun 04, 2017 at 10:58:38PM +0100, Al Viro wrote: > u64 ufs_max_bytes(struct super_block *sb) > { > struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; > int bits = uspi->s_apbshift; > u64 res; > > if (bits > 21) > return MAX_LFS_FILESIZE; > > res = UFS_NDADDR + (1LL << bits) + (1LL << (2*bits)) + > (1LL << (3*bits)); > > if (res >= (MAX_LFS_FILESIZE >> uspi->s_bshift)) > return MAX_LFS_FILESIZE; > > return res << uspi->s_bshift; > } > > ought to calculate the right thing for modern UFS variants; I would > leave the anything other than UFS_MOUNT_UFSTYPE_44BSD and > UFS_MOUNT_UFSTYPE_UFS2 alone. Now that I'm hopefully sufficiently awake... Folks, could you try this: diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 131b2b77c818..2bab1491a5d4 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -746,6 +746,24 @@ static void ufs_put_super(struct super_block *sb) return; } +static u64 ufs_max_bytes(struct super_block *sb) +{ + struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; + int bits = uspi->s_apbshift; + u64 res; + + if (bits > 21) + return MAX_LFS_FILESIZE; + + res = UFS_NDADDR + (1LL << bits) + (1LL << (2*bits)) + + (1LL << (3*bits)); + + if (res >= (MAX_LFS_FILESIZE >> uspi->s_bshift)) + return MAX_LFS_FILESIZE; + + return res << uspi->s_bshift; +} + static int ufs_fill_super(struct super_block *sb, void *data, int silent) { struct ufs_sb_info * sbi; @@ -823,6 +841,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) uspi->s_fshift = 9; uspi->s_sbsize = super_block_size = 1536; uspi->s_sbbase = 0; + sb->s_maxbytes = ufs_max_bytes(sb); flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; break; case UFS_MOUNT_UFSTYPE_UFS2: @@ -833,6 +852,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) uspi->s_fshift = 9; uspi->s_sbsize = super_block_size = 1536; uspi->s_sbbase = 0; + sb->s_maxbytes = ufs_max_bytes(sb); flags |= UFS_TYPE_UFS2 | UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; break;