[LTP] 答复: [PATCH] aio_error/3-1.c: Call write before aio_error

Zouwei (Samuel) zou_wei@huawei.com
Tue Apr 7 09:25:27 CEST 2020


Hi All,

Does this patch need to be updated or modified?

Best Regards
Zou Wei

-----邮件原件-----
发件人: Yang Xu [mailto:xuyang2018.jy@cn.fujitsu.com] 
发送时间: 2020年3月20日 16:15
收件人: Zouwei (Samuel) <zou_wei@huawei.com>
抄送: ltp@lists.linux.it
主题: Re: [LTP] [PATCH] aio_error/3-1.c: Call write before aio_error

Hi Zou

> In the case, if there is no write/read operation before aio_error, 
> aio_error will judge that the current asynchronous I/O has been 
> successfully completed, then return 0, case failed.
> 
> After the write/read operation is added, because aiocb.aio_reqprio is 
> -1, the write/read operation will return -1, so aio_error will also 
> return EINVAL because it detects that the asynchronous I/O has not completed successfully.
I have seen glibc code about aio_write and aio_err function, you are right. Thanks for the fix.

Looks good to me.
Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>

Best Regards
Yang Xu
> 
> ps:
> http://man7.org/linux/man-pages/man3/aio_error.3.html
> RETURN VALUE
>         This function returns one of the following:
>         *  EINPROGRESS, if the request has not been completed yet.
>         *  ECANCELED, if the request was canceled.
>         *  0, if the request completed successfully.
>         *  A positive error number, if the asynchronous I/O operation failed.
>            This is the same value that would have been stored in the errno
>            variable in the case of a synchronous read(2), write(2), fsync(2),
>            or fdatasync(2) call.
> ERRORS
>         EINVAL aiocbp does not point at a control block for an asynchronous
>                I/O request of which the return status (see aio_return(3)) has
>                not been retrieved yet.
> 
> Signed-off-by: Zou Wei <zou_wei@huawei.com>
> ---
>   .../open_posix_testsuite/conformance/interfaces/aio_error/3-1.c      | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git 
> a/testcases/open_posix_testsuite/conformance/interfaces/aio_error/3-1.
> c 
> b/testcases/open_posix_testsuite/conformance/interfaces/aio_error/3-1.
> c
> index 9ccda05..2b2c65b 100644
> --- 
> a/testcases/open_posix_testsuite/conformance/interfaces/aio_error/3-1.
> c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_error/
> +++ 3-1.c
> @@ -64,6 +64,11 @@ int main(void)
>   	aiocb.aio_reqprio = -1;
>   	aiocb.aio_nbytes = BUF_SIZE;
> 
> +	if (aio_write(&aiocb) != -1) {
> +                printf(TNAME " Error at aio_write(): %s\n", strerror(errno));
> +                return PTS_FAIL;
> +        }
> +
>   	ret = aio_error(&aiocb);
> 
>   	if (ret != EINVAL) {
> --
> 2.6.2
> 
> 




More information about the ltp mailing list