LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"pali@kernel.org" <pali@kernel.org>,
	"dsterba@suse.cz" <dsterba@suse.cz>,
	"aaptel@suse.com" <aaptel@suse.com>,
	"willy@infradead.org" <willy@infradead.org>,
	"rdunlap@infradead.org" <rdunlap@infradead.org>,
	"joe@perches.com" <joe@perches.com>,
	"mark@harmstone.com" <mark@harmstone.com>,
	"nborisov@suse.com" <nborisov@suse.com>,
	"linux-ntfs-dev@lists.sourceforge.net" 
	<linux-ntfs-dev@lists.sourceforge.net>,
	"anton@tuxera.com" <anton@tuxera.com>,
	"dan.carpenter@oracle.com" <dan.carpenter@oracle.com>,
	"hch@lst.de" <hch@lst.de>
Subject: RE: [PATCH v14 04/10] fs/ntfs3: Add file operations and implementation
Date: Fri, 11 Dec 2020 16:31:18 +0000
Message-ID: <229c4a26f2834f8dabf566823936d3e4@paragon-software.com> (raw)
In-Reply-To: <X8qC3NaNv1kmCO4c@sol.localdomain>

From: Eric Biggers <ebiggers@kernel.org>
Sent: Friday, December 4, 2020 9:42 PM
> To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> Cc: linux-fsdevel@vger.kernel.org; viro@zeniv.linux.org.uk; linux-kernel@vger.kernel.org; pali@kernel.org; dsterba@suse.cz;
> aaptel@suse.com; willy@infradead.org; rdunlap@infradead.org; joe@perches.com; mark@harmstone.com; nborisov@suse.com;
> linux-ntfs-dev@lists.sourceforge.net; anton@tuxera.com; dan.carpenter@oracle.com; hch@lst.de
> Subject: Re: [PATCH v14 04/10] fs/ntfs3: Add file operations and implementation
> 
> On Fri, Dec 04, 2020 at 06:45:54PM +0300, Konstantin Komarov wrote:
> > +/* external compression lzx/xpress */
> > +static int decompress_lzx_xpress(struct ntfs_sb_info *sbi, const char *cmpr,
> > +				 size_t cmpr_size, void *unc, size_t unc_size,
> > +				 u32 frame_size)
> > +{
> > +	int err;
> > +	void *ctx;
> > +
> > +	if (cmpr_size == unc_size) {
> > +		/* frame not compressed */
> > +		memcpy(unc, cmpr, unc_size);
> > +		return 0;
> > +	}
> > +
> > +	err = 0;
> > +	ctx = NULL;
> > +	spin_lock(&sbi->compress.lock);
> > +	if (frame_size == 0x8000) {
> > +		/* LZX: frame compressed */
> > +		if (!sbi->compress.lzx) {
> > +			/* Lazy initialize lzx decompress context */
> > +			spin_unlock(&sbi->compress.lock);
> > +			ctx = lzx_allocate_decompressor(0x8000);
> > +			if (!ctx)
> > +				return -ENOMEM;
> > +			if (IS_ERR(ctx)) {
> > +				/* should never failed */
> > +				err = PTR_ERR(ctx);
> > +				goto out;
> > +			}
> > +
> > +			spin_lock(&sbi->compress.lock);
> > +			if (!sbi->compress.lzx) {
> > +				sbi->compress.lzx = ctx;
> > +				ctx = NULL;
> > +			}
> > +		}
> > +
> > +		if (lzx_decompress(sbi->compress.lzx, cmpr, cmpr_size, unc,
> > +				   unc_size)) {
> > +			err = -EINVAL;
> > +		}
> > +	} else {
> > +		/* XPRESS: frame compressed */
> > +		if (!sbi->compress.xpress) {
> > +			/* Lazy initialize xpress decompress context */
> > +			spin_unlock(&sbi->compress.lock);
> > +			ctx = xpress_allocate_decompressor();
> > +			if (!ctx)
> > +				return -ENOMEM;
> > +
> > +			spin_lock(&sbi->compress.lock);
> > +			if (!sbi->compress.xpress) {
> > +				sbi->compress.xpress = ctx;
> > +				ctx = NULL;
> > +			}
> > +		}
> > +
> > +		if (xpress_decompress(sbi->compress.xpress, cmpr, cmpr_size,
> > +				      unc, unc_size)) {
> > +			err = -EINVAL;
> > +		}
> > +	}
> > +	spin_unlock(&sbi->compress.lock);
> > +out:
> > +	ntfs_free(ctx);
> > +	return err;
> > +}
> 
> Decompression is a somewhat heavyweight operation.  Not the type of thing that
> should be done while holding a spin lock.
> 
> - Eric

Hi Eric! We plan to swap spinlock to mutex in the next version.

Best regards!

  reply index

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 15:45 [PATCH v14 00/10] NTFS read-write driver GPL implementation by Paragon Software Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 01/10] fs/ntfs3: Add headers and misc files Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 02/10] fs/ntfs3: Add initialization of super block Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 03/10] fs/ntfs3: Add bitmap Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 04/10] fs/ntfs3: Add file operations and implementation Konstantin Komarov
2020-12-04 18:41   ` Eric Biggers
2020-12-11 16:31     ` Konstantin Komarov [this message]
2020-12-25 14:27       ` Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 05/10] fs/ntfs3: Add attrib operations Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 06/10] fs/ntfs3: Add compression Konstantin Komarov
2020-12-04 18:38   ` Eric Biggers
2020-12-11 16:28     ` Konstantin Komarov
2020-12-25 14:29       ` Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 07/10] fs/ntfs3: Add NTFS journal Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 08/10] fs/ntfs3: Add Kconfig, Makefile and doc Konstantin Komarov
2020-12-04 15:45 ` [PATCH v14 09/10] fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile Konstantin Komarov
2020-12-04 18:51   ` kernel test robot
2020-12-05  0:41   ` kernel test robot
2020-12-04 15:46 ` [PATCH v14 10/10] fs/ntfs3: Add MAINTAINERS Konstantin Komarov

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=229c4a26f2834f8dabf566823936d3e4@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=aaptel@suse.com \
    --cc=anton@tuxera.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=ebiggers@kernel.org \
    --cc=hch@lst.de \
    --cc=joe@perches.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    --cc=mark@harmstone.com \
    --cc=nborisov@suse.com \
    --cc=pali@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git