Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2259310ybz; Sun, 26 Apr 2020 14:51:40 -0700 (PDT) X-Google-Smtp-Source: APiQypI5GPdRQIlX0fB+XGrYVdoeIMdaZ0vqkLKla4c9bfR788hfHfZS59awVCRnEcEUE7KFaj3V X-Received: by 2002:a17:906:4553:: with SMTP id s19mr16617370ejq.295.1587937900524; Sun, 26 Apr 2020 14:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587937900; cv=none; d=google.com; s=arc-20160816; b=TPOvO+Zyxsf8+I7MJFNxWgvj0U8DPmumq+gbPk48iy91hc4B+kiHWmnPm/cq9h9z+C 127dqkBgZllv5H7FlT768Vgd0FKkAVP7N4ExG8YlIu/SUzRkELuHzr2NNKkV0j2Fsokw bSqLUaYrdO42HEQVUC6impgNjWuU9T9BEpHZm8z+S1pwQa9QV+hBPvkJeK6y24ycAAEt 315qLcpRF7peJwD0IlWxaOSltgPhWGuh6osIoh6DeEaMcLiYdS4SG+/vGRRq8uv8pZE8 Lc3x3R51EWq214d/EP1AcKeXgIPHRIz6KruhYLy5dkX7dR+Rak3P5qAUK9L8myBHQYni I0Ew== 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=8YZX6HD1KfYztNlIB7+yLvJefwmGiH93TRfGwqC7PeQ=; b=xufXWZptZpVabA/J7PIswTVtgBeIQb7yc4KBM9/93H8PRuBAXn1jWyi7WJ8hCw1zwK AS1I1RRLtfUHCC5XfYf1Vll6WBn/2PCkulh6zgX51iZmnFgkV450t1aqvF4r8qR/SUci oqWXW/C3mo9/AsB12EZBOqppGESGfgBLPsP/ATWb6Bb9Rt5hym1vwnbnivXKqMV8KF91 55ve1oCWovKgy3pxTiNBduaWKiS6RcEwBjtASBT1MGCne2tRbN/3cBFNywMyMrL6+yVu IoApKyKLfd100uttnHAi/75aHgSc88tY01QBetPJVbRScN4f9+u6CSl9+OcP0pkXDdHl gJWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b="XJUCf4/P"; 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 ch14si7364217ejb.304.2020.04.26.14.51.17; Sun, 26 Apr 2020 14:51:40 -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="XJUCf4/P"; 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 S1726403AbgDZVtz (ORCPT + 99 others); Sun, 26 Apr 2020 17:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726378AbgDZVtw (ORCPT ); Sun, 26 Apr 2020 17:49:52 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7BE4C061A0F for ; Sun, 26 Apr 2020 14:49:50 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id k22so12018570eds.6 for ; Sun, 26 Apr 2020 14:49:50 -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=8YZX6HD1KfYztNlIB7+yLvJefwmGiH93TRfGwqC7PeQ=; b=XJUCf4/P3uV7oFMdxzQRFCOfUhzfFQc4G4aSbcspZJ2OiUwRdTeqHaiQFn/uzJVy6n WgYCFN8XMPbZLNkfr+vzFpVAGFJcgOV0pdRmEDQlWGUiaxVtwbptV51UEtbu8ZXVJWyT iaKsrKOnwwMPfg3OnjKyeGklbYVWoJUlGMZ1WAaBDgSvflIxeWcnfuID+FvQGkMKA1JQ YZHXUyTj4ZE6tToXQJVaSVe5/3Lw+SZkhPxruuz+5fw8on+HwDGLZKhP1LB62SUcC7ST 3emBtqDQ/v+fZdnLeYcjEvFBd0u4IVV93UqT8I5UkEok0FOAq0qHFraUswdzR+xuJ3VM BFQQ== 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=8YZX6HD1KfYztNlIB7+yLvJefwmGiH93TRfGwqC7PeQ=; b=Dx6y63IhzdHYZq5uOaTNIMvBArYVaFzPBOdMfOrRScebaq5nFZWNXYUkpaqqkpaKWs sOUbMCQD2aw+CnhhdT+LrcK4pZX7Ewx+Jlr27CNTDHTl3oHZA5XHnSBzrEpayOqvvneB YM0gVRZhT4tkbnNeI4EqPN5mqkB/To92YUKqKGOZhsc7jCAAI40xOqsEU7kqW40WVawF DPirUd6mGofo3ghrCS2KnNYgjCinifCSqBL1i/Enc/HjQsByvxXqFPBAy9UH+KBP01E4 ImEz9oeWAbegwqN7ag5Vq/FjG4d2uRaJg961LO0xiNvY/77q0/NSZWu4sygcesJBn/YA a13Q== X-Gm-Message-State: AGi0PuaQUcFQXkLD0E505TPcByQAEviJy++DJduTxQS8ugz2MbVXbwwb yFduj6IN3sztb5g2q/mhwHluuw== X-Received: by 2002:a05:6402:31b1:: with SMTP id dj17mr15648996edb.146.1587937789583; Sun, 26 Apr 2020 14:49:49 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:fab1:56ff:feab:56b1]) by smtp.gmail.com with ESMTPSA id ce18sm2270108ejb.61.2020.04.26.14.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2020 14:49:48 -0700 (PDT) From: Guoqing Jiang To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: hch@infradead.org, david@fromorbit.com, willy@infradead.org, Guoqing Jiang , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [RFC PATCH 3/9] btrfs: use set/clear_fs_page_private Date: Sun, 26 Apr 2020 23:49:19 +0200 Message-Id: <20200426214925.10970-4-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200426214925.10970-1-guoqing.jiang@cloud.ionos.com> References: <20200426214925.10970-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 btrfs. Cc: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Signed-off-by: Guoqing Jiang --- fs/btrfs/disk-io.c | 4 +--- fs/btrfs/extent_io.c | 21 ++++++--------------- fs/btrfs/inode.c | 17 ++++------------- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a6cb5cbbdb9f..1230863e80f9 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -980,9 +980,7 @@ static void btree_invalidatepage(struct page *page, unsigned int offset, btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info, "page private not zero on page %llu", (unsigned long long)page_offset(page)); - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); + clear_fs_page_private(page); } } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 39e45b8a5031..de8c2d5a99db 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3076,22 +3076,16 @@ static int submit_extent_page(unsigned int opf, static void attach_extent_buffer_page(struct extent_buffer *eb, struct page *page) { - if (!PagePrivate(page)) { - SetPagePrivate(page); - get_page(page); - set_page_private(page, (unsigned long)eb); - } else { + if (!PagePrivate(page)) + set_fs_page_private(page, eb); + else WARN_ON(page->private != (unsigned long)eb); - } } void set_page_extent_mapped(struct page *page) { - if (!PagePrivate(page)) { - SetPagePrivate(page); - get_page(page); - set_page_private(page, EXTENT_PAGE_PRIVATE); - } + if (!PagePrivate(page)) + set_fs_page_private(page, (void *)EXTENT_PAGE_PRIVATE); } static struct extent_map * @@ -4929,10 +4923,7 @@ static void btrfs_release_extent_buffer_pages(struct extent_buffer *eb) * We need to make sure we haven't be attached * to a new eb. */ - ClearPagePrivate(page); - set_page_private(page, 0); - /* One for the page private */ - put_page(page); + clear_fs_page_private(page); } if (mapped) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 320d1062068d..07871c57ba96 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8303,11 +8303,8 @@ btrfs_readpages(struct file *file, struct address_space *mapping, static int __btrfs_releasepage(struct page *page, gfp_t gfp_flags) { int ret = try_release_extent_mapping(page, gfp_flags); - if (ret == 1) { - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); - } + if (ret == 1) + clear_fs_page_private(page); return ret; } @@ -8331,11 +8328,9 @@ static int btrfs_migratepage(struct address_space *mapping, if (page_has_private(page)) { ClearPagePrivate(page); - get_page(newpage); - set_page_private(newpage, page_private(page)); + set_fs_page_private(newpage, (void *)page_private(page)); set_page_private(page, 0); put_page(page); - SetPagePrivate(newpage); } if (PagePrivate2(page)) { @@ -8458,11 +8453,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset, } ClearPageChecked(page); - if (PagePrivate(page)) { - ClearPagePrivate(page); - set_page_private(page, 0); - put_page(page); - } + clear_fs_page_private(page); } /* -- 2.17.1