Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1575427

Re: [PATCH] f2fs: enhance lookup xattr

From Chao Yu <yuchao0@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH] f2fs: enhance lookup xattr
Date 2017-02-07 08:30 +0100
Message-ID <t88nU-8dU-7@gated-at.bofh.it> (permalink)
References <t38HU-4mc-29@gated-at.bofh.it> <t4P85-2fM-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Jaegeuk,

On 2017/1/29 11:58, Jaegeuk Kim wrote:
> Hi Chao,
> 
> On 01/24, Chao Yu wrote:
> 
> ...
> 
>>  
>> -	error = read_all_xattrs(inode, ipage, &base_addr);
>> +	error = lookup_all_xattrs(inode, ipage, index, len, name,
>> +				&entry, &base_addr);
>>  	if (error)
>>  		return error;
>>  
>> -	entry = __find_xattr(base_addr, index, len, name);
>> -	if (IS_XATTR_LAST_ENTRY(entry)) {
>> -		error = -ENODATA;
>> -		goto cleanup;
>> -	}
>> -
>> -	size = le16_to_cpu(entry->e_value_size);
>> +	size = __le16_to_cpu(entry->e_value_size);
> 
> Looks good to me, except __le16_to_cpu() here.
> Do we need to use this instead of le16_to_cpu()?

Indeed, no needed. :)

Thanks,

> 
> Thanks,
> 
>>  
>>  	if (buffer && size > buffer_size) {
>>  		error = -ERANGE;
>> -		goto cleanup;
>> +		goto out;
>>  	}
>>  
>> +	pval = entry->e_name + entry->e_name_len;
>> +
>>  	if (buffer) {
>>  		char *pval = entry->e_name + entry->e_name_len;
>>  		memcpy(buffer, pval, size);
>>  	}
>>  	error = size;
>> -
>> -cleanup:
>> +out:
>>  	kzfree(base_addr);
>>  	return error;
>>  }
>> diff --git a/fs/f2fs/xattr.h b/fs/f2fs/xattr.h
>> index f990de20cdcd..d5a94928c116 100644
>> --- a/fs/f2fs/xattr.h
>> +++ b/fs/f2fs/xattr.h
>> @@ -72,9 +72,10 @@ struct f2fs_xattr_entry {
>>  		for (entry = XATTR_FIRST_ENTRY(addr);\
>>  				!IS_XATTR_LAST_ENTRY(entry);\
>>  				entry = XATTR_NEXT_ENTRY(entry))
>> -
>> -#define MIN_OFFSET(i)	XATTR_ALIGN(inline_xattr_size(i) + PAGE_SIZE -	\
>> -				sizeof(struct node_footer) - sizeof(__u32))
>> +#define MAX_XATTR_BLOCK_SIZE	(PAGE_SIZE - sizeof(struct node_footer))
>> +#define VALID_XATTR_BLOCK_SIZE	(MAX_XATTR_BLOCK_SIZE - sizeof(__u32))
>> +#define MIN_OFFSET(i)		XATTR_ALIGN(inline_xattr_size(i) +	\
>> +						VALID_XATTR_BLOCK_SIZE)
>>  
>>  #define MAX_VALUE_LEN(i)	(MIN_OFFSET(i) -			\
>>  				sizeof(struct f2fs_xattr_header) -	\
>> -- 
>> 2.8.2.295.g3f1c1d0
> 
> .
> 

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH] f2fs: enhance lookup xattr Chao Yu <yuchao0@huawei.com> - 2017-02-07 08:30 +0100

csiph-web