Flexible I/O Tester development
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Vincent Fu <vincentfu@gmail.com>, fio@vger.kernel.org
Cc: Vincent Fu <vincent.fu@samsung.com>
Subject: Re: [PATCH] windows: fix pread/pwrite
Date: Thu, 8 May 2025 11:18:28 -0600	[thread overview]
Message-ID: <16cf9fd1-968b-4349-903b-9a58eb0c9945@kernel.dk> (raw)
In-Reply-To: <20250508171444.2113-1-vincent.fu@samsung.com>

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


  reply	other threads:[~2025-05-08 17:18 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 [this message]
2025-05-08 17:31   ` Vincent Fu
2025-05-08 17:35     ` Jens Axboe
2025-05-08 18:00       ` Vincent Fu
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=16cf9fd1-968b-4349-903b-9a58eb0c9945@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --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