Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2237815ybk; Sun, 17 May 2020 14:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwglnGkXpg4zvMC4vp8Td90vHX9KUreI9R3uy1kwRAWh4R/6K8OZ2oPFZReEatrE3Bue+05 X-Received: by 2002:a17:906:bc4c:: with SMTP id s12mr12958213ejv.285.1589752223128; Sun, 17 May 2020 14:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589752223; cv=none; d=google.com; s=arc-20160816; b=v6K0b5635TYgOGHIQHvYHvnO8XHPsWArbgY+kVsfaL2M+qK/sEbexFGbPQqEh9tx7u 0K0Gfh2zDUGBj0Te0HWqozZCWHkSsHmHWrQJn9EVRc5eu8GI8S1hN3prcLAfww7atUcA mSlaYu0nILIVVtDctr1P/XBjxF/0olptGxAWRjr4wr4CZXUmcf0iBhuxFXOudAuBizFf VEomsWkoVRSB+SJ3dG7OMIcEswptNXlJFZZtRw5uIlU3T4tSz355hZszfpcVH7hiu+5h Rp+zZi+VWlrnwaCiBBPaV5U53ik1iQZ4SYaN4KTRFvfkdyvqtO9uh5PIOt+IGNeHLiGi zsjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KhLF+EAo4dGVe9BW/cZoXpOODpgV89tLSnKlct0jr14=; b=iKSkuWsu04jOSsyMvM/AEwVyEGwq9ii86NiocBQcFHX5iaOGyhGEAD5JqmYTTJxLW4 6DzfhiblRDbxbGaV+6DpRYL+HsBLBY6bmCWGRsUSn3Aomz7hqDCC3DbixLmngyLDDOoP rwfX/nyIN+5cB3gdaXl2Yn0e3eRL2tpfl4jfCv6zbA6pmiiXD1SF9gW70Bd6cu/tYhzL OSD3u82FH1a511c5kHhArnQx7W1myXOvMRkp414OEiZonbxBOImD8+pvTaWYXZR6PzU5 /z2kda4zYkmV2x5mZa5qL8SaJ2eOg78IibEzba1MbhozELNgYYE9ruj9U1EzKqRZD3WH l/8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=OnCwteZT; 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 i60si5409539edd.0.2020.05.17.14.50.00; Sun, 17 May 2020 14:50:23 -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; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=OnCwteZT; 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 S1727066AbgEQVrz (ORCPT + 99 others); Sun, 17 May 2020 17:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgEQVrb (ORCPT ); Sun, 17 May 2020 17:47:31 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84038C05BD0C for ; Sun, 17 May 2020 14:47:30 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e16so9562775wra.7 for ; Sun, 17 May 2020 14:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KhLF+EAo4dGVe9BW/cZoXpOODpgV89tLSnKlct0jr14=; b=OnCwteZT1cB8ocCGH1aeVFrR4EgF5VX00CwdKk8KWUvXv5ftfo0fsjEkaKXrYyqAko mv8QW8YvOau+ddNZijQJPWJlc875CMZRCq5jPs47LtKcK0iAs7w4XKAdfWadVkwF5yh0 vbZ8lxoep7MmAuEH6k47PeqCAdK68/ugEpDe30/qtwZ9iClzkmuyh8DAmed8tdkPBipP jtwANFKLPWtFlbDtTJ0ozTDQyrJ/8MF+yVMxoywDnUPV0eAnzFwGIvF1UFAWTh1jfkPy frPno0kwJWfIWzY+KzjmatENTMD8D9ajyV22QBav5R+pK9+lpGb7JXY4w7s1coccPTEN Jq9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KhLF+EAo4dGVe9BW/cZoXpOODpgV89tLSnKlct0jr14=; b=dd2hWhUj496UTtIBmSvthhYEHZhhlPBYzLBCaf5CFwYwV7STkMKZTk2GJ4eH1Vh5HF JmDiBVlhsL6V7X8z0BBca4PP/KUzVQWpIgb5R+vODQ9pdeKE0eJqdMK3j+4PVIvOFs6R iwNhKVqovVqXLii74TyMtkDfwK1pgKwUoafhAtbg+hl+NduGWwZVXnSlWJjv03mqvmSN iw54xTKn4Z7apsp0wKQ7jV8K6fABzhbimbzX3OdOhsOXMeVQv9NEZgSHWEmtLP+wd+ed yXsJFbOj9AlFOmIR5Rwvv+GjzYJ8ZfC3E0fMjaDwuExLALyJU8JZZEQunbw4YO+VR+50 kmbg== X-Gm-Message-State: AOAM530iuB/mIoLwgG+sYjwxt363Jv2mDVdq5U9oU45eGgkVn2tjPzpD dXbBcwn+A8jz9LOdOwzmpBaeSA== X-Received: by 2002:a5d:5228:: with SMTP id i8mr16279223wra.359.1589752049269; Sun, 17 May 2020 14:47:29 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:bc3e:92a1:7010:2763]) by smtp.gmail.com with ESMTPSA id v126sm14441244wmb.4.2020.05.17.14.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 14:47:28 -0700 (PDT) From: Guoqing Jiang To: akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, david@fromorbit.com, hch@infradead.org, willy@infradead.org, Guoqing Jiang , "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 06/10] iomap: use attach/detach_page_private Date: Sun, 17 May 2020 23:47:14 +0200 Message-Id: <20200517214718.468-7-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200517214718.468-1-guoqing.jiang@cloud.ionos.com> References: <20200517214718.468-1-guoqing.jiang@cloud.ionos.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the new pair function is introduced, we can call them to clean the code in iomap. Cc: Christoph Hellwig Cc: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org Signed-off-by: Guoqing Jiang --- No change since RFC V3. RFC V2 -> RFC V3 1. rename clear_page_private to detach_page_private. RFC -> RFC V2 1. change the name of new functions to attach/clear_page_private. 2. call attach_page_private(newpage, clear_page_private(page)) to cleanup code further as suggested by Matthew Wilcox. 3. don't return attach_page_private in iomap_page_create per the comment from Christoph Hellwig. fs/iomap/buffered-io.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 890c8fcda4f3..a1ed7620fbac 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -59,24 +59,19 @@ iomap_page_create(struct inode *inode, struct page *page) * migrate_page_move_mapping() assumes that pages with private data have * their count elevated by 1. */ - get_page(page); - set_page_private(page, (unsigned long)iop); - SetPagePrivate(page); + attach_page_private(page, iop); return iop; } static void iomap_page_release(struct page *page) { - struct iomap_page *iop = to_iomap_page(page); + struct iomap_page *iop = detach_page_private(page); if (!iop) return; WARN_ON_ONCE(atomic_read(&iop->read_count)); WARN_ON_ONCE(atomic_read(&iop->write_count)); - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); kfree(iop); } @@ -526,14 +521,8 @@ iomap_migrate_page(struct address_space *mapping, struct page *newpage, if (ret != MIGRATEPAGE_SUCCESS) return ret; - if (page_has_private(page)) { - ClearPagePrivate(page); - get_page(newpage); - set_page_private(newpage, page_private(page)); - set_page_private(page, 0); - put_page(page); - SetPagePrivate(newpage); - } + if (page_has_private(page)) + attach_page_private(newpage, detach_page_private(page)); if (mode != MIGRATE_SYNC_NO_COPY) migrate_page_copy(newpage, page); -- 2.17.1