linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment()
@ 2023-06-02  5:20 Noboru Asai
  2023-06-02  6:08 ` Gao Xiang
  2023-06-02  6:39 ` Yue Hu
  0 siblings, 2 replies; 4+ messages in thread
From: Noboru Asai @ 2023-06-02  5:20 UTC (permalink / raw)
  To: xiang, chao, huyue2; +Cc: linux-erofs

The variable 'ctx->pclustersize' could be larger than max pclustersize.

Signed-off-by: Noboru Asai <asai@sijam.com>
---
 lib/compress.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/compress.c b/lib/compress.c
index 2e1dfb3..e943056 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -359,8 +359,9 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_vle_compress_ctx *ctx,
 
 	/* try to fix again if it gets larger (should be rare) */
 	if (inode->fragment_size < newsize) {
-		ctx->pclustersize = roundup(newsize - inode->fragment_size,
-					    erofs_blksiz());
+		ctx->pclustersize = min(z_erofs_get_max_pclusterblks(inode) * erofs_blksiz(),
+					roundup(newsize - inode->fragment_size,
+						erofs_blksiz()));
 		return false;
 	}
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment()
  2023-06-02  5:20 [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment() Noboru Asai
@ 2023-06-02  6:08 ` Gao Xiang
  2023-06-02  6:25   ` 答复: [External Mail]Re: " 孙士杰 via Linux-erofs
  2023-06-02  6:39 ` Yue Hu
  1 sibling, 1 reply; 4+ messages in thread
From: Gao Xiang @ 2023-06-02  6:08 UTC (permalink / raw)
  To: huyue2; +Cc: linux-erofs, 孙士杰

Hi Yue,

On 2023/6/2 13:20, Noboru Asai wrote:
> The variable 'ctx->pclustersize' could be larger than max pclustersize.
> 
> Signed-off-by: Noboru Asai <asai@sijam.com>

Please take a look at this patch.
+Cc Shijie Sun.

Thanks,
Gao Xiang

> ---
>   lib/compress.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/compress.c b/lib/compress.c
> index 2e1dfb3..e943056 100644
> --- a/lib/compress.c
> +++ b/lib/compress.c
> @@ -359,8 +359,9 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_vle_compress_ctx *ctx,
>   
>   	/* try to fix again if it gets larger (should be rare) */
>   	if (inode->fragment_size < newsize) {
> -		ctx->pclustersize = roundup(newsize - inode->fragment_size,
> -					    erofs_blksiz());
> +		ctx->pclustersize = min(z_erofs_get_max_pclusterblks(inode) * erofs_blksiz(),
> +					roundup(newsize - inode->fragment_size,
> +						erofs_blksiz()));
>   		return false;
>   	}
>   

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 答复: [External Mail]Re: [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment()
  2023-06-02  6:08 ` Gao Xiang
@ 2023-06-02  6:25   ` 孙士杰 via Linux-erofs
  0 siblings, 0 replies; 4+ messages in thread
From: 孙士杰 via Linux-erofs @ 2023-06-02  6:25 UTC (permalink / raw)
  To: Gao Xiang, huyue2; +Cc: linux-erofs

[-- Attachment #1: Type: text/plain, Size: 2300 bytes --]

好的,非常感谢

________________________________
发件人: Gao Xiang <hsiangkao@linux.alibaba.com>
发送时间: 2023年6月2日 14:08:33
收件人: huyue2@coolpad.com
抄送: linux-erofs@lists.ozlabs.org; Noboru Asai; Gao Xiang; Chao Yu; 孙士杰
主题: [External Mail]Re: [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment()

[外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈

Hi Yue,

On 2023/6/2 13:20, Noboru Asai wrote:
> The variable 'ctx->pclustersize' could be larger than max pclustersize.
>
> Signed-off-by: Noboru Asai <asai@sijam.com>

Please take a look at this patch.
+Cc Shijie Sun.

Thanks,
Gao Xiang

> ---
>   lib/compress.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/compress.c b/lib/compress.c
> index 2e1dfb3..e943056 100644
> --- a/lib/compress.c
> +++ b/lib/compress.c
> @@ -359,8 +359,9 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_vle_compress_ctx *ctx,
>
>       /* try to fix again if it gets larger (should be rare) */
>       if (inode->fragment_size < newsize) {
> -             ctx->pclustersize = roundup(newsize - inode->fragment_size,
> -                                         erofs_blksiz());
> +             ctx->pclustersize = min(z_erofs_get_max_pclusterblks(inode) * erofs_blksiz(),
> +                                     roundup(newsize - inode->fragment_size,
> +                                             erofs_blksiz()));
>               return false;
>       }
>
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, 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!******/#

[-- Attachment #2: Type: text/html, Size: 4436 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment()
  2023-06-02  5:20 [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment() Noboru Asai
  2023-06-02  6:08 ` Gao Xiang
@ 2023-06-02  6:39 ` Yue Hu
  1 sibling, 0 replies; 4+ messages in thread
From: Yue Hu @ 2023-06-02  6:39 UTC (permalink / raw)
  To: Noboru Asai; +Cc: linux-erofs, huyue2, zhangwen

On Fri,  2 Jun 2023 14:20:39 +0900
Noboru Asai <asai@sijam.com> wrote:

> The variable 'ctx->pclustersize' could be larger than max pclustersize.
> 
> Signed-off-by: Noboru Asai <asai@sijam.com>
> ---
>  lib/compress.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/compress.c b/lib/compress.c
> index 2e1dfb3..e943056 100644
> --- a/lib/compress.c
> +++ b/lib/compress.c
> @@ -359,8 +359,9 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_vle_compress_ctx *ctx,
>  
>  	/* try to fix again if it gets larger (should be rare) */
>  	if (inode->fragment_size < newsize) {
> -		ctx->pclustersize = roundup(newsize - inode->fragment_size,
> -					    erofs_blksiz());
> +		ctx->pclustersize = min(z_erofs_get_max_pclusterblks(inode) * erofs_blksiz(),
> +					roundup(newsize - inode->fragment_size,
> +						erofs_blksiz()));

Looks good to me.

Reviewed-by: Yue Hu <huyue2@coolpad.com>

>  		return false;
>  	}
>  


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-02  6:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-02  5:20 [PATCH] erofs-utils: limit pclustersize in z_erofs_fixup_deduped_fragment() Noboru Asai
2023-06-02  6:08 ` Gao Xiang
2023-06-02  6:25   ` 答复: [External Mail]Re: " 孙士杰 via Linux-erofs
2023-06-02  6:39 ` Yue Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).