Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2247823ybk; Sun, 17 May 2020 15:09:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTzdJe5p5fwDpuRmDxMOX3HSrux6I3r7QvpFpXr7znbX7q0S4N4Gnp7XEDeyCYqQ75yj1E X-Received: by 2002:a50:c90b:: with SMTP id o11mr11038684edh.311.1589753385676; Sun, 17 May 2020 15:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589753385; cv=none; d=google.com; s=arc-20160816; b=AIWfc81KF0jSP4p4W1XniYD2RBL2xnU5DjHZGrzbY2L4dlX9hY6ieMLrwvCoCs23N+ NKO4Wvkh+LQ4tH/KTDiJ0Gp6jb7OXUJPJYfrOJTidkO0VfoVwdoFHjVLNN2FDQGUTYoi FPV4Nt7S03OnTPSQUlWsZnQqHwxQVHzFd2UwOPpGRiieJ46FuaAOK1hi2r9mlNJ/sLb7 RvrhYdZ84IDELhQwPb5MVnYtqwuw9Q85vf3UHuUemnm2ZuIJJ/aJ8FwDhG+5EOeeqgnh ZpmzfO9XKfDkUiINymozXiR2NV4NjDXxqJ686I7ZwLMeD9BXEPBuD0qW1fPGeYI8gu5k L5mw== 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=+NNOaVE9c9xGGuOYwwS94f/tcLOCL8JkmWYJIg2IYGE=; b=MNTA78Eb/aFnRIVNPC5lShWXhA74FOblLtIUFDFxcLdMeeSC1YoIyCx+Oh5F/kheYz DifytssmpKLEbqaarC6feOWHQQp8BsEai+jbUAF+ldO8dMwTlwHd4gi2SeSmPb0uXKZu iVOcHhP/dlHDVw61cP/S/848JimU+hvuEv07KrYN/ao++SFS/a6sl4zsHab3QsGlVEfV QqAxmniMKmAjpkBtW0JaUIGVGNNm3R+APhLzmgb/c6kofoaMkdWHbkXZv8Rw/G7cpofz u7N6GEandKqM/Greg7wdLyTeUKZgPhff6qR98ODxp6ETQBerLFVViK/1WDk2+rSTipiX 6L9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=W4RlgQDE; 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 gl8si5320342ejb.149.2020.05.17.15.09.20; Sun, 17 May 2020 15:09:45 -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=W4RlgQDE; 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 S1727788AbgEQVsL (ORCPT + 99 others); Sun, 17 May 2020 17:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgEQVr1 (ORCPT ); Sun, 17 May 2020 17:47:27 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BC05C061A0C for ; Sun, 17 May 2020 14:47:27 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id g14so20994666wme.1 for ; Sun, 17 May 2020 14:47:27 -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=+NNOaVE9c9xGGuOYwwS94f/tcLOCL8JkmWYJIg2IYGE=; b=W4RlgQDEM4dTeXyi2mptdIu5T2CvqwRG+TKlWVbkMelzNIfaff9Wmw0PAXMiyfwhWW yJAe47ZFLz3pYPOG9I3Il9qsRPlFq0oKinV6U9c1odAv8brONkSKQKblNq8dfw6SdEge qERSqJUwmaypO56h4G7DMc66bvjPx0fvQO9yOAmgusWYGI4DsNcSBiA08ndHk8UDn9Eo BkGzmsf7dVh1lNVUwGgJCxs9MRBYBkgb+9Jlka1rcfFw+IHqrgMTQk554+4nG7sZ8+fl d4ekX1CRU5P96jm1pxMRkllf8WkXhLbACTVHqQvDLQ36sdL8tVIO1XW7/hkyyr3mri9G tS3A== 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=+NNOaVE9c9xGGuOYwwS94f/tcLOCL8JkmWYJIg2IYGE=; b=I7hztI2buIVzrgF3N7HMGhP+KUdyCzn7W9XZNQevoAxT8GDoYZsFKu5hHbYu6ltZ7B bRL/FBm4gTjzplWbzZ8bC+pKmO8/z/71yIMMinImItqKh7om/rikcTgMOq/5IsWpOtaN aQnXC22SCNydvWqwEbaiNR0tHFk/oCfGJhmQyRQJWSyv1pI2bB6JUhwv3NoftMGwPiBR FAEB1XSGBpF6X+M82bfzRs+4R0CjCxEw0w5/8T+vSEuM620kpEqnXNcSOcZP6aFJzpLY /qtIvos0pCi4vfLdUIP00IqyhmOJ5PNWoRE/np1IP3/O1XBUbAyQVV/Xr0P3IJ5VsYAm ejUw== X-Gm-Message-State: AOAM530hXPOpAoJnhEbPrPNHfITPUkpcNORDiBvCJQiKXQAx5cHxpVJd Ayo2wOawEfhTKx2FFq48fzi0lw== X-Received: by 2002:a7b:ce01:: with SMTP id m1mr4221199wmc.116.1589752046199; Sun, 17 May 2020 14:47:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2020 14:47:25 -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 , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [PATCH 03/10] btrfs: use attach/detach_page_private Date: Sun, 17 May 2020 23:47:11 +0200 Message-Id: <20200517214718.468-4-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 btrfs. Cc: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: linux-btrfs@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 Dave Chinner. fs/btrfs/disk-io.c | 4 +--- fs/btrfs/extent_io.c | 21 ++++++--------------- fs/btrfs/inode.c | 23 +++++------------------ 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 714b57553ed6..44745d5e05cf 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -976,9 +976,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); + detach_page_private(page); } } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 451d17bfafd8..704239546093 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3099,22 +3099,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)) + attach_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)) + attach_page_private(page, (void *)EXTENT_PAGE_PRIVATE); } static struct extent_map * @@ -4935,10 +4929,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); + detach_page_private(page); } if (mapped) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 037efc25d993..6c2d6ecedd6a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7927,11 +7927,8 @@ static void btrfs_readahead(struct readahead_control *rac) 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) + detach_page_private(page); return ret; } @@ -7953,14 +7950,8 @@ static int btrfs_migratepage(struct address_space *mapping, 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 (PagePrivate2(page)) { ClearPagePrivate2(page); @@ -8082,11 +8073,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); - } + detach_page_private(page); } /* -- 2.17.1