[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 32/34] monitor: fdset: Match against O_DIRECT
From: |
Fabiano Rosas |
Subject: |
Re: [PATCH v4 32/34] monitor: fdset: Match against O_DIRECT |
Date: |
Wed, 21 Feb 2024 10:37:37 -0300 |
Markus Armbruster <armbru@redhat.com> writes:
> Fabiano Rosas <farosas@suse.de> writes:
>
>> We're about to enable the use of O_DIRECT in the migration code and
>> due to the alignment restrictions imposed by filesystems we need to
>> make sure the flag is only used when doing aligned IO.
>>
>> The migration will do parallel IO to different regions of a file, so
>> we need to use more than one file descriptor. Those cannot be obtained
>> by duplicating (dup()) since duplicated file descriptors share the
>> file status flags, including O_DIRECT. If one migration channel does
>> unaligned IO while another sets O_DIRECT to do aligned IO, the
>> filesystem would fail the unaligned operation.
>>
>> The add-fd QMP command along with the fdset code are specifically
>> designed to allow the user to pass a set of file descriptors with
>> different access flags into QEMU to be later fetched by code that
>> needs to alternate between those flags when doing IO.
>>
>> Extend the fdset matching function to behave the same with the
>> O_DIRECT flag.
>>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>> monitor/fds.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/monitor/fds.c b/monitor/fds.c
>> index 9a28e4b72b..42bf3eb982 100644
>> --- a/monitor/fds.c
>> +++ b/monitor/fds.c
>> @@ -413,6 +413,12 @@ static bool monitor_fdset_flags_match(int flags, int
>> fd_flags)
> static bool monitor_fdset_flags_match(int flags, int fd_flags)
> {
> bool match = false;
>
>> if ((flags & O_ACCMODE) == (fd_flags & O_ACCMODE)) {
>> match = true;
>> +
>> +#ifdef O_DIRECT
>> + if ((flags & O_DIRECT) != (fd_flags & O_DIRECT)) {
>> + match = false;
>> + }
>> +#endif
>> }
>>
>> return match;
> }
>
> I'd prefer something like
>
> static bool monitor_fdset_flags_match(int flags, int fd_flags)
> {
> #ifdef O_DIRECT
> if ((flags & O_DIRECT) != (fd_flags & O_DIRECT)) {
> return false;
> }
> #endif
>
> if ((flags & O_ACCMODE) != (fd_flags & O_ACCMODE)) {
> return false;
>
> }
>
> return true;
> }
This makes the O_DIRECT flag dictate the outcome when it's present. I
want O_DIRECT to be considered only when all other flags have matched.
Otherwise we regress the original use-case if the user happened to have
put O_DIRECT in the flags. A non-match due to different O_ACCMODE would
become a match due to (possibly) matching O_DIRECT.
- [PATCH v4 26/34] tests/qtest/migration: Add a multifd + fixed-ram migration test, (continued)
- [PATCH v4 26/34] tests/qtest/migration: Add a multifd + fixed-ram migration test, Fabiano Rosas, 2024/02/20
- [PATCH v4 27/34] migration: Add direct-io parameter, Fabiano Rosas, 2024/02/20
- [PATCH v4 28/34] migration/multifd: Add direct-io support, Fabiano Rosas, 2024/02/20
- [PATCH v4 29/34] tests/qtest/migration: Add tests for file migration with direct-io, Fabiano Rosas, 2024/02/20
- [PATCH v4 30/34] monitor: Honor QMP request for fd removal immediately, Fabiano Rosas, 2024/02/20
- [PATCH v4 31/34] monitor: Extract fdset fd flags comparison into a function, Fabiano Rosas, 2024/02/20
- [PATCH v4 32/34] monitor: fdset: Match against O_DIRECT, Fabiano Rosas, 2024/02/20
[PATCH v4 34/34] tests/qtest/migration: Add a test for fixed-ram with passing of fds, Fabiano Rosas, 2024/02/20
[PATCH v4 33/34] migration: Add support for fdset with multifd + file, Fabiano Rosas, 2024/02/20
Re: [PATCH v4 00/34] migration: File based migration with multifd and fixed-ram, Peter Xu, 2024/02/22
Re: [PATCH v4 00/34] migration: File based migration with multifd and fixed-ram, Peter Xu, 2024/02/26