Message ID | ZJk1XTtgLFxIcxzp@bu2204.myguest.virtualbox.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7294747vqr; Mon, 26 Jun 2023 00:07:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58FUxBRArWmU2UTwFVpMW99XaOzmhuIr8/JRbKzrfybCNoP8DKPwTnK1tCQ/Z/dJYVGKT5 X-Received: by 2002:a17:906:da84:b0:988:f307:aea7 with SMTP id xh4-20020a170906da8400b00988f307aea7mr18768189ejb.7.1687763263486; Mon, 26 Jun 2023 00:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687763263; cv=none; d=google.com; s=arc-20160816; b=XOIFsOx2GrmckNUBAs65WWm4hkdS5IXWaYmaCOEgG9NbiU3VBQonuAZ4kENtwHetbb 9yD9xj0GrATjmH7U7+pwrBVU9E/B9di+/DlHVClBXFFpQxQ9iarjO3SXn074k4MGT4nC cpd8+uzLZVG7iYI5e2jtPjlyZqX+s3vdu91D/ZwU2+hEp4RSEmZILNyaDQN1lkF5Fe4f ItvVVDEgTdi2WKoAH3g+kVc367UcwyTAlnaEC82dwO1z6fNIg4jrBgTx9AxGwjMCuz5S nEGNDOQAjw73k5vZshPZwWnFN+a0qqa7JbCtLYKuQort2xPf2AnXRijgeljD50FMmd0T snRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=RVEVx49mxNIII67NO2PpPsiMVgXqHBi6kJxlBTilANo=; fh=2/OepbD16sII06AHmQTJgD7xcw2OMNoUEY9t7KuTeGw=; b=yGImwq4UeV8Fh9U9JzJuY8sRGo1wfvEfmOw6uTYo3bFU//dJJuHXrVKdaY4aY/fIgc 6z+Bd70VxnziwWu3D3CCV8XkuR2Zg5Unxva6R/vijOsxKAgwOedVuo3ycp0oTEwrXXBH UT2Gd+6ApdTDgbecApnJ75d/vbdunk9jI/ll5RY82KNv7LbgS4xylvAM1FHnucEpK33S KordWAdolx7feKm48XFDPNlLsvmhR+gZqKc0hCcJ9g1F7xD7LXWT60/UrV+MTd7tFEj+ MKI/j0oFNjqb4WuQT0DFrL5gfglSHy5k2RlJ/KOQZm0J+akVXzB+rP1ixh+QBO1/cXTm CMhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=PRpAQuq9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u21-20020a170906125500b0098283fa8be0si2455948eja.426.2023.06.26.00.07.17; Mon, 26 Jun 2023 00:07:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=PRpAQuq9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbjFZGva (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 02:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjFZGv3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 02:51:29 -0400 X-Greylist: delayed 41273 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 25 Jun 2023 23:51:24 PDT Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC97DE7B for <linux-kernel@vger.kernel.org>; Sun, 25 Jun 2023 23:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1687762277; bh=Pgn7S7GW3U6u3f3Hy8tc/2FAPWJkWS46rNADXIMWKy4=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=PRpAQuq9eHEuXF0MJhvvlHEm7wlDa1lGzzqt5J8Q+MaLVMRLZeFFkRIjrJglUR2lI llD8LnPmQSEsdNFiQm/hk5FNXr9z+fMcksD+w9U8jldbTs+Gm4IDJ1yqK3gMQ58Mg3 yjY/gYln4YRMoT85o2c/Vum7nYKQJGoJtEuUkz1k= Received: by b221-6.in.mailobj.net [192.168.90.26] with ESMTP via ip-20.mailobj.net [213.182.54.20] Mon, 26 Jun 2023 08:51:16 +0200 (CEST) X-EA-Auth: Eu/Q3BBGOZASBNR3dpmx6ET/wlVioDsvV4FoUhX+WcVKwrfl6adetu3e6VtSUbBvxZC7qTm86HVr6Td9HE/uWXqx2GV65Gol Date: Mon, 26 Jun 2023 12:21:09 +0530 From: Deepak R Varma <drv@mailo.com> To: Bob Peterson <rpeterso@redhat.com>, Andreas Gruenbacher <agruenba@redhat.com>, cluster-devel@redhat.com, linux-kernel@vger.kernel.org Cc: Ira Weiny <ira.weiny@intel.com>, "Fabio M. De Francesco" <fmdefrancesco@gmail.com>, Sumitra Sharma <sumitraartsy@gmail.com>, Deepak R Varma <drv@mailo.com> Subject: [PATCH v2] gfs2: Replace deprecated kmap_atomic() by kmap_local_page() Message-ID: <ZJk1XTtgLFxIcxzp@bu2204.myguest.virtualbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769748051311493734?= X-GMAIL-MSGID: =?utf-8?q?1769748051311493734?= |
Series |
[v2] gfs2: Replace deprecated kmap_atomic() by kmap_local_page()
|
|
Commit Message
Deepak R Varma
June 26, 2023, 6:51 a.m. UTC
kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().
Therefore, replace kmap_atomic() with kmap_local_page() in
gfs2_internal_read() and stuffed_readpage().
kmap_atomic() disables page-faults and preemption (the latter only for
!PREEMPT_RT kernels), However, the code within the mapping/un-mapping in
gfs2_internal_read() and stuffed_readpage() does not depend on the
above-mentioned side effects.
Therefore, a mere replacement of the old API with the new one is all that
is required (i.e., there is no need to explicitly add any calls to
pagefault_disable() and/or preempt_disable()).
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
Note: The Patch is build tested only. I will be happy to run recommended testing
with some guidance if required.
Changes in v2:
- Update patch description to correct the replacement function name from
kmap_local_folio to kmap_local _page
fs/gfs2/aops.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On lunedì 26 giugno 2023 08:51:09 CEST Deepak R Varma wrote: > kmap_atomic() is deprecated in favor of kmap_local_{folio,page}(). > > Therefore, replace kmap_atomic() with kmap_local_page() in > gfs2_internal_read() and stuffed_readpage(). > > kmap_atomic() disables page-faults and preemption (the latter only for > !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in > gfs2_internal_read() and stuffed_readpage() does not depend on the > above-mentioned side effects. > > Therefore, a mere replacement of the old API with the new one is all that > is required (i.e., there is no need to explicitly add any calls to > pagefault_disable() and/or preempt_disable()). > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > Note: The Patch is build tested only. I will be happy to run recommended > testing with some guidance if required. > > Changes in v2: > - Update patch description to correct the replacement function name from > kmap_local_folio to kmap_local _page Ah, well done. I didn't note this with the comment on v1. > fs/gfs2/aops.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c > index 3b41542d6697..7bd92054d353 100644 > --- a/fs/gfs2/aops.c > +++ b/fs/gfs2/aops.c > @@ -432,10 +432,10 @@ static int stuffed_readpage(struct gfs2_inode *ip, > struct page *page) if (error) > return error; > > - kaddr = kmap_atomic(page); > + kaddr = kmap_local_page(page); > memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); > memset(kaddr + dsize, 0, PAGE_SIZE - dsize); > - kunmap_atomic(kaddr); > + kunmap_local(kaddr); > flush_dcache_page(page); > brelse(dibh); > SetPageUptodate(page); > @@ -498,12 +498,12 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, > loff_t *pos, continue; > return PTR_ERR(page); > } > - p = kmap_atomic(page); > + p = kmap_local_page(page); > amt = size - copied; > if (offset + size > PAGE_SIZE) > amt = PAGE_SIZE - offset; > memcpy(buf + copied, p + offset, amt); As said in the comment on v1, the memcpy_from_page() helper is better suited here, unless you noted something that prevents its use and that I'm not able to see at the moment. Thanks, Fabio > - kunmap_atomic(p); > + kunmap_local(p); > put_page(page); > copied += amt; > index++; > -- > 2.34.1
On Mon, Jun 26, 2023 at 8:51 AM Deepak R Varma <drv@mailo.com> wrote: > kmap_atomic() is deprecated in favor of kmap_local_{folio,page}(). I'll apply this, convert the remaining instances of kmap_atomic(), and switch to memcpy_{from,to}_page() where appropriate. Thanks, Andreas > Therefore, replace kmap_atomic() with kmap_local_page() in > gfs2_internal_read() and stuffed_readpage(). > > kmap_atomic() disables page-faults and preemption (the latter only for > !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in > gfs2_internal_read() and stuffed_readpage() does not depend on the > above-mentioned side effects. > > Therefore, a mere replacement of the old API with the new one is all that > is required (i.e., there is no need to explicitly add any calls to > pagefault_disable() and/or preempt_disable()). > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > Note: The Patch is build tested only. I will be happy to run recommended testing > with some guidance if required. > > Changes in v2: > - Update patch description to correct the replacement function name from > kmap_local_folio to kmap_local _page > > > fs/gfs2/aops.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c > index 3b41542d6697..7bd92054d353 100644 > --- a/fs/gfs2/aops.c > +++ b/fs/gfs2/aops.c > @@ -432,10 +432,10 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) > if (error) > return error; > > - kaddr = kmap_atomic(page); > + kaddr = kmap_local_page(page); > memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); > memset(kaddr + dsize, 0, PAGE_SIZE - dsize); > - kunmap_atomic(kaddr); > + kunmap_local(kaddr); > flush_dcache_page(page); > brelse(dibh); > SetPageUptodate(page); > @@ -498,12 +498,12 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, > continue; > return PTR_ERR(page); > } > - p = kmap_atomic(page); > + p = kmap_local_page(page); > amt = size - copied; > if (offset + size > PAGE_SIZE) > amt = PAGE_SIZE - offset; > memcpy(buf + copied, p + offset, amt); > - kunmap_atomic(p); > + kunmap_local(p); > put_page(page); > copied += amt; > index++; > -- > 2.34.1 > > >
On Tue, Jun 27, 2023 at 03:45:20PM +0200, Andreas Gruenbacher wrote: > On Mon, Jun 26, 2023 at 8:51 AM Deepak R Varma <drv@mailo.com> wrote: > > kmap_atomic() is deprecated in favor of kmap_local_{folio,page}(). > > I'll apply this, convert the remaining instances of kmap_atomic(), and > switch to memcpy_{from,to}_page() where appropriate. Hello Andreas, Thank you for your review. I am working on the other conversion opportunities for this module and will send those in shortly. Regards, Deepak. > > Thanks, > Andreas > > > Therefore, replace kmap_atomic() with kmap_local_page() in > > gfs2_internal_read() and stuffed_readpage(). > > > > kmap_atomic() disables page-faults and preemption (the latter only for > > !PREEMPT_RT kernels), However, the code within the mapping/un-mapping in > > gfs2_internal_read() and stuffed_readpage() does not depend on the > > above-mentioned side effects. > > > > Therefore, a mere replacement of the old API with the new one is all that > > is required (i.e., there is no need to explicitly add any calls to > > pagefault_disable() and/or preempt_disable()). > > > > Signed-off-by: Deepak R Varma <drv@mailo.com> > > --- > > Note: The Patch is build tested only. I will be happy to run recommended testing > > with some guidance if required. > > > > Changes in v2: > > - Update patch description to correct the replacement function name from > > kmap_local_folio to kmap_local _page > > > > > > fs/gfs2/aops.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c > > index 3b41542d6697..7bd92054d353 100644 > > --- a/fs/gfs2/aops.c > > +++ b/fs/gfs2/aops.c > > @@ -432,10 +432,10 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) > > if (error) > > return error; > > > > - kaddr = kmap_atomic(page); > > + kaddr = kmap_local_page(page); > > memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); > > memset(kaddr + dsize, 0, PAGE_SIZE - dsize); > > - kunmap_atomic(kaddr); > > + kunmap_local(kaddr); > > flush_dcache_page(page); > > brelse(dibh); > > SetPageUptodate(page); > > @@ -498,12 +498,12 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, > > continue; > > return PTR_ERR(page); > > } > > - p = kmap_atomic(page); > > + p = kmap_local_page(page); > > amt = size - copied; > > if (offset + size > PAGE_SIZE) > > amt = PAGE_SIZE - offset; > > memcpy(buf + copied, p + offset, amt); > > - kunmap_atomic(p); > > + kunmap_local(p); > > put_page(page); > > copied += amt; > > index++; > > -- > > 2.34.1 > > > > > > >
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 3b41542d6697..7bd92054d353 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -432,10 +432,10 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page) if (error) return error; - kaddr = kmap_atomic(page); + kaddr = kmap_local_page(page); memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); memset(kaddr + dsize, 0, PAGE_SIZE - dsize); - kunmap_atomic(kaddr); + kunmap_local(kaddr); flush_dcache_page(page); brelse(dibh); SetPageUptodate(page); @@ -498,12 +498,12 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos, continue; return PTR_ERR(page); } - p = kmap_atomic(page); + p = kmap_local_page(page); amt = size - copied; if (offset + size > PAGE_SIZE) amt = PAGE_SIZE - offset; memcpy(buf + copied, p + offset, amt); - kunmap_atomic(p); + kunmap_local(p); put_page(page); copied += amt; index++;