linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: dsterba@suse.cz, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/4] fs/btrfs: Convert kmap to kmap_local_page() using coccinelle
Date: Fri, 12 Mar 2021 12:03:14 -0800	[thread overview]
Message-ID: <20210312200314.GF3014244@iweiny-DESK2.sc.intel.com> (raw)
In-Reply-To: <20210312185839.GR7604@suse.cz>

On Fri, Mar 12, 2021 at 07:58:39PM +0100, David Sterba wrote:
> On Tue, Feb 16, 2021 at 06:48:23PM -0800, ira.weiny@intel.com wrote:
> > --- a/fs/btrfs/lzo.c
> > +++ b/fs/btrfs/lzo.c
> > @@ -118,7 +118,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
> >  	struct workspace *workspace = list_entry(ws, struct workspace, list);
> >  	int ret = 0;
> >  	char *data_in;
> > -	char *cpage_out;
> > +	char *cpage_out, *sizes_ptr;
> >  	int nr_pages = 0;
> >  	struct page *in_page = NULL;
> >  	struct page *out_page = NULL;
> > @@ -258,10 +258,9 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
> >  	}
> >  
> >  	/* store the size of all chunks of compressed data */
> > -	cpage_out = kmap(pages[0]);
> > -	write_compress_length(cpage_out, tot_out);
> > -
> > -	kunmap(pages[0]);
> > +	sizes_ptr = kmap_local_page(pages[0]);
> > +	write_compress_length(sizes_ptr, tot_out);
> > +	kunmap_local(sizes_ptr);
> 
> Why is not cpage_out reused for this mapping? I don't see any reason for
> another temporary variable, cpage_out is not used at this point.

For this patch that is true.  However, I'm trying to convert the other kmaps as
well.  To do that I'll need cpage_out preserved for the final kunmap_local().

Unfortunately, the required nesting ordering of kmap_local_page() makes
converting the other calls hacky at best.  I'm not sure what to do about them.
The best I've come up with is doing a hacky extra unmap/remap to preserve the
nesting.

Anyway, I'd prefer to leave this additional temp variable but I can certainly
change if it you want.  The other conversions may never work/land.  :-/

Ira

  reply	other threads:[~2021-03-12 20:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17  2:48 [PATCH 0/4] btrfs: Convert more kmaps to kmap_local_page() ira.weiny
2021-02-17  2:48 ` [PATCH 1/4] fs/btrfs: Convert kmap to kmap_local_page() using coccinelle ira.weiny
2021-03-12 18:58   ` David Sterba
2021-03-12 20:03     ` Ira Weiny [this message]
2021-03-16 11:04       ` David Sterba
2021-02-17  2:48 ` [PATCH 2/4] fs/btrfs: Convert raid5/6 kmaps to kmap_local_page() ira.weiny
2021-03-12 19:26   ` David Sterba
2021-02-17  2:48 ` [PATCH 3/4] fs/btrfs: Use kmap_local_page() in __btrfsic_submit_bio() ira.weiny
2021-02-17  2:48 ` [PATCH 4/4] fs/btrfs: Convert block context kmap's to kmap_local_page() ira.weiny
2021-03-11 21:30 ` [PATCH 0/4] btrfs: Convert more kmaps " Ira Weiny
2021-03-12 19:41 ` David Sterba
2021-03-12 20:05   ` Ira Weiny
2021-03-16 11:07     ` David Sterba
2021-03-16 16:56       ` Ira Weiny

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=20210312200314.GF3014244@iweiny-DESK2.sc.intel.com \
    --to=ira.weiny@intel.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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
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;
as well as URLs for NNTP newsgroup(s).