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: Yue Hu <huyue2@coolpad.com>,
	linux-erofs@lists.ozlabs.org, shaojunjun@coolpad.com,
	zhangwen@coolpad.com
Subject: Re: [RFC PATCH v4 2/3] erofs-utils: lib: support on-disk offset for shifted decompression
Date: Wed, 24 Aug 2022 16:58:52 +0800	[thread overview]
Message-ID: <20220824165852.00002d6b.zbestahu@gmail.com> (raw)
In-Reply-To: <YwXlR0lL6eZPtTTC@B-P7TQMD6M-0146.local>

On Wed, 24 Aug 2022 16:45:59 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:

> Hi Yue,
> 
> On Sun, Aug 21, 2022 at 09:57:24PM +0800, zbestahu@gmail.com wrote:
> > From: Yue Hu <huyue2@coolpad.com>
> > 
> > Add support to uncompressed data layout with on-disk offset for
> > compressed files.  
> 
> Sorry for some delay.
> 
> Add interlaced uncompressed data layout for compressed files.
> 
> > 
> > Signed-off-by: Yue Hu <huyue2@coolpad.com>
> > ---
> >  include/erofs/decompress.h |  3 +++
> >  lib/data.c                 |  8 +++++++-
> >  lib/decompress.c           | 10 ++++++++--
> >  3 files changed, 18 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/erofs/decompress.h b/include/erofs/decompress.h
> > index 82bf7b8..b622df5 100644
> > --- a/include/erofs/decompress.h
> > +++ b/include/erofs/decompress.h
> > @@ -23,6 +23,9 @@ struct z_erofs_decompress_req {
> >  	unsigned int decodedskip;
> >  	unsigned int inputsize, decodedlength;
> >  
> > +	/* head offset of uncompressed data */
> > +	unsigned int shiftedhead;  
> 
> 	/* cut point of interlaced uncompressed data */
> 	unsigned int interlaced_offset;
> 
> > +
> >  	/* indicate the algorithm will be used for decompression */
> >  	unsigned int alg;
> >  	bool partial_decoding;
> > diff --git a/lib/data.c b/lib/data.c
> > index 2af73c7..008790d 100644
> > --- a/lib/data.c
> > +++ b/lib/data.c
> > @@ -226,7 +226,7 @@ static int z_erofs_read_data(struct erofs_inode *inode, char *buffer,
> >  	};
> >  	struct erofs_map_dev mdev;
> >  	bool partial;
> > -	unsigned int bufsize = 0;
> > +	unsigned int bufsize = 0, head;
> >  	char *raw = NULL;
> >  	int ret = 0;
> >  
> > @@ -307,10 +307,16 @@ static int z_erofs_read_data(struct erofs_inode *inode, char *buffer,
> >  		if (ret < 0)
> >  			break;
> >  
> > +		head = 0;
> > +		if (erofs_sb_has_fragments() &&  
> 
> Can we add another Z_EROFS_ADVISE_ for this, such as
> Z_EROFS_ADVISE_INTERLACED_UNCOMPRESSED_DATA ?

Sounds good, let's do this.

Thanks.

> 
> > +		    map.m_algorithmformat == Z_EROFS_COMPRESSION_SHIFTED)
> > +			head = erofs_blkoff(end);
> > +
> >  		ret = z_erofs_decompress(&(struct z_erofs_decompress_req) {
> >  					.in = raw,
> >  					.out = buffer + end - offset,
> >  					.decodedskip = skip,
> > +					.shiftedhead = head,
> >  					.inputsize = map.m_plen,
> >  					.decodedlength = length,
> >  					.alg = map.m_algorithmformat,
> > diff --git a/lib/decompress.c b/lib/decompress.c
> > index 1661f91..08a0861 100644
> > --- a/lib/decompress.c
> > +++ b/lib/decompress.c
> > @@ -132,14 +132,20 @@ out:
> >  int z_erofs_decompress(struct z_erofs_decompress_req *rq)
> >  {
> >  	if (rq->alg == Z_EROFS_COMPRESSION_SHIFTED) {
> > +		unsigned int count, rightpart;
> > +
> >  		if (rq->inputsize > EROFS_BLKSIZ)
> >  			return -EFSCORRUPTED;
> >  
> >  		DBG_BUGON(rq->decodedlength > EROFS_BLKSIZ);
> >  		DBG_BUGON(rq->decodedlength < rq->decodedskip);
> >  
> > -		memcpy(rq->out, rq->in + rq->decodedskip,
> > -		       rq->decodedlength - rq->decodedskip);
> > +		count = rq->decodedlength - rq->decodedskip;
> > +		rightpart = min(EROFS_BLKSIZ - rq->shiftedhead, count);
> > +
> > +		memcpy(rq->out, rq->in + (erofs_sb_has_fragments() ?  
> 
> same here.
> 
> Thanks,
> Gao Xiang
> 
> > +		       rq->shiftedhead : rq->decodedskip), rightpart);
> > +		memcpy(rq->out + rightpart, rq->in, count - rightpart);
> >  		return 0;
> >  	}
> >  
> > -- 
> > 2.17.1  


  reply	other threads:[~2022-08-24  8:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-21 13:57 [RFC PATCH v4 0/3] erofs-utils: compressed fragments feature zbestahu
2022-08-21 13:57 ` [RFC PATCH v4 1/3] erofs-utils: lib: add support for fragments data decompression zbestahu
2022-08-21 13:57 ` [RFC PATCH v4 2/3] erofs-utils: lib: support on-disk offset for shifted decompression zbestahu
2022-08-24  8:45   ` Gao Xiang
2022-08-24  8:58     ` Yue Hu [this message]
2022-08-21 13:57 ` [RFC PATCH v4 3/3] erofs-utils: introduce compressed fragments support zbestahu
2022-08-24  9:00   ` Gao Xiang
2022-08-25  8:16     ` Yue Hu

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=20220824165852.00002d6b.zbestahu@gmail.com \
    --to=zbestahu@gmail.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=shaojunjun@coolpad.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