From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v2 2/3] xfs_io: Add RWF_DONTCACHE support to pwritev2
Date: Thu, 06 Mar 2025 00:41:54 +0530 [thread overview]
Message-ID: <87a59z70n9.fsf@gmail.com> (raw)
In-Reply-To: <20250305181031.GG2803749@frogsfrogsfrogs>
"Darrick J. Wong" <djwong@kernel.org> writes:
> On Wed, Mar 05, 2025 at 03:57:47PM +0530, Ritesh Harjani (IBM) wrote:
>> Add per-io RWF_DONTCACHE support flag to pwritev2().
>> This enables xfs_io to perform uncached buffered-io writes.
>>
>> e.g. xfs_io -fc "pwrite -U -V 1 0 16K" /mnt/f1
>>
>> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
>> ---
>> include/linux.h | 5 +++++
>> io/pwrite.c | 14 ++++++++++++--
>> man/man8/xfs_io.8 | 8 +++++++-
>> 3 files changed, 24 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux.h b/include/linux.h
>> index b3516d54..6e83e073 100644
>> --- a/include/linux.h
>> +++ b/include/linux.h
>> @@ -237,6 +237,11 @@ struct fsxattr {
>> #define RWF_ATOMIC ((__kernel_rwf_t)0x00000040)
>> #endif
>>
>> +/* buffered IO that drops the cache after reading or writing data */
>> +#ifndef RWF_DONTCACHE
>> +#define RWF_DONTCACHE ((__kernel_rwf_t)0x00000080)
>> +#endif
>> +
>> /*
>> * Reminder: anything added to this file will be compiled into downstream
>> * userspace projects!
>> diff --git a/io/pwrite.c b/io/pwrite.c
>> index fab59be4..5fb0253f 100644
>> --- a/io/pwrite.c
>> +++ b/io/pwrite.c
>> @@ -45,6 +45,7 @@ pwrite_help(void)
>> " -N -- Perform the pwritev2() with RWF_NOWAIT\n"
>> " -D -- Perform the pwritev2() with RWF_DSYNC\n"
>> " -A -- Perform the pwritev2() with RWF_ATOMIC\n"
>> +" -U -- Perform the pwritev2() with Uncached/RWF_DONTCACHE\n"
>
> I would have just said "...with RWF_DONTCACHE" because that's a lot more
> precise.
>
Yes, probably I was just overthinking and trying to give a reason here of
choosing -U (Uncached).
> With that shortened, this looks pretty straightforward.
Sure will fix in v3.
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Thanks!
-ritesh
>
> --D
>
>> #endif
>> "\n"));
>> }
>> @@ -285,7 +286,7 @@ pwrite_f(
>> init_cvtnum(&fsblocksize, &fssectsize);
>> bsize = fsblocksize;
>>
>> - while ((c = getopt(argc, argv, "Ab:BCdDf:Fi:NqRs:OS:uV:wWZ:")) != EOF) {
>> + while ((c = getopt(argc, argv, "Ab:BCdDf:Fi:NqRs:OS:uUV:wWZ:")) != EOF) {
>> switch (c) {
>> case 'b':
>> tmp = cvtnum(fsblocksize, fssectsize, optarg);
>> @@ -328,6 +329,9 @@ pwrite_f(
>> case 'A':
>> pwritev2_flags |= RWF_ATOMIC;
>> break;
>> + case 'U':
>> + pwritev2_flags |= RWF_DONTCACHE;
>> + break;
>> #endif
>> case 's':
>> skip = cvtnum(fsblocksize, fssectsize, optarg);
>> @@ -392,6 +396,12 @@ pwrite_f(
>> exitcode = 1;
>> return command_usage(&pwrite_cmd);
>> }
>> + if (pwritev2_flags != 0 && vectors == 0) {
>> + printf(_("pwritev2 flags require vectored I/O (-V)\n"));
>> + exitcode = 1;
>> + return command_usage(&pwrite_cmd);
>> + }
>> +
>> offset = cvtnum(fsblocksize, fssectsize, argv[optind]);
>> if (offset < 0) {
>> printf(_("non-numeric offset argument -- %s\n"), argv[optind]);
>> @@ -480,7 +490,7 @@ pwrite_init(void)
>> pwrite_cmd.argmax = -1;
>> pwrite_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
>> pwrite_cmd.args =
>> -_("[-i infile [-qAdDwNOW] [-s skip]] [-b bs] [-S seed] [-FBR [-Z N]] [-V N] off len");
>> +_("[-i infile [-qAdDwNOUW] [-s skip]] [-b bs] [-S seed] [-FBR [-Z N]] [-V N] off len");
>> pwrite_cmd.oneline =
>> _("writes a number of bytes at a specified offset");
>> pwrite_cmd.help = pwrite_help;
>> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
>> index 59d5ddc5..47af5232 100644
>> --- a/man/man8/xfs_io.8
>> +++ b/man/man8/xfs_io.8
>> @@ -244,7 +244,7 @@ See the
>> .B pread
>> command.
>> .TP
>> -.BI "pwrite [ \-i " file " ] [ \-qAdDwNOW ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-V " vectors " ] " "offset length"
>> +.BI "pwrite [ \-i " file " ] [ \-qAdDwNOUW ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-V " vectors " ] " "offset length"
>> Writes a range of bytes in a specified blocksize from the given
>> .IR offset .
>> The bytes written can be either a set pattern or read in from another
>> @@ -287,6 +287,12 @@ Perform the
>> call with
>> .IR RWF_ATOMIC .
>> .TP
>> +.B \-U
>> +Perform the
>> +.BR pwritev2 (2)
>> +call with
>> +.IR RWF_DONTCACHE .
>> +.TP
>> .B \-O
>> perform pwrite once and return the (maybe partial) bytes written.
>> .TP
>> --
>> 2.48.1
>>
>>
next prev parent reply other threads:[~2025-03-05 19:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 10:27 [PATCH v2 0/3] xfsprogs: Add support for preadv2() and RWF_DONTCACHE Ritesh Harjani (IBM)
2025-03-05 10:27 ` [PATCH v2 1/3] xfs_io: Add support for preadv2 Ritesh Harjani (IBM)
2025-03-05 18:08 ` Darrick J. Wong
2025-03-05 19:07 ` Ritesh Harjani
2025-03-05 10:27 ` [PATCH v2 2/3] xfs_io: Add RWF_DONTCACHE support to pwritev2 Ritesh Harjani (IBM)
2025-03-05 18:10 ` Darrick J. Wong
2025-03-05 19:11 ` Ritesh Harjani [this message]
2025-03-05 10:27 ` [PATCH v2 3/3] xfs_io: Add RWF_DONTCACHE support to preadv2 Ritesh Harjani (IBM)
2025-03-05 18:11 ` Darrick J. Wong
2025-03-05 19:14 ` Ritesh Harjani
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=87a59z70n9.fsf@gmail.com \
--to=ritesh.list@gmail.com \
--cc=axboe@kernel.dk \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--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