mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Yue Hu <zbestahu@gmail.com>
Cc: linux-erofs@lists.ozlabs.org, LKML <linux-kernel@vger.kernel.org>,
	huyue2@coolpad.com, zhangwen@coolpad.com
Subject: Re: [PATCH 4/5] erofs: refine z_erofs_transform_plain() for sub-page block support
Date: Fri, 8 Dec 2023 15:34:14 +0800	[thread overview]
Message-ID: <9ced71c9-4460-4907-abb9-21b517a883c7@linux.alibaba.com> (raw)
In-Reply-To: <20231208132031.00003b8d.zbestahu@gmail.com>



On 2023/12/8 13:20, Yue Hu wrote:
> On Wed,  6 Dec 2023 17:10:56 +0800
> Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
> 
>> Sub-page block support is still unusable even with previous commits if
>> interlaced PLAIN pclusters exist.  Such pclusters can be found if the
>> fragment feature is enabled.
>>
>> This commit tries to handle "the head part" of interlaced PLAIN
>> pclusters first: it was once explained in commit fdffc091e6f9 ("erofs:
>> support interlaced uncompressed data for compressed files").
>>
>> It uses a unique way for both shifted and interlaced PLAIN pclusters.
>> As an added bonus, PLAIN pclusters larger than the block size is also
>> supported now for the upcoming large lclusters.
>>
>> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
>> ---
>>   fs/erofs/decompressor.c | 81 ++++++++++++++++++++++++-----------------
>>   1 file changed, 48 insertions(+), 33 deletions(-)
>>
>> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
>> index 021be5feb1bc..5ec11f5024b7 100644
>> --- a/fs/erofs/decompressor.c
>> +++ b/fs/erofs/decompressor.c
>> @@ -319,43 +319,58 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq,
>>   static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
>>   				   struct page **pagepool)
>>   {
>> -	const unsigned int inpages = PAGE_ALIGN(rq->inputsize) >> PAGE_SHIFT;
>> -	const unsigned int outpages =
>> +	const unsigned int nrpages_in =
>> +		PAGE_ALIGN(rq->pageofs_in + rq->inputsize) >> PAGE_SHIFT;
>> +	const unsigned int nrpages_out =
>>   		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
>> -	const unsigned int righthalf = min_t(unsigned int, rq->outputsize,
>> -					     PAGE_SIZE - rq->pageofs_out);
>> -	const unsigned int lefthalf = rq->outputsize - righthalf;
>> -	const unsigned int interlaced_offset =
>> -		rq->alg == Z_EROFS_COMPRESSION_SHIFTED ? 0 : rq->pageofs_out;
>> -	u8 *src;
>> -
>> -	if (outpages > 2 && rq->alg == Z_EROFS_COMPRESSION_SHIFTED) {
>> -		DBG_BUGON(1);
>> -		return -EFSCORRUPTED;
>> -	}
>> -
>> -	if (rq->out[0] == *rq->in) {
>> -		DBG_BUGON(rq->pageofs_out);
>> -		return 0;
>> +	const unsigned int bs = rq->sb->s_blocksize;
>> +	unsigned int cur = 0, ni = 0, no, pi, po, insz, cnt;
>> +	u8 *kin;
>> +
>> +	DBG_BUGON(rq->outputsize > rq->inputsize);
>> +	if (rq->alg == Z_EROFS_COMPRESSION_INTERLACED) {
>> +		cur = bs - (rq->pageofs_out & (bs - 1));
>> +		pi = (rq->pageofs_in + rq->inputsize - cur) & ~PAGE_MASK;
>> +		cur = min(cur, rq->outputsize);
>> +		if (cur && rq->out[0]) {
>> +			kin = kmap_local_page(rq->in[nrpages_in - 1]);
>> +			if (rq->out[0] == rq->in[nrpages_in - 1]) {
>> +				memmove(kin + rq->pageofs_out, kin + pi, cur);
>> +				flush_dcache_page(rq->out[0]);
>> +			} else {
>> +				memcpy_to_page(rq->out[0], rq->pageofs_out,
>> +					       kin + pi, cur);
>> +			}
>> +			kunmap_local(kin);
>> +		}
>> +		rq->outputsize -= cur;
>>   	}
>>   
>> -	src = kmap_local_page(rq->in[inpages - 1]) + rq->pageofs_in;
>> -	if (rq->out[0])
>> -		memcpy_to_page(rq->out[0], rq->pageofs_out,
>> -			       src + interlaced_offset, righthalf);
>> -
>> -	if (outpages > inpages) {
>> -		DBG_BUGON(!rq->out[outpages - 1]);
>> -		if (rq->out[outpages - 1] != rq->in[inpages - 1]) {
>> -			memcpy_to_page(rq->out[outpages - 1], 0, src +
>> -					(interlaced_offset ? 0 : righthalf),
>> -				       lefthalf);
>> -		} else if (!interlaced_offset) {
>> -			memmove(src, src + righthalf, lefthalf);
>> -			flush_dcache_page(rq->in[inpages - 1]);
>> -		}
>> +	for (; rq->outputsize; rq->pageofs_in = 0, cur += PAGE_SIZE, ni++) {
>> +		insz = min(PAGE_SIZE - rq->pageofs_in, rq->outputsize);
> 
> min_t(unsigned int, ,)?
> 
> ../include/linux/minmax.h:21:28: error: comparison of distinct pointer types lacks a cast [-Werror]
>    (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))

What compiler version are you using? I didn't find any error
and
https://lore.kernel.org/linux-erofs/202312080122.iCCXzSuE-lkp@intel.com

also didn't report this.

Thanks,
Gao Xiang

  reply	other threads:[~2023-12-08  7:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06  9:10 [PATCH 0/5] erofs: basic sub-page compressed data support Gao Xiang
2023-12-06  9:10 ` [PATCH 1/5] erofs: support I/O submission for sub-page compressed blocks Gao Xiang
2023-12-11  8:10   ` Gao Xiang
2023-12-06  9:10 ` [PATCH 2/5] erofs: record `pclustersize` in bytes instead of pages Gao Xiang
2023-12-06  9:10 ` [PATCH 3/5] erofs: fix up compacted indexes for block size < 4096 Gao Xiang
2023-12-06  9:10 ` [PATCH 4/5] erofs: refine z_erofs_transform_plain() for sub-page block support Gao Xiang
2023-12-08  5:20   ` Yue Hu
2023-12-08  7:34     ` Gao Xiang [this message]
2023-12-08  7:44       ` Gao Xiang
2023-12-08  8:30         ` Yue Hu
2023-12-06  9:10 ` [PATCH 5/5] erofs: enable sub-page compressed " Gao Xiang
2023-12-11  6:50 ` [PATCH 0/5] erofs: basic sub-page compressed data support Yue Hu
2023-12-14 14:58 ` Chao Yu

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=9ced71c9-4460-4907-abb9-21b517a883c7@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbestahu@gmail.com \
    --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

all inboxes | Powered by JetHome®