From: Dave Chinner <david@fromorbit.com>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: elder@kernel.org, tytso@mit.edu,
Namjae Jeon <namjae.jeon@samsung.com>,
linux-kernel@vger.kernel.org, xfs@oss.sgi.com, hch@infradead.org,
bpm@sgi.com, adilger.kernel@dilger.ca, viro@zeniv.linux.org.uk,
a.sangwan@samsung.com, linux-fsdevel@vger.kernel.org,
linux-ext4@vger.kernel.org, mtk.manpages@gmail.com
Subject: Re: [PATCH RESEND 2/7] xfs: add support FALLOC_FL_COLLAPSE_RANGE for fallocate
Date: Fri, 11 Oct 2013 08:23:26 +1100 [thread overview]
Message-ID: <20131010212326.GZ4446@dastard> (raw)
In-Reply-To: <CAKYAXd8=ZKESV5Fmw7hqwL=G8L=BG6h0LQpc2cVjN9uTkj7nYw@mail.gmail.com>
On Thu, Oct 10, 2013 at 04:00:13PM +0900, Namjae Jeon wrote:
> >
> > /*
> > * Shift extent records to the left to cover a hole.
> > *
> > * The maximum number of extents to be shifted in a single operation
> > * is @count, and @current_ext keeps track of the current extent
> > * index we have shifted. If there is no hole to shift the extents
> > * into, then we abort immediately.
> > */
> Thanks for your help. I will change this comment instead of original one.
>
> >> +int
> >> +xfs_bmap_shift_extents(
> >> + struct xfs_trans *tp,
> >> + struct xfs_inode *ip,
> >> + int *done,
> >> + xfs_fileoff_t start_fsb,
> >> + xfs_fileoff_t shift,
> >
> > Shift means ...? Number of extents to shift, a length, a number of
> > block, or something else?
> Ah, yes, shift_len would be a more proper name
I'm not sure that's a lot better. What are we shifting? We are
shifting the offset of the blocks, right? And the unit is in fsb?
So perhaps offset_shift_fsb, and add that to the description of the
function above?
> >> + /*
> >> + * Before shifting extent into hole, make sure that the hole
> >> + * is large enough to accomodate the shift.
> >> + */
> >> + if (*current_ext) {
> >> + state |= BMAP_LEFT_VALID;
> >> + xfs_bmbt_get_all(xfs_iext_get_ext(ifp,
> >> + *current_ext - 1), &left);
> >> +
> >> + if (isnullstartblock(left.br_startblock))
> >> + state |= BMAP_LEFT_DELAY;
> >> +
> >> + if (startoff < left.br_startoff + left.br_blockcount)
> >> + error = XFS_ERROR(EFSCORRUPTED);
> >
> > Why is the filesystem corrupted if the shift we asked for is too
> > large for the hole in the file? I haven't seen any checks before
> > this that guarantee that the hole is big enough for the shift...
>
> we call xfs_free_file_space to free enough blocks for shifting.
> If still the space is not big enough will it be considered as fs corrupted?
> What error could we return in this case?
Hole punching rounds inwards, and the amount of rounding is not
necessarily the nearest filesystem block. Again it's the block size
smaller than page size case that will trip you over here, as the
rounding when punching holes will be done to page size, not
filesystem block size. Hence it's entirely possible that your
calculated shift start and lengths don't match the size of the hole
that was punched.
That doesn't mean there was a corruption - just that the hole wasn't
the size and shape that was expected....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-10-10 21:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-06 20:13 [PATCH RESEND 2/7] xfs: add support FALLOC_FL_COLLAPSE_RANGE for fallocate Namjae Jeon
2013-10-10 0:51 ` Dave Chinner
2013-10-10 7:00 ` Namjae Jeon
2013-10-10 21:23 ` Dave Chinner [this message]
2013-10-14 3:30 ` Namjae Jeon
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=20131010212326.GZ4446@dastard \
--to=david@fromorbit.com \
--cc=a.sangwan@samsung.com \
--cc=adilger.kernel@dilger.ca \
--cc=bpm@sgi.com \
--cc=elder@kernel.org \
--cc=hch@infradead.org \
--cc=linkinjeon@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=namjae.jeon@samsung.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=xfs@oss.sgi.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 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).