From: Mandeep Singh Baines <msb@google.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, hch@infradead.org, rlove@google.com,
viro@zeniv.linux.org.uk, hannes@cmpxchg.org
Subject: Re: [PATCH 3/3] vfs: change sb->s_maxbytes to a loff_t
Date: Mon, 10 Aug 2009 14:24:48 -0700 [thread overview]
Message-ID: <20090810212447.GC10147@google.com> (raw)
In-Reply-To: <1249906663-7572-4-git-send-email-jlayton@redhat.com>
Jeff Layton (jlayton@redhat.com) wrote:
> sb->s_maxbytes is supposed to indicate the maximum size of a file that
> can exist on the filesystem. It's declared as an unsigned long long.
>
> Even if a filesystem has no inherent limit that prevents it from using
> every bit in that unsigned long long, it's still problematic to set it
> to anything larger than MAX_LFS_FILESIZE. There are places in the kernel
> that cast s_maxbytes to a signed value. If it's set too large then this
> cast makes it a negative number and generally breaks the comparison.
>
> Change s_maxbytes to be loff_t instead. That should help eliminate the
> temptation to set it too large by making it a signed value.
>
> Also, add a warning for couple of releases to help catch filesystems
> that set s_maxbytes too large. Eventually we can either convert this to
> a BUG() or just remove it and in the hope that no one will get it wrong
> now that it's a signed value.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> fs/super.c | 10 ++++++++++
> include/linux/fs.h | 2 +-
> 2 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index 2761d3e..660d437 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -889,6 +889,16 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
> if (error)
> goto out_sb;
>
> + /*
> + * filesystems should never set s_maxbytes larger than MAX_LFS_FILESIZE
> + * but s_maxbytes was an unsigned long long for many releases. Throw
> + * this warning for a little while to try and catch filesystems that
> + * violate this rule. This warning should be either removed or
> + * converted to a BUG() in 2.6.34.
> + */
> + WARN((mnt->mnt_sb->s_maxbytes < 0), "WARNING: %s set sb->s_maxbytes to "
> + "negative value (%lld)\n", type->name, mnt->mnt_sb->s_maxbytes);
> +
Minor nit. "WARNING:" is redundant. I believe WARN() will already print
"WARNING: at <file>:<line>".
> mnt->mnt_mountpoint = mnt->mnt_root;
> mnt->mnt_parent = mnt;
> up_write(&mnt->mnt_sb->s_umount);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 67888a9..bfe3c08 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1316,7 +1316,7 @@ struct super_block {
> unsigned long s_blocksize;
> unsigned char s_blocksize_bits;
> unsigned char s_dirt;
> - unsigned long long s_maxbytes; /* Max file size */
> + loff_t s_maxbytes; /* Max file size */
Looks good to me. Thanks!
> struct file_system_type *s_type;
> const struct super_operations *s_op;
> struct dquot_operations *dq_op;
> --
> 1.6.0.6
>
prev parent reply other threads:[~2009-08-10 21:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 12:17 [PATCH 0/3] vfs: change sb->s_maxbytes to loff_t (try #2) Jeff Layton
2009-08-10 12:17 ` [PATCH 1/3] vfs: make get_sb_pseudo set s_maxbytes to value that can be cast to signed Jeff Layton
2009-08-10 13:49 ` Christoph Hellwig
2009-08-10 14:08 ` Jeff Layton
2009-08-10 14:16 ` Christoph Hellwig
2009-08-10 12:17 ` [PATCH 2/3] vfs: remove redundant position check in do_sendfile Jeff Layton
2009-08-10 14:56 ` Johannes Weiner
2009-08-10 12:17 ` [PATCH 3/3] vfs: change sb->s_maxbytes to a loff_t Jeff Layton
2009-08-10 21:24 ` Mandeep Singh Baines [this message]
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=20090810212447.GC10147@google.com \
--to=msb@google.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rlove@google.com \
--cc=viro@zeniv.linux.org.uk \
/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.