[Ocfs2-devel] [PATCH v2 4/5] ocfs2: ocfs2_mount_volume does cleanup job before return error

heming.zhao at suse.com heming.zhao at suse.com
Thu Apr 14 09:14:54 UTC 2022


On 4/13/22 19:25, Joseph Qi wrote:
> 
> 
> On 4/13/22 4:29 PM, Heming Zhao wrote:
>> After this patch, when error, ocfs2_fill_super doesn't take care to
>> release resources which are allocated in ocfs2_mount_volume.
>>
>> Signed-off-by: Heming Zhao <heming.zhao at suse.com>
>> ---
>>   fs/ocfs2/super.c | 42 +++++++++++++++++++++++++++---------------
>>   1 file changed, 27 insertions(+), 15 deletions(-)
>> ... ...
>> -leave:
>> -	if (unlock_super)
>> -		ocfs2_super_unlock(osb, 1);
>> +	ocfs2_super_unlock(osb, 1);
>> +	return 0;
>>   
>> +out_system_inodes:
>> +	if (osb->local_alloc_state == OCFS2_LA_ENABLED)
>> +		ocfs2_shutdown_local_alloc(osb);
>> +	ocfs2_release_system_inodes(osb);
>> +	ocfs2_journal_shutdown(osb);
>> +out_super_lock:
>> +	ocfs2_super_unlock(osb, 1);
>> +out_dlm:
>> +	ocfs2_dlm_shutdown(osb, 0);
>> +out:
>>   	return status;
>>   }
>>   
>> @@ -2393,14 +2402,17 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di,
>>   	return status;
>>   }
>>   
>> +/*
>> + * If this function returns failure, caller responds to release
>> + * here alloced resources.
>> + */
>>   static int ocfs2_check_volume(struct ocfs2_super *osb)
>>   {
>>   	int status;
>>   	int dirty;
>>   	int local;
>> -	struct ocfs2_dinode *local_alloc = NULL; /* only used if we
>> -						  * recover
>> -						  * ourselves. */
>> +    /* only used if we recover ourselves. */
> 
> Malformed. Actually I don't think we have to touch this function.
> 

OK. Will roll back my changes.
My original intention is to add comment at front of this function to info caller.
To remind them to don't forget to release the alloced resources when fails.

- Heming




More information about the Ocfs2-devel mailing list