From: "Burton, Ross" <ross.burton@intel.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] create_inode: fix copying large files
Date: Fri, 1 Feb 2019 18:32:04 +0000 [thread overview]
Message-ID: <CAJTo0LZbC9n4AJR4mvnxHxGCPQOnqzbkfXkrwZuL-70-EewmUQ@mail.gmail.com> (raw)
In-Reply-To: <20190201174715.GB10211@magnolia>
Yeah, you're right, thanks for the review.
Ross
On Fri, 1 Feb 2019 at 17:47, Darrick J. Wong <darrick.wong@oracle.com> wrote:
>
> On Fri, Feb 01, 2019 at 12:51:59PM +0000, Ross Burton wrote:
> > When copying large files into a ext filesystem at mkfs time the copy fails at
> > 2^31 bytes in. There are two problems:
> >
> > copy_file_chunk() passes an offset (off_t, 64-bit typically) to
> > ext2fs_file_lseek() which expects a ext2_off_t (typedef to __u32) so the value
> > is truncated. Solve by calling ext2fs_file_llseek() which takes a u64 offset
> > instead.
> >
> > try_lseek_copy() rounds the data and hole offsets as found by lseek() to block
> > boundaries, but the calculation gets truncated to 32-bits. Solve by casting the
> > 32-bit blocksize to off_t to ensure this doesn't happen.
> >
> > Signed-off-by: Ross Burton <ross.burton@intel.com>
> > ---
> > misc/create_inode.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/misc/create_inode.c b/misc/create_inode.c
> > index 05aa6363..f106dcda 100644
> > --- a/misc/create_inode.c
> > +++ b/misc/create_inode.c
> > @@ -438,7 +438,7 @@ static errcode_t copy_file_chunk(ext2_filsys fs, int fd, ext2_file_t e2_file,
> > ptr += blen;
> > continue;
> > }
> > - err = ext2fs_file_lseek(e2_file, off + bpos,
> > + err = ext2fs_file_llseek(e2_file, off + bpos,
> > EXT2_SEEK_SET, NULL);
> > if (err)
> > goto fail;
> > @@ -481,7 +481,7 @@ static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf,
> > return EXT2_ET_UNIMPLEMENTED;
> >
> > data_blk = data & ~(fs->blocksize - 1);
>
> Do we need to cast this one too? ^^^^^^^
>
> (Looks reasonable otherwise...)
>
> --D
>
> > - hole_blk = (hole + (fs->blocksize - 1)) & ~(fs->blocksize - 1);
> > + hole_blk = (hole + (off_t)(fs->blocksize - 1)) & ~(off_t)(fs->blocksize - 1);
> > err = copy_file_chunk(fs, fd, e2_file, data_blk, hole_blk, buf,
> > zerobuf);
> > if (err)
> > --
> > 2.11.0
> >
prev parent reply other threads:[~2019-02-01 18:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-01 12:51 [PATCH] create_inode: fix copying large files Ross Burton
2019-02-01 17:47 ` Darrick J. Wong
2019-02-01 18:32 ` Burton, Ross [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=CAJTo0LZbC9n4AJR4mvnxHxGCPQOnqzbkfXkrwZuL-70-EewmUQ@mail.gmail.com \
--to=ross.burton@intel.com \
--cc=darrick.wong@oracle.com \
--cc=linux-ext4@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).