All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Fu <vincentfu@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: fio@vger.kernel.org, Vincent Fu <vincent.fu@samsung.com>
Subject: Re: [PATCH] windows: fix pread/pwrite
Date: Thu, 8 May 2025 14:00:52 -0400	[thread overview]
Message-ID: <44bebdec-119a-4039-bbcf-db323d74cc30@gmail.com> (raw)
In-Reply-To: <2adb3a16-946c-4adf-9285-a251e018082d@kernel.dk>

On 5/8/25 1:35 PM, Jens Axboe wrote:
> On 5/8/25 11:31 AM, Vincent Fu wrote:
>> On Thu, May 8, 2025 at 1:18?PM Jens Axboe <axboe@kernel.dk> wrote:
>>>
>>> On 5/8/25 11:14 AM, Vincent Fu wrote:
>>>> The pread and pwrite functions for Windows posix emulation never actually seek
>>>> to the requested offset. Fix this so that the psync ioengine works correctly on
>>>> Windows.
>>>>
>>>> Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
>>>> ---
>>>>   os/windows/posix.c | 10 ++++++++--
>>>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/os/windows/posix.c b/os/windows/posix.c
>>>> index e3abf383..3e48c3ff 100644
>>>> --- a/os/windows/posix.c
>>>> +++ b/os/windows/posix.c
>>>> @@ -830,18 +830,24 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte,
>>>>                off_t offset)
>>>>   {
>>>>        int64_t pos = _telli64(fildes);
>>>> -     ssize_t len = _write(fildes, buf, nbyte);
>>>> +     ssize_t len;
>>>>
>>>> +     _lseeki64(fildes, offset, SEEK_SET);
>>>> +     len = _write(fildes, buf, nbyte);
>>>>        _lseeki64(fildes, pos, SEEK_SET);
>>>> +
>>>>        return len;
>>>>   }
>>>>
>>>>   ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset)
>>>>   {
>>>>        int64_t pos = _telli64(fildes);
>>>> -     ssize_t len = read(fildes, buf, nbyte);
>>>> +     ssize_t len;
>>>>
>>>> +     _lseeki64(fildes, offset, SEEK_SET);
>>>> +     len = read(fildes, buf, nbyte);
>>>>        _lseeki64(fildes, pos, SEEK_SET);
>>>> +
>>>>        return len;
>>>>   }
>>>
>>> lol, how broken is that... Does windows have any offset read/write
>>> variants, or is lseek required?
>>>
>>> --
>>> Jens Axboe
>>>
>>
>> I could not find a better way to do this but I am hoping someone who
>> knows more about Windows than I do can weigh in. Sitsofe?
> 
> It's probably not a big deal. I did a quick search and doesn't seem like
> one exists for that.
> 

Ok thanks. I will go ahead with it then.

Vincent

  reply	other threads:[~2025-05-08 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08 17:14 [PATCH] windows: fix pread/pwrite Vincent Fu
2025-05-08 17:18 ` Jens Axboe
2025-05-08 17:31   ` Vincent Fu
2025-05-08 17:35     ` Jens Axboe
2025-05-08 18:00       ` Vincent Fu [this message]
2025-05-08 21:28     ` Sitsofe Wheeler
2025-05-09  0:43       ` Vincent Fu
2025-05-08 17:49 ` fio CI test result fiotestbot

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=44bebdec-119a-4039-bbcf-db323d74cc30@gmail.com \
    --to=vincentfu@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --cc=vincent.fu@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.