Re: [PATCH 3/3] block: implement (some of) fallocate for block devices

From: Linus Torvalds
Date: Fri Mar 04 2016 - 22:13:31 EST


On Fri, Mar 4, 2016 at 4:56 PM, Darrick J. Wong <darrick.wong@xxxxxxxxxx> wrote:
> +
> + /* We can't change the bdev size from here */
> + if (!(mode & FALLOC_FL_KEEP_SIZE))
> + return -EOPNOTSUPP;

Oh, and this I think is wrong.

The thing is, FALLOC_FL_KEEP_SIZE is only supposed to matter if the
region is outside the existing length.

So if y ou punch a hole in the middle of a file, you don't need
FALLOC_FL_KEEP_SIZE.

I would suggest removing this check entirely, since you already check
that people don't try to punch holes past the end of the device. So
FALLOC_FL_KEEP_SIZE is simply a non-issue, and shouldn't even be
checked.

Linus