[Ocfs2-tools-devel] [PATCH] o2image: back-up xattr tree for regular file

piaojun piaojun at huawei.com
Wed May 24 23:44:18 PDT 2017


Hi Joseph,

On 2017/5/23 9:19, Joseph Qi wrote:
> Redirect to the right ocfs2-tools-devel mail list.
> 
> IIRC, OCFS2_CHAIN_FL is a allocator flag and will only occurs in system
> file. So I am curious about how regular file goes in traverse_chains
> rather than traverse_xb.
> 
> Thanks,
> Joseph
> 
Sorry, my last comment is wrong, if the regular file has been marked as
xattr but has no xattr btree, 'di->i_xattr_loc' is set zero. that will
go in traverse_extents(). so we need check 'OCFS2_HAS_XATTR_FL' and
'di->i_xattr_loc' at the same time.

Thanks,
Jun

> On 17/5/20 09:56, piaojun wrote:
>> when traversing regular file's inode with xattr btree in
>> traverse_inode(), we will get into traverse_chains() rather than
>> traverse_xb(). so xattr tree is not back-up actually.
>>
>> Signed-off-by: Jun Piao <piaojun at huawei.com>
>> ---
>>  o2image/o2image.c | 18 ++++++++++--------
>>  1 file changed, 10 insertions(+), 8 deletions(-)
>>
>> diff --git a/o2image/o2image.c b/o2image/o2image.c
>> index ee62acf..c56bbcf 100644
>> --- a/o2image/o2image.c
>> +++ b/o2image/o2image.c
>> @@ -256,9 +256,16 @@ static errcode_t traverse_inode(ocfs2_filesys *ofs, uint64_t inode)
>>  	 *
>>  	 * NOTE: we do need to handle its xattr btree if exists.
>>  	 */
>> -	if (!S_ISDIR(di->i_mode) && !(di->i_flags & OCFS2_SYSTEM_FL) &&
>> -	    !(di->i_dyn_features & OCFS2_HAS_XATTR_FL))
>> +	if (!S_ISDIR(di->i_mode) && !(di->i_flags & OCFS2_SYSTEM_FL)) {
>> +		if ((di->i_dyn_features & OCFS2_HAS_XATTR_FL) && di->i_xattr_loc) {
>> +			/* traverse xattr btree to map bucket leaves */
>> +			ret = traverse_xb(ofs, di->i_xattr_loc);
>> +			if (ret)
>> +				com_err(program_name, ret, "while traversing xattr tree"
>> +					" %"PRIu64"", inode);
>> +		}
>>  		goto out;
>> +	}
>>
>>  	/* Read and traverse group descriptors */
>>  	if (di->i_flags & OCFS2_SYSTEM_FL)
>> @@ -291,9 +298,6 @@ static errcode_t traverse_inode(ocfs2_filesys *ofs, uint64_t inode)
>>  		ret = traverse_chains(ofs, &(di->id2.i_chain), dump_type);
>>  	else if (di->i_flags & OCFS2_DEALLOC_FL)
>>  		ret = mark_dealloc_bits(ofs, &(di->id2.i_dealloc));
>> -	else if ((di->i_dyn_features & OCFS2_HAS_XATTR_FL) && di->i_xattr_loc)
>> -		/* Do need to traverse xattr btree to map bucket leaves */
>> -		ret = traverse_xb(ofs, di->i_xattr_loc);
>>  	else {
>>  		/*
>>  		 * Don't check superblock flag for the dir indexing
>> @@ -318,11 +322,9 @@ static errcode_t traverse_inode(ocfs2_filesys *ofs, uint64_t inode)
>>  	}
>>
>>  out_error:
>> -	if (ret) {
>> +	if (ret)
>>  		com_err(program_name, ret, "while scanning inode %"PRIu64"",
>>  			inode);
>> -		goto out;
>> -	}
>>  out:
>>  	if (buf)
>>  		ocfs2_free(&buf);
>>
> .
> 



More information about the Ocfs2-tools-devel mailing list