Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4361439pxf; Tue, 16 Mar 2021 11:30:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0zqVQSJ3nMTjiggZ1s9mtRqCBaqzricn8iOWVStL+Tbt4kSFhySGhk7rsYjGYhVteEYl1 X-Received: by 2002:aa7:d792:: with SMTP id s18mr37130877edq.176.1615919406593; Tue, 16 Mar 2021 11:30:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615919406; cv=none; d=google.com; s=arc-20160816; b=gofvyxBlmLxeuSRfvl/K8L8tGysBw4DdC0vOKX/uxPsrakQYm05PygvNJrckXoqTM9 dTyAnD71be4Cg8a69NvL/poPIuu0IdzgLgoN4blMdrrYlmw+QNUR7ZCQp7Tpcd98QTLV 4Ve6Zel0/w4a1hgMf2/jfX3cUEuofJ5Anek0MWlXhuh889Q9BqDlgwec+1FwRR1gpFWv /8Q0F8TwrsQh2oBrby0BJBst+elivIR0MfHht5ftHTUQd9N5QSe93Yjq7p9/VcEsgA83 TjCKx7t3I1Y6dHi25bSPwQATIivCcTzvv+qJnmxIttsaXD/wUbN3V1/lAcvAs4SATjrn 5pxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date; bh=1A/QW5FRXaM9i9CrEEK0Y3kc29jHXBxXYN9qHC9LG0M=; b=TR1DOlFJatqgXLL+I3B03PHK0k5mEDIN1laLMg0UE1LN3Hebuvlt6agh+7WoZZBbkB Uxqz8JJgrOLoeu5HxO8krDTgYpRk4bmb/hyKfrKjIudmOofEZI6l1hTkm/4QIsA49YIA GoUfm3mxnIz4LvEBT1MZHOhBSIL4EuYcPYJVrlKTB0JHT9Qt3u9EHjMk4RKdbp01TCzr cSmuBn37y1oVTfR3vthiKNQSw2A3+jEkepOdseatWGbfLfEbhcLiwgKWlQNRX1MJQ0qx QHwu+7+tWeZJrIZNm8wwTpFNjON4S1EsQ12w6fHvAK1FId6s5Fd1hNtoq7a6BFTs+B0+ IFnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si11719313edc.327.2021.03.16.11.29.42; Tue, 16 Mar 2021 11:30:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237048AbhCPLHW (ORCPT + 99 others); Tue, 16 Mar 2021 07:07:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:42120 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbhCPLGq (ORCPT ); Tue, 16 Mar 2021 07:06:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 47006AC1D; Tue, 16 Mar 2021 11:06:45 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id B120ADA6E2; Tue, 16 Mar 2021 12:04:43 +0100 (CET) Date: Tue, 16 Mar 2021 12:04:43 +0100 From: David Sterba To: Ira Weiny Cc: dsterba@suse.cz, Chris Mason , Josef Bacik , 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 Message-ID: <20210316110443.GI7604@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Ira Weiny , Chris Mason , Josef Bacik , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <20210217024826.3466046-1-ira.weiny@intel.com> <20210217024826.3466046-2-ira.weiny@intel.com> <20210312185839.GR7604@suse.cz> <20210312200314.GF3014244@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210312200314.GF3014244@iweiny-DESK2.sc.intel.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 12, 2021 at 12:03:14PM -0800, Ira Weiny wrote: > 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. :-/ Ok, no problem keeping the variable then. I've added a note to changelog why it's there. The whole conversion sounds tricky so adding trivial helper code is no big deal.