All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Richard Narron <comet.berkeley@gmail.com>,
	Will B <will.brokenbourgh2877@gmail.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: UFS s_maxbytes bogosity
Date: Sun, 4 Jun 2017 22:58:38 +0100	[thread overview]
Message-ID: <20170604215838.GA24416@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20170604213736.GM6365@ZenIV.linux.org.uk>

On Sun, Jun 04, 2017 at 10:37:36PM +0100, Al Viro wrote:
> On Sun, Jun 04, 2017 at 12:31:34PM -0700, Linus Torvalds wrote:
> 
> > and in particular the patch in there that just makes UFS use MAX_LFS_FILESIZE:
> > 
> >     https://bugzilla.kernel.org/attachment.cgi?id=256853&action=diff
>  
> > I'm inclined to just apply it, since clearly the default 2G limit
> > isn't appropriate for UFS, although it would perhaps be a good idea to
> > figure out just what the true UFS maximum file size can be.. The
> > on-disk "ui_size" field seems to be a 64-bit entity, so
> > MAX_LFS_FILESIZE is certainly better, but there's probably some index
> > tree limit that depends on the block size or whatever.
> 
> Depends.  There had been a lot of UFS variants (hell, ext2 is one), so
> limits differ.  They are also kernel-dependent.
> 
> One hard limit is the same as in ext2 - indirect blocks contain pointers
> to blocks, so you get (10 + n + n^2 + n^3)*block_size, where n is

<grabs some coffee>

12 + n + n^2 + n^3, sorry.  12 direct blocks, plus usual indirects.

Something like (completely untested)

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.

  reply	other threads:[~2017-06-04 21:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-04 19:31 UFS s_maxbytes bogosity Linus Torvalds
2017-06-04 21:37 ` Al Viro
2017-06-04 21:58   ` Al Viro [this message]
2017-06-04 22:06     ` Al Viro
2017-06-04 23:26       ` Linus Torvalds
2017-06-05  0:11         ` Al Viro
2017-06-05  3:00           ` Linus Torvalds
2017-06-05  3:49             ` Al Viro
2017-06-07 23:48               ` Al Viro
2017-06-08  0:35                 ` Richard Narron
2017-06-08  2:20                   ` Al Viro
2017-06-08 22:15                     ` Al Viro
2017-06-08 22:36                       ` Linus Torvalds
2017-06-09  0:11                     ` Richard Narron
2017-06-09  3:35                       ` Al Viro
2017-06-09 17:34                         ` Al Viro
2017-06-09 21:55                         ` Richard Narron
2017-06-10  0:09                         ` Richard Narron
2017-06-04 22:32     ` Theodore Ts'o
2017-06-05  0:02       ` Al Viro
2017-06-04 23:23 ` [PATCH 1/1] fs/ufs: Set UFS default maximum bytes per file Richard Narron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170604215838.GA24416@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=comet.berkeley@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=will.brokenbourgh2877@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.