[Ocfs2-devel] 答复: Bug report and patch request reviews, thanks

Guozhonghua guozhonghua at h3c.com
Mon Sep 1 01:10:11 PDT 2014


The variables ip_clusters type is unsigned int, and c_to_s_bits type is int.
So after bits moved, the result will int, that may be overflowed.

It is better to return the block count directly.
return (blkcnt_t)OCFS2_I(inode)->ip_clusters << c_to_s_bits;

-----邮件原件-----
发件人: Joseph Qi [mailto:joseph.qi at huawei.com]
发送时间: 2014年9月1日 15:37
收件人: guozhonghua 02084
抄送: ocfs2-devel at oss.oracle.com
主题: Re: [Ocfs2-devel] Bug report and patch request reviews, thanks

On 2014/9/1 15:14, Guozhonghua wrote:
> Hi¸ we test one file which is larger than 2T, then we get the information wrong.
>
>
>
> Without patch, the result is as below, OCFS2, and you can see that size of the file and the blocks is not well:
>
>     # ls -al /vms/ocfs2lv/test_base_0
>
>     -rw------- 1 root root 2618930032640 Aug 29 19:00
> /vms/ocfs2lv/test_base_0
>
>
>
>     # stat --format="%b %B" /vms/ocfs2lv/test_base_0
>
>     820127744 512
>
>
>
>     # ls -alsi /vms/ocfs2lv/test_base_0
>
>     2100482 410063872 -rw------- 1 root root 2618930032640 Aug 29
> 19:00 /vms/ocfs2lv/test_base_0
>
>
>
>     # ls -al /vms/ocfs2lv/test_base_0
>
>     -rw------- 1 root root 2618930032640 Aug 29 19:00
> /vms/ocfs2lv/test_base_0
>
>
>
> With patch, the information of the file is correct, and the file may be have some parse space in it, so the diff of the space can be ingnored:
>
>         # stat --format "%b %B" /vms/ocfs2lv/test_base_0
>
>     5115095040 512
>
>
>
>     # ls -alsi /vms/ocfs2lv/test_base_0
>
>     2100482 2557547520 -rw------- 1 root root 2618930032640 Aug 29
> 19:00 /vms/ocfs2lv/test_base_0
>
>
>
> The patch is as below, we known that the blocks count is not correct, but we are not sure the patch has any side-effect with other part of OCFS2, so requesting reviews.
>
> Would some OCFS2 experts have time to review it and merged it into
> main line? Thanks
>
>
>
> ---  inode.h    2014-08-09 14:23:42.609594669 +0800
>
> +++ inode.h     2014-09-01 14:30:37.224294249 +0800
>
>
>
> @@ -157,7 +155,7 @@ static inline blkcnt_t
> ocfs2_inode_sector_count(struct inode *inode)
>
> {
>
>       int c_to_s_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits - 9;
>
> -       return (blkcnt_t)(OCFS2_I(inode)->ip_clusters << c_to_s_bits);
>
> +      return (blkcnt_t)((unsigned long)OCFS2_I(inode)->ip_clusters <<
> + c_to_s_bits);
>
> }

So you mean the bit operation may lead to overflow if cluster is 1MB?
Why not delete the parentheses directly?

return (blkcnt_t)OCFS2_I(inode)->ip_clusters << c_to_s_bits;
-------------------------------------------------------------------------------------------------------------------------------------
本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出
的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、
或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本
邮件!
This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!


More information about the Ocfs2-devel mailing list