Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Yue Hu <zbestahu@gmail.com>
To: Gao Xiang <hsiangkao@linux.alibaba.com>
Cc: huyue2@coolpad.com, linux-erofs@lists.ozlabs.org, zhangwen@coolpad.com
Subject: Re: [PATCH 1/3] erofs-utils: get rid of useless nr_dup
Date: Wed, 1 Mar 2023 19:05:03 +0800	[thread overview]
Message-ID: <20230301190503.00006aab.zbestahu@gmail.com> (raw)
In-Reply-To: <20230228185459.117762-1-hsiangkao@linux.alibaba.com>

On Wed,  1 Mar 2023 02:54:57 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:

> Also refine the longest detection.
> 
> Fixes: 990c7e383795 ("erofs-utils: mkfs: support fragment deduplication")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>

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

> ---
>  lib/fragments.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/lib/fragments.c b/lib/fragments.c
> index c67c1bb..1e41485 100644
> --- a/lib/fragments.c
> +++ b/lib/fragments.c
> @@ -26,7 +26,7 @@
>  
>  struct erofs_fragment_dedupe_item {
>  	struct list_head	list;
> -	unsigned int		length, nr_dup;
> +	unsigned int		length;
>  	erofs_off_t		pos;
>  	u8			data[];
>  };
> @@ -53,7 +53,7 @@ static int z_erofs_fragments_dedupe_find(struct erofs_inode *inode, int fd,
>  	struct erofs_fragment_dedupe_item *cur, *di = NULL;
>  	struct list_head *head;
>  	u8 *data;
> -	unsigned int length, e2;
> +	unsigned int length, e2, deduped;
>  	int ret;
>  
>  	head = &dupli_frags[FRAGMENT_HASH(crc)];
> @@ -83,6 +83,7 @@ static int z_erofs_fragments_dedupe_find(struct erofs_inode *inode, int fd,
>  
>  	DBG_BUGON(length <= EROFS_TOF_HASHLEN);
>  	e2 = length - EROFS_TOF_HASHLEN;
> +	deduped = 0;
>  
>  	list_for_each_entry(cur, head, list) {
>  		unsigned int e1, mn, i = 0;
> @@ -97,22 +98,22 @@ static int z_erofs_fragments_dedupe_find(struct erofs_inode *inode, int fd,
>  		while (i < mn && cur->data[e1 - i - 1] == data[e2 - i - 1])
>  			++i;
>  
> -		if (i && (!di || i + EROFS_TOF_HASHLEN > di->nr_dup)) {
> -			cur->nr_dup = i + EROFS_TOF_HASHLEN;
> +		if (!di || i + EROFS_TOF_HASHLEN > deduped) {
> +			deduped = i + EROFS_TOF_HASHLEN;
>  			di = cur;
>  
>  			/* full match */
> -			if (i == mn)
> +			if (i == e2)
>  				break;
>  		}
>  	}
>  	if (!di)
>  		goto out;
>  
> -	DBG_BUGON(di->length < di->nr_dup);
> +	DBG_BUGON(di->length < deduped);
>  
> -	inode->fragment_size = di->nr_dup;
> -	inode->fragmentoff = di->pos + di->length - di->nr_dup;
> +	inode->fragment_size = deduped;
> +	inode->fragmentoff = di->pos + di->length - deduped;
>  
>  	erofs_dbg("Dedupe %u tail data at %llu", inode->fragment_size,
>  		  inode->fragmentoff | 0ULL);
> @@ -161,7 +162,6 @@ static int z_erofs_fragments_dedupe_insert(void *data, unsigned int len,
>  	memcpy(di->data, data, len);
>  	di->length = len;
>  	di->pos = pos;
> -	di->nr_dup = 0;
>  
>  	list_add_tail(&di->list, &dupli_frags[FRAGMENT_HASH(crc)]);
>  	return 0;


      parent reply	other threads:[~2023-03-01 10:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 18:54 [PATCH 1/3] erofs-utils: get rid of useless nr_dup Gao Xiang
2023-02-28 18:54 ` [PATCH 2/3] erofs-utils: use compressed pclusters to mark fragments Gao Xiang
2023-03-01 14:00   ` Yue Hu
2023-02-28 18:54 ` [PATCH 3/3] erofs-utils: add `-Eall-fragments` option Gao Xiang
2023-03-01 11:21   ` Yue Hu
2023-03-01 11:05 ` Yue Hu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301190503.00006aab.zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=zhangwen@coolpad.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox