Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1092801ybj; Thu, 7 May 2020 14:46:57 -0700 (PDT) X-Google-Smtp-Source: APiQypJyeFQu+jdxyKfXQsE6gNtqp4vF/5ZDz98XQgnNO0t0M8SwR57Zjv2janpFAVZ/nWDcwvJ9 X-Received: by 2002:a17:906:1292:: with SMTP id k18mr14141121ejb.132.1588888016819; Thu, 07 May 2020 14:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588888016; cv=none; d=google.com; s=arc-20160816; b=oCLV40VRD+RNBRt9tkGfnLPml0OeuGVIUt6e9GN45msF+HmZtS/aHh/U8DV7R9ZeEn pQ2+/movAQ8TkGbGgu8FdGF3NYkQB7juREeAdHVf4GsUIlwz0RD6/QWBWDjIuFHzb9Ef 83Va1gj9rNOc93Hp/cZ0uYrBDGoV+chM7Y68Ug3/BUxy7ZKHPaVkwzTAx0HvKBXDM41M vS/NlIiE6XTGW7A+JxYsP0ifMRsQJ3PhhIl7XLFYaOqQiC2bHTeVQUfJbHWLSH68yana TCWR7LAYeOJiBuu2rPQX3ZrPgQJd3hAeLqmmmIOCjtDdF6T9imbIrP3qW7pIposdEPDs Y5ug== 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=W6k+nr3o33Kw7lh1iadEOaXBpO+mApJUEyA7nm+lCVE=; b=FrCNHhldDQ8u5sMHRETX2o8Thb0IxSiru4hpikQCmutw16VEY3YQua2D4eDJ2GdY/O hA6vD3a6PXaJijdhnKQTBpXRmJpwuOZJqsb3q82Fj2cmQe/bdyC7mYnU+ghFOxKVbqir HlGLzOUVBqzl+B37utDFVHxc6NM9aDGQza1ic2Ho+alpYL5I8Jx8i16AjApMTmDL8KGb lBQ01I+sX59F/AqauHmgnXybsENMUxQmTz8s4QpfOcOGOcxS6ejbJbJQ3YgFD2y9Bmtt O8obq8WHumBBkGZ/HVjMPsuWxRlIWZMJQWnz6l9Bi0NJ76lzpXbUwV56sWQRA7bYOUIf o08g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloud.ionos.com header.s=google header.b=FZ6fTGY3; 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 os28si3968447ejb.98.2020.05.07.14.46.34; Thu, 07 May 2020 14:46:56 -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=FZ6fTGY3; 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 S1727827AbgEGVou (ORCPT + 99 others); Thu, 7 May 2020 17:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbgEGVoZ (ORCPT ); Thu, 7 May 2020 17:44:25 -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 F2854C05BD0A for ; Thu, 7 May 2020 14:44:24 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id pg17so5883760ejb.9 for ; Thu, 07 May 2020 14:44:24 -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=W6k+nr3o33Kw7lh1iadEOaXBpO+mApJUEyA7nm+lCVE=; b=FZ6fTGY3spuMmoNHovS2scKLAy45oECWLSGK4J8REO6bw+4MW2ufoPSSSNz4nTBrTA uyubEJPaMyOadZhoVN6d8x5b6qP9FkAjC5BD3T9F4XzBwEM1H3m07rKkz/xDgE2jdqEd AdgyKlLCvCmG9+hMQUHlzORPrlkfhvL4lq26Z99gjOTMmSTjirVXLYol/xQD0R+jCnAQ lt5rSDUMrEw2zSDAUP7bn4kKRw+dTD8510FerIpIoLJXGNEopsr8Mo2A9Fp6zFJllyyZ 2XainexmOGHw1py11wgLiDhzo6t7UCj7LAKSxLHZ2MLOs4ZoeMFE7eGI/nf/D6J/Gwko vFLg== 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=W6k+nr3o33Kw7lh1iadEOaXBpO+mApJUEyA7nm+lCVE=; b=oGI+oBE1TQCvgY4aIfNIsQAI8kGWBbiyO3Z30FxDLAban/BI+wU3tlO+2L6HZ4nI3+ IY0tDYzlc85UsdBmML8beD//VQEWCMsB67BpQaU7iYsjHwcmvkVaPSYj13OKEqFhle1m ePXLx1mJ5yAQkImbhXM50nLoxyigSNi/sKDfiYoxCh9uBN4HD1EqJU5+R1xLdMyiJOG0 00BpcGyX87ulJR+nfNaaw3AKOrJjCyqC0DkIwdqqr2q6fwGtYPZ+/64CyYAcpHNNxaI1 qSS+WOYGZ/zkJsLUP+K5qWhwA7HMOpX3CEzCmcFVvcP5rY3Ly0B69kiBRfiTIoSWzyyF DYWw== X-Gm-Message-State: AGi0PuYjIHl72nwPjwMyXxp2TyZ4jITONBHvUePMa1hMpdWHJ4n665W8 tEsJmjBwL84zEyWlzRHi3cbvWQ== X-Received: by 2002:a17:906:4714:: with SMTP id y20mr14594259ejq.5.1588887863537; Thu, 07 May 2020 14:44:23 -0700 (PDT) Received: from ls00508.pb.local ([2001:1438:4010:2540:a1ee:a39a:b93a:c084]) by smtp.gmail.com with ESMTPSA id k3sm613530edi.60.2020.05.07.14.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 14:44:22 -0700 (PDT) From: Guoqing Jiang To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: david@fromorbit.com, hch@infradead.org, willy@infradead.org, Guoqing Jiang , "Darrick J. Wong" , linux-xfs@vger.kernel.org Subject: [RFC PATCH V3 06/10] iomap: use attach/detach_page_private Date: Thu, 7 May 2020 23:43:56 +0200 Message-Id: <20200507214400.15785-7-guoqing.jiang@cloud.ionos.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200507214400.15785-1-guoqing.jiang@cloud.ionos.com> References: <20200507214400.15785-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 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 89e21961d1ad..e3031007b4ae 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); } @@ -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, detach_page_private(page)); if (mode != MIGRATE_SYNC_NO_COPY) migrate_page_copy(newpage, page); -- 2.17.1