Re: [PATCH v3 1/4] fsstress: add IO_URING read and write operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/3/20 6:42 AM, Brian Foster wrote:
> On Sun, Aug 23, 2020 at 02:30:29PM +0800, Zorro Lang wrote:
>> IO_URING is a new feature of curent linux kernel, add basic IO_URING
>> read/write into fsstess to cover this kind of IO testing.
>>
>> Signed-off-by: Zorro Lang <zlang@xxxxxxxxxx>
>> ---
>>  README                 |   4 +-
>>  configure.ac           |   1 +
>>  include/builddefs.in   |   1 +
>>  ltp/Makefile           |   5 ++
>>  ltp/fsstress.c         | 139 ++++++++++++++++++++++++++++++++++++++++-
>>  m4/Makefile            |   1 +
>>  m4/package_liburing.m4 |   4 ++
>>  7 files changed, 152 insertions(+), 3 deletions(-)
>>  create mode 100644 m4/package_liburing.m4
>>
> ...
>> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
>> index 709fdeec..7a0e278a 100644
>> --- a/ltp/fsstress.c
>> +++ b/ltp/fsstress.c
> ...
>> @@ -2170,6 +2189,108 @@ do_aio_rw(int opno, long r, int flags)
>>  }
>>  #endif
>>  
>> +#ifdef URING
>> +void
>> +do_uring_rw(int opno, long r, int flags)
>> +{
>> +	char		*buf;
>> +	int		e;
>> +	pathname_t	f;
>> +	int		fd;
>> +	size_t		len;
>> +	int64_t		lr;
>> +	off64_t		off;
>> +	struct stat64	stb;
>> +	int		v;
>> +	char		st[1024];
>> +	struct io_uring_sqe	*sqe;
>> +	struct io_uring_cqe	*cqe;
>> +	struct iovec	iovec;
>> +	int		iswrite = (flags & (O_WRONLY | O_RDWR)) ? 1 : 0;
>> +
>> +	init_pathname(&f);
>> +	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
>> +		if (v)
>> +			printf("%d/%d: do_uring_rw - no filename\n", procid, opno);
>> +		goto uring_out3;
>> +	}
>> +	fd = open_path(&f, flags);
>> +	e = fd < 0 ? errno : 0;
>> +	check_cwd();
>> +	if (fd < 0) {
>> +		if (v)
>> +			printf("%d/%d: do_uring_rw - open %s failed %d\n",
>> +			       procid, opno, f.path, e);
>> +		goto uring_out3;
>> +	}
>> +	if (fstat64(fd, &stb) < 0) {
>> +		if (v)
>> +			printf("%d/%d: do_uring_rw - fstat64 %s failed %d\n",
>> +			       procid, opno, f.path, errno);
>> +		goto uring_out2;
>> +	}
>> +	inode_info(st, sizeof(st), &stb, v);
>> +	if (!iswrite && stb.st_size == 0) {
>> +		if (v)
>> +			printf("%d/%d: do_uring_rw - %s%s zero size\n", procid, opno,
>> +			       f.path, st);
>> +		goto uring_out2;
>> +	}
>> +	sqe = io_uring_get_sqe(&ring);
>> +	if (!sqe) {
>> +		if (v)
>> +			printf("%d/%d: do_uring_rw - io_uring_get_sqe failed\n",
>> +			       procid, opno);
>> +		goto uring_out2;
>> +	}
> 
> I'm not familiar with the io_uring bits, but do we have to do anything
> to clean up this sqe object (or the cqe) before we return?

The cqe/sqe resources are tied to the ring, so as long as
io_uring_queue_exit() is called, then they are freed. And it is after
the run, so looks fine to me.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux