Flexible I/O Tester development
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Vincent Fu <vincentfu@gmail.com>, Kanchan Joshi <joshi.k@samsung.com>
Cc: fio@vger.kernel.org, vincent.fu@samsung.com
Subject: Re: [PATCH] filesetup: do not ask O_RDWR for read-only workload
Date: Fri, 3 Feb 2023 07:14:53 -0700	[thread overview]
Message-ID: <dee97219-f0ce-bae7-94ef-c4e56073ff2e@kernel.dk> (raw)
In-Reply-To: <b14eae2a-56f9-0063-42b0-50ca35961d1a@gmail.com>

On 2/3/23 7:08?AM, Vincent Fu wrote:
> On 2/3/23 07:46, Jens Axboe wrote:
>> On Feb 3, 2023, at 5:35 AM, Kanchan Joshi <joshi.k@samsung.com> wrote:
>>>
>>> ?Use O_RDONLY flag when read is requested on char-type files.
>>>
>>> Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
>>> ---
>>>
>>> Before this patch: unexpected permission-denial for unprivileged-user.
>>>
>>> $ ls -l /dev/ng0n1
>>> cr--r--r-- 1 root root 242, 0 Feb  3 16:30 /dev/ng0n1
>>>
>>> $ ./fio -iodepth=1 -rw=randread -ioengine=io_uring_cmd -bs=4k -numjobs=1
>>> -size=4k -cmd_type=nvme -filename=/dev/ng0n1 -name=t
>>> t: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T)
>>> 4096B-4096B, ioengine=io_uring_cmd, iodepth=1
>>> fio-3.33-71-g7d7a
>>> Starting 1 process
>>> fio: pid=131312, err=13/file:filesetup.c:805, func=open(/dev/ng0n1),
>>> error=Permission denied
>>>
>>> filesetup.c | 5 +----
>>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/filesetup.c b/filesetup.c
>>> index 1d3cc5ad..d77b8ba4 100644
>>> --- a/filesetup.c
>>> +++ b/filesetup.c
>>> @@ -768,10 +768,7 @@ open_again:
>>>         else
>>>             from_hash = file_lookup_open(f, flags);
>>>     } else if (td_read(td)) {
>>> -        if (f->filetype == FIO_TYPE_CHAR && !read_only)
>>> -            flags |= O_RDWR;
>>> -        else
>>> -            flags |= O_RDONLY;
>>> +        flags |= O_RDONLY;
>>
>> This will break sg like interfaces, where a read is done by writing the command to the char device.
>>
>> ?
>> Jens Axboe
>>
> 
> Kanchan, does it work if you run fio with the --readonly option?

I think we should just make it work. Conceptually, the patch is obviously
fine, it just happens to break some oddball cases like sg/bsg. But maybe
we just add a fio ioengine flag for that, like FIO_RO_NEEDS_RW_OPEN or
something, where the engine can tell us if it needs a writeable open
even or a read-only workload.

Then generic_file_open() can use O_RDONLY for td_read(), except if the
engine has FIO_RO_NEEDS_RW_OPEN set.

-- 
Jens Axboe


  reply	other threads:[~2023-02-03 14:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230203123513epcas5p4cb1961d7d1376bf39690f82de639d6f4@epcas5p4.samsung.com>
2023-02-03 12:34 ` [PATCH] filesetup: do not ask O_RDWR for read-only workload Kanchan Joshi
2023-02-03 12:46   ` Jens Axboe
2023-02-03 14:08     ` Vincent Fu
2023-02-03 14:14       ` Jens Axboe [this message]
2023-02-03 15:26         ` Vincent Fu
2023-02-03 15:32           ` Jens Axboe
2023-02-06  6:52           ` Kanchan Joshi
2023-02-06 19:37             ` Jens Axboe
2023-02-07 16:16               ` Vincent Fu
2023-02-07 16:33                 ` Jens Axboe

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=dee97219-f0ce-bae7-94ef-c4e56073ff2e@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --cc=joshi.k@samsung.com \
    --cc=vincent.fu@samsung.com \
    --cc=vincentfu@gmail.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