Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2310644ybz; Thu, 30 Apr 2020 14:54:54 -0700 (PDT) X-Google-Smtp-Source: APiQypKRVePL3oE3IZZ3bAMVqPtZpYV0V63WVQxxPoRrJgnnEbC5FJM+gbHRE2jc5fLkcaSon+8W X-Received: by 2002:a17:906:6a02:: with SMTP id o2mr492476ejr.223.1588283694094; Thu, 30 Apr 2020 14:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283694; cv=none; d=google.com; s=arc-20160816; b=yYKJ3DH9iEsbzfpr2k9If4kWghmnqycvFUqDQ5AA7WnhBtSwaTsqIdTPNP64PjxjSR JMQ2CA7Ki+TNVCjRN5jZOHLUWWOKs+ytaKiPJ1CInB7LtM99dHq5YiVsxymgISVV/B/i M51amjkvS8OgVf88XnQToHPUuapRHN0R0FLAfvQcoGq3pL2wQ7j/A8EUWqo+9eF2XT0C cc/1Z8XwJKHe3Tm8RYAket/KWMlZzqxFqQR15gjrwOEwYSdNxAaQIDG2ATq0NBMe5oLd qhn9lLG3g0M5t1HItzqaVBTPLzVJdCuYGNv0bGKuUIgZv9dG6Ampvl8pCzL/2XBoMbl7 F49w== 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=LDEyu4DqGHwJ7t/wlLTaUyFP1PKV8rYydYP0xvjnvj8=; b=Y07RlpTNLobPnabbpIvriuvF+4impreNY5olSZbwjNEMNThBgWv35BbVYrEvXBltMS aRn0SI9mSlfHHqlPQ6P6mSMYxTk1fv4iOFq+qhB05C+7AV41XeAZlFC/r6QA05T4Xg0b nc3IHi20hCi4Vk1Cbhs0NjRinNB+OIiLUmwjjX4FR+f25q6RFuCJ02HY+/rXPAAHhBpl koqQYE1jk7w3R7tvNPMI5o5tPV74o+Bt70M+nHiKZ4Tm7Phmam1tVwItkuOvJvR9X5da 1ngr6xign5qVxaqIVYns2s2iHfw1cs27DQlqLEBV44ig8kKyU8rug284qJPgi2E4JRvP +4vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=K0b9BUEb; 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 o17si538215eju.70.2020.04.30.14.54.31; Thu, 30 Apr 2020 14:54:54 -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=K0b9BUEb; 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 S1727888AbgD3Vwq (ORCPT + 99 others); Thu, 30 Apr 2020 17:52:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727788AbgD3Vwo (ORCPT ); Thu, 30 Apr 2020 17:52:44 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03169C08E934 for ; Thu, 30 Apr 2020 14:52:44 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id n4so5956392ejs.11 for ; Thu, 30 Apr 2020 14:52:43 -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=LDEyu4DqGHwJ7t/wlLTaUyFP1PKV8rYydYP0xvjnvj8=; b=K0b9BUEbUMN4c/HcO3EMetbwDKa/bQB7gEHoueMz+xCk9NFN8tJEEGyelIxvpaZToN ECQhJ9+wuy6qVtEwW9mUbisrOp3Pj/n5ULKfaLTMyrAgHJ/y7vfV7+QRzZcu/ByCJwZV CPuAb8QHPy18fm4QKel2ZHntwvTIDJWCm5hPjM+GtW6xp2scc5EbWir72q2kghoVWPxH Az6OQH50Tuf5V695TOo+L4tAZIwvPVOvxxLMV5G8tX86ymSPIZ2N9QR403Il6RFjXg4b ouaTyJZDdGlDGYke3obk+Sa+ExaUEl1q26wAKLnV/KKIMOjQcxkwBOITpksORcNhKjYu O75w== 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=LDEyu4DqGHwJ7t/wlLTaUyFP1PKV8rYydYP0xvjnvj8=; b=lrS+2UKIgCoSEQSFZJ0vOpd3TOQ9u2kQfaRVjF7sBn+JoeaMCGzUFSQag/LnSspqPf dfAJFPxlKHjkfA/2YWFhjsdTAGntYPDrqwNdzSSWEl+TXWVH7YxxOUR2wxuAaeWCKoYv UbjLtbNN94ERfOtOkjHX4FJQ5CRJoU2WXsAxRzvwj7PvMBvuQ6YZpt5IvZvvtGNFIsun NhldFfzQPjDOtqqNzAU42TdnWxYuRJIyms4JkJ3Tw0Ugye8fu+0+HlsOUgtqiOB0tUYy inbwU2MXlcAimpP+yPPSeqKR3usgiDMt2r952o5dF2aoGVOp/UyFURlnjC6yL0/xrenz lwqQ== X-Gm-Message-State: AGi0PuYNTVMHMEkj0exPhVZb71MVuV/c4CXWnXmsTM4QJxLjhD/YYfsI w2Y+Jawd6j90p7Kn+8wv/qLInw== X-Received: by 2002:a17:906:5918:: with SMTP id h24mr537740ejq.210.1588283562672; Thu, 30 Apr 2020 14:52:42 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:b82f:dfc:5e2a:e7cc]) by smtp.gmail.com with ESMTPSA id f13sm92022ejd.2.2020.04.30.14.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:52:42 -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 , "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [RFC PATCH V2 6/9] iomap: use attach/clear_page_private Date: Thu, 30 Apr 2020 23:44:47 +0200 Message-Id: <20200430214450.10662-7-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214450.10662-1-guoqing.jiang@cloud.ionos.com> References: <20200430214450.10662-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 --- 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 89e21961d1ad..cf4c1b02a9d8 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 = clear_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); } @@ -554,14 +549,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, clear_page_private(page)); if (mode != MIGRATE_SYNC_NO_COPY) migrate_page_copy(newpage, page); -- 2.17.1