From: Petr Vorel <pvorel@suse.cz>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] scsi_debug/tlibio/lio_read_buffer: Always return total amount of read bytes
Date: Wed, 17 May 2023 02:24:56 +0200 [thread overview]
Message-ID: <20230517002456.GB9395@pevik> (raw)
In-Reply-To: <20230516165929.1343864-2-khorenko@virtuozzo.com>
> This issue behind this patch is noticed while fixing the
> lio_write_buffer().
> Here in lio_read_buffer() we have similar situation: in case of a
> partial read, we cycle, but lio_read_buffer() returns back the amount of
> bytes read during the last read() call while it's expected to return the
> whole amount of read bytes.
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
> ---
> lib/tlibio.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> diff --git a/lib/tlibio.c b/lib/tlibio.c
> index 8298e2de9..604663307 100644
> --- a/lib/tlibio.c
> +++ b/lib/tlibio.c
> @@ -1112,6 +1112,8 @@ int lio_read_buffer(int fd, /* open file descriptor */
> long wrd) /* to allow future features, use zero for now */
> {
> int ret = 0; /* syscall return or used to get random method */
> + int totally_read = 0; /* as we cycle reads in case of partial reads, */
> + /* we have to report up total bytes read */
Again, multiline comment would be more readable:
/* as we cycle reads in case of partial reads,
* we have to report up total bytes read */
int totally_read = 0;
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> char *io_type; /* Holds string of type of io */
> int listio_cmd; /* Holds the listio/lio_listio cmd */
> int omethod = method;
> @@ -1323,13 +1325,14 @@ int lio_read_buffer(int fd, /* open file descriptor */
> fd, size, ret);
> size -= ret;
> buffer += ret;
> + totally_read += ret;
> } else {
> if (Debug_level > 1)
> printf
> ("DEBUG %s/%d: read completed without error (ret %d)\n",
> __FILE__, __LINE__, ret);
> - return ret;
> + return totally_read + ret;
> }
> }
> wait4sync_io(fd, 1);
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-05-16 22:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 16:59 [LTP] [PATCH 1/2] scsi_debug/tlibio/lio_write_buffer: Always return total amount of written bytes Konstantin Khorenko via ltp
2023-05-16 16:59 ` [LTP] [PATCH 2/2] scsi_debug/tlibio/lio_read_buffer: Always return total amount of read bytes Konstantin Khorenko via ltp
2023-05-17 0:24 ` Petr Vorel [this message]
2023-05-17 0:23 ` [LTP] [PATCH 1/2] scsi_debug/tlibio/lio_write_buffer: Always return total amount of written bytes Petr Vorel
2023-05-18 7:46 ` Konstantin Khorenko via ltp
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=20230517002456.GB9395@pevik \
--to=pvorel@suse.cz \
--cc=khorenko@virtuozzo.com \
--cc=ltp@lists.linux.it \
/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.