Re: [PATCH v2 2/2] fstress: add suport for using liburing getxattr

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




On 12/12/21 7:10 AM, Eryu Guan wrote:
> On Tue, Nov 30, 2021 at 09:52:02PM -0800, Stefan Roesch wrote:
>> Liburing added support for getxattr. This change adds
>> support for this this in fsstress when fsstress is built
>> with liburing support.
>>
>> Signed-off-by: Stefan Roesch <shr@xxxxxx>
>> ---
>>  ltp/fsstress.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++----
>>  1 file changed, 59 insertions(+), 4 deletions(-)
>>
>> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
>> index aba7c6f7..5a18701a 100644
>> --- a/ltp/fsstress.c
>> +++ b/ltp/fsstress.c
>> @@ -145,6 +145,7 @@ typedef enum {
>>  	OP_URING_WRITE,
>>  	OP_WRITE,
>>  	OP_WRITEV,
>> +	OP_URING_GETXATTR,
>>  	OP_URING_SETXATTR,
>>  	OP_LAST
>>  } opty_t;
>> @@ -152,6 +153,7 @@ typedef enum {
>>  typedef long long opnum_t;
>>  
>>  typedef void (*opfnc_t)(opnum_t, long);
>> +typedef ssize_t (*getxattr_cbk)(const char *, const char *, void *, size_t);
>>  typedef int (*setxattr_cbk)(const char *, const char *, const void *, size_t, int);
>>  
>>  typedef struct opdesc {
>> @@ -279,6 +281,7 @@ void	uring_read_f(opnum_t, long);
>>  void	uring_write_f(opnum_t, long);
>>  void	write_f(opnum_t, long);
>>  void	writev_f(opnum_t, long);
>> +void	uring_getxattr_f(opnum_t, long);
>>  void	uring_setxattr_f(opnum_t, long);
>>  char	*xattr_flag_to_string(int);
>>  
>> @@ -350,6 +353,7 @@ opdesc_t	ops[] = {
>>  	{ OP_URING_WRITE, "uring_write", uring_write_f, 1, 1 },
>>  	{ OP_WRITE, "write", write_f, 4, 1 },
>>  	{ OP_WRITEV, "writev", writev_f, 4, 1 },
>> +	{ OP_URING_GETXATTR, "uring_getxattr", uring_getxattr_f, 1, 0 },
>>  	{ OP_URING_SETXATTR, "uring_setxattr", uring_setxattr_f, 1, 1 },
>>  }, *ops_end;
>>  
>> @@ -3899,8 +3903,44 @@ getdents_f(opnum_t opno, long r)
>>  	closedir(dir);
>>  }
>>  
>> -void
>> -getfattr_f(opnum_t opno, long r)
>> +static ssize_t
>> +io_uring_getxattr(const char *path, const char *name, void *value, size_t size)
>> +{
>> +	struct io_uring_sqe *sqe;
>> +	struct io_uring_cqe *cqe;
>> +	int ret;
>> +
>> +	sqe = io_uring_get_sqe(&ring);
>> +	if (!sqe) {
>> +		printf("io_uring_get_sqe failed\n");
>> +		ret = -1;
>> +		goto out;
>> +	}
>> +
>> +	io_uring_prep_getxattr(sqe, name, value, path, size);
>> +
>> +	ret = io_uring_submit_and_wait(&ring, 1);
>> +	if (ret != 1) {
>> +		printf("io_uring_submit_and_wait failed, ret=%d\n", ret);
>> +		ret = -1;
>> +		goto out;
>> +    	}
>> +
>> +	ret = io_uring_wait_cqe(&ring, &cqe);
>> +	if (ret < 0) {
>> +		printf("io_uring_wait_cqe failed, ret=%d\n", ret);
>> +		goto out;
>> +	}
>> +
>> +	ret = cqe->res;
>> +	io_uring_cqe_seen(&ring, cqe);
>> +
>> +out:
>> +	return ret;
>> +}
>> +
>> +static void
>> +getfattr_f_cbk(opnum_t opno, long r, getxattr_cbk cbk)
>>  {
>>  	fent_t	        *fep;
>>  	int		e;
>> @@ -3936,7 +3976,7 @@ getfattr_f(opnum_t opno, long r)
>>  		goto out;
>>  	}
>>  
>> -	value_len = getxattr(f.path, name, NULL, 0);
>> +        value_len = cbk(f.path, name, NULL, 0);
> 
> Use tab for indention here.
> 
> Thanks,
> Eryu
> 

Fixed with v4.

>>  	if (value_len < 0) {
>>  		if (v)
>>  			printf("%d/%lld: getfattr file %s name %s failed %d\n",
>> @@ -3958,7 +3998,8 @@ getfattr_f(opnum_t opno, long r)
>>  		goto out;
>>  	}
>>  
>> -	e = getxattr(f.path, name, value, value_len) < 0 ? errno : 0;
>> +	e = cbk(f.path, name, value, value_len) < 0 ? errno : 0;
>> +
>>  out_log:
>>  	if (v)
>>  		printf("%d/%lld: getfattr file %s name %s value length %d %d\n",
>> @@ -3968,6 +4009,20 @@ out:
>>  	free_pathname(&f);
>>  }
>>  
>> +void
>> +uring_getxattr_f(opnum_t opno, long r)
>> +{
>> +#ifdef URING
>> +	getfattr_f_cbk(opno, r, io_uring_getxattr);
>> +#endif
>> +}
>> +
>> +void
>> +getfattr_f(opnum_t opno, long r)
>> +{
>> +	getfattr_f_cbk(opno, r, getxattr);
>> +}
>> +
>>  void
>>  link_f(opnum_t opno, long r)
>>  {
>> -- 
>> 2.30.2



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux