OS-7640: ltp io_setup01 fails wanting EAGAIN, gets EINVAL

Details

Issue Type:Bug
Priority:4 - Normal
Status:Open
Created at:2019-03-06T16:09:45.923Z
Updated at:2019-07-12T22:11:40.058Z

People

Created by:Former user
Reported by:Former user

Labels

lxbrand

Description

io_setup_01 fails with:

root@7c5eb456-134f-49d5-a9f4-845bd48c8161:/opt/ltp#  ./testcases/bin/io_setup01
tst_test.c:982: INFO: Timeout per run is 0h 05m 00s
io_setup01.c:75: PASS: io_setup() passed as expected
io_setup01.c:56: PASS: io_setup() failed as expected, returned -EINVAL
io_setup01.c:56: PASS: io_setup() failed as expected, returned -EINVAL
io_setup01.c:56: PASS: io_setup() failed as expected, returned -EFAULT
io_setup01.c:60: FAIL: io_setup() failed unexpectedly, returned -EINVAL expected -EAGAIN/EWOULDBLOCK

Summary:
passed   4
failed   1
skipped  0
warnings 0

The failing test is at line 91:

 79 static void verify_io_setup(void)
 80 {
 81         io_context_t ctx;
 82         unsigned int aio_max = 0;
 83
 84         verify_success(1, &ctx, 0);
 85         verify_failure(1, &ctx, 1, EINVAL);
 86         verify_failure(-1, &ctx, 0, EINVAL);
 87         verify_failure(1, NULL, 0, EFAULT);
 88
 89         if (!access("/proc/sys/fs/aio-max-nr", F_OK)) {
 90                 SAFE_FILE_SCANF("/proc/sys/fs/aio-max-nr", "%u", &aio_max);
 91                 verify_failure(aio_max + 1, &ctx, 0, EAGAIN);
 92         } else {
 93                 tst_res(TCONF, "the aio-max-nr file did not exist");
 94         }
 95 }

That is, it is looking for the "aio max number" and trying to set up an aio with a number one larger than that. It expects EAGAIN (when it gets this invalid value, sigh) but gets EINVAL.

lx_io_setup() contains:

603  	/* The cid in user-land must be NULL to start */
604  	if (cid != NULL || nr_events > LX_AIO_MAX_NR)
605  		return (set_errno(EINVAL));
606  
607  	mutex_enter(&lxzd->lxzd_lock);
608  	if ((nr_events + lxzd->lxzd_aio_nr) > LX_AIO_MAX_NR) {
609  		mutex_exit(&lxzd->lxzd_lock);
610  		return (set_errno(EAGAIN));
611  	}

The check at line 604 is the reason for this failure. Removing || nr_events > LX_AIO_MAX_NR from that line looks like it will make it so that EAGAIN is returned at line 610.

Comments