[Ocfs2-tools-devel] [PATCH 2/5] tunefs.ocfs2: Correct the way of calculating try_clusters
piaojun
piaojun at huawei.com
Tue Apr 28 17:25:58 PDT 2015
Hi Goldwyn,
There is a little difference between ocfs2_clusters_in_bytes() and
ocfs2_bytes_to_clusters(). In ocfs2_clusters_in_bytes(), the number of
clusters calculated is always one more than maximum clusters of new
size of device. In ocfs2_bytes_to_clusters(), the number of clusters
calculated is the same with maximum clusters of new size. The former
will cause an error that 'try_clusters' is larger than
'device_clusters'.
在 2015/4/24 22:37, Goldwyn Rodrigues 写道:
> Hi Piaojun,
>
> On 04/02/2015 07:27 AM, piaojun wrote:
>> In check_new_size(), ocfs2_clusters_in_bytes() should be replaced with
>> ocfs2_bytes_to_clusters() in case try_clusters is larger than
>> device_clusters.
>>
>> Signed-off-by: Jun Piao <piaojun at huawei.com>
>> Reviewed-by: Alex Chen <alex.chen at huawei.com>
>>
>> ---
>> tunefs.ocfs2/op_resize_volume.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tunefs.ocfs2/op_resize_volume.c b/tunefs.ocfs2/op_resize_volume.c
>> index 076bda0..96eef66 100644
>> --- a/tunefs.ocfs2/op_resize_volume.c
>> +++ b/tunefs.ocfs2/op_resize_volume.c
>> @@ -506,7 +506,7 @@ static errcode_t check_new_size(ocfs2_filesys *fs, uint64_t new_size,
>> errcode_t ret;
>> uint64_t max_bytes = ocfs2_clusters_to_bytes(fs, UINT32_MAX);
>> uint64_t device_bytes;
>> - uint32_t try_clusters = ocfs2_clusters_in_bytes(fs, new_size);
>> + uint32_t try_clusters = ocfs2_bytes_to_clusters(fs, new_size);
>
> Both these functions are the same. See their respective definitions in ocfs2.h
>
> However, ocfs2.h needs to be cleaned to be closer to the one with the one in linux/fs/ocfs2.h. In the kernel's ocfs2.h, all _in_ functions have been removed.
>
>> uint64_t try_blocks;
>> uint64_t device_blocks;
>> uint64_t device_clusters; /* 64bits because devices can be larger
>>
>
More information about the Ocfs2-tools-devel
mailing list