Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1541001pxf; Fri, 12 Mar 2021 12:04:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2qVQYh3HT0H5NCL+GtnZxAwtL9fkqI0LGJd1bV2WwcxcKC1nRQRKorby6tMPyWMtMQ6qX X-Received: by 2002:a17:906:f88a:: with SMTP id lg10mr10647674ejb.39.1615579499297; Fri, 12 Mar 2021 12:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615579499; cv=none; d=google.com; s=arc-20160816; b=iu+AKrwIl7H9zUxdhH5b6PD9eElZGfW5uAWZRNd+5N3pAbokIzqb0U7YT/lCkFt4Sl Rcr43F9MuBgFt8NiDwMHKQP7PneJ0XEI3a6/qfwQqbcYYl2fEDOe5g9bSYMQx1f3/7n3 QgdtO3O4kmAQDgN7kby/dx0/cyXTZ5SXJAYF5yYT9Z7e8mL+G6bBVxbecNRVHJSQOmUA llBJ7/SdBogPVUKcOC9N+GWCUd88r0XoqGrZfp403XVu0+lGXzxJbcIx+lajdAmnX/Xo mqA+L487PIQbY6IM0FHe3raNF4VSPFyL2umfNcoXo/kN+11A8kFusAw8gA51SwcFpHOT XxQA== 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:message-id:subject:to:from:date :ironport-sdr:ironport-sdr; bh=dadiiwI1yIohvsBr+vQeZqdIQmJYeq5qxP2om5eMu2c=; b=ZGvGIh9WEWXXdZxWZWUs/B1agqVnjIeu1BsiWyjgvD8N9Hf22uZdKBCNXYUvwn3d+b qA+bFNowRc9Ux/7Jd1QgJSj/DXX+CNay3xvKlBSXJ2dQ9KZARt0OYpEkC+OTvf0355WY Yskgr/f1StTHey5MDY4EOjtcMEq5ADRWUeqbxX/3sF3z6f2Tft/GT6yn/duFCOpZ5gzC 5CM7r2lVb9IhvkGpGLm+pVYG9ALf62MozPnas5aB/XJ5tmL61sdk6KT/lGe2xUFxgy61 ndsitrYPIqu2OS+xeqwaPZe7m6pbBh7crA5lpYctb8fvaM3/h285tYdfzkDLgNX8Robe CMVg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si4470897edq.578.2021.03.12.12.04.35; Fri, 12 Mar 2021 12:04:59 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234526AbhCLUDk (ORCPT + 99 others); Fri, 12 Mar 2021 15:03:40 -0500 Received: from mga14.intel.com ([192.55.52.115]:31067 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234294AbhCLUDR (ORCPT ); Fri, 12 Mar 2021 15:03:17 -0500 IronPort-SDR: FZWzccZeEmv6SV9kVrbzp/EtAmcTC5JFlCUQxW/pCflwaMabXfEkbAkavdTnv38g3GVBLNqinS t1St/DcXp2jw== X-IronPort-AV: E=McAfee;i="6000,8403,9921"; a="188248073" X-IronPort-AV: E=Sophos;i="5.81,244,1610438400"; d="scan'208";a="188248073" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 12:03:14 -0800 IronPort-SDR: GvhqHz2C3BZ9nUflQhI5sQU6TJdlA/608uXDKfs91rOQZdRlQ/N/SproFDZmHXIO9qFYHn+Buf D+TRGR63Whmg== X-IronPort-AV: E=Sophos;i="5.81,244,1610438400"; d="scan'208";a="404529094" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 12:03:14 -0800 Date: Fri, 12 Mar 2021 12:03:14 -0800 From: Ira Weiny To: 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: <20210312200314.GF3014244@iweiny-DESK2.sc.intel.com> References: <20210217024826.3466046-1-ira.weiny@intel.com> <20210217024826.3466046-2-ira.weiny@intel.com> <20210312185839.GR7604@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210312185839.GR7604@suse.cz> User-Agent: Mutt/1.11.1 (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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