From: Calvin Owens <calvinowens@fb.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, kernel-team@fb.com,
calvinowens <calvinowens@fb.com>
Subject: Re: [PATCH][PROGS] xfs_io: Allow setting multiple mode flags for fallocate()
Date: Sun, 19 Mar 2017 21:33:50 -0700 [thread overview]
Message-ID: <8dc5334b-a7b9-d455-25b5-5d651a3b918d@fb.com> (raw)
In-Reply-To: <20170318065554.GX17542@dastard>
On 03/17/2017 11:55 PM, Dave Chinner wrote:
> On Fri, Mar 17, 2017 at 06:26:09PM -0700, Calvin Owens wrote:
>> This allows testing FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE.
>
> Which is normally done through the "fpunch" command, which explains
> why nobody has noticed this.
Ah okay, I was assuming parity with syscalls in the commands and picked
the first one I saw ;)
>> Signed-off-by: Calvin Owens <calvinowens@fb.com>
>> ---
>> io/prealloc.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/io/prealloc.c b/io/prealloc.c
>> index a9d66cc..2a4bcdc 100644
>> --- a/io/prealloc.c
>> +++ b/io/prealloc.c
>> @@ -201,19 +201,19 @@ fallocate_f(
>> while ((c = getopt(argc, argv, "cikpu")) != EOF) {
>> switch (c) {
>> case 'c':
>> - mode = FALLOC_FL_COLLAPSE_RANGE;
>> + mode |= FALLOC_FL_COLLAPSE_RANGE;
>> break;
>> case 'i':
>> - mode = FALLOC_FL_INSERT_RANGE;
>> + mode |= FALLOC_FL_INSERT_RANGE;
>> break;
>> case 'k':
>> - mode = FALLOC_FL_KEEP_SIZE;
>> + mode |= FALLOC_FL_KEEP_SIZE;
>> break;
>> case 'p':
>> - mode = FALLOC_FL_PUNCH_HOLE;
>> + mode |= FALLOC_FL_PUNCH_HOLE;
>> break;
>> case 'u':
>> - mode = FALLOC_FL_UNSHARE_RANGE;
>> + mode |= FALLOC_FL_UNSHARE_RANGE;
>> break;
>
> NACK. We should not allow users to set invalid combinations
> of commands such as 'falloc -cipu ...' - this would set the flags
> (FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_INSERT_RANGE |
> FALLOC_FL_PUNCH_HOLE | FALLOC_FL_UNSHARE_RANGE) and will always
> error out.
Isn't it potentially useful to test invalid behavior?
> The use of FALLOC_FL_KEEP_SIZE for the FALLOC_FL_PUNCH_HOLE command
> is essentially for documentation purposes - it does not do
> truncation, hence the FALLOC_FL_KEEP_SIZE flag was added to it to
> ensure developers understand that it does not truncate the file and
> change EOF.
>
> IOWs, the fix needed to make the 'falloc -p' command work is really
> just this:
>
> - mode = FALLOC_FL_PUNCH_HOLE;
> + mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
My thinking was just "allow full exercising of the syscall", fpunch works
for my testcase so if you'd prefer not to do that we can just drop this :)
It might be worth cleaning up 'falloc' though: '-k' doesn't really make
sense on its own right? Maybe remove "-k" and make "-p" OR in KEEP_SIZE
like you suggest?
Thanks,
Calvin
> Cheers,
>
> Dave.
>
next prev parent reply other threads:[~2017-03-20 4:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-18 1:26 [PATCH][PROGS] xfs_io: Allow setting multiple mode flags for fallocate() Calvin Owens
2017-03-18 6:55 ` Dave Chinner
2017-03-20 4:33 ` Calvin Owens [this message]
2017-03-21 21:54 ` Dave Chinner
2017-03-31 4:14 ` Calvin Owens
2017-04-04 19:26 ` Eric Sandeen
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=8dc5334b-a7b9-d455-25b5-5d651a3b918d@fb.com \
--to=calvinowens@fb.com \
--cc=david@fromorbit.com \
--cc=kernel-team@fb.com \
--cc=linux-xfs@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).