Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp816093pxb; Tue, 12 Apr 2022 14:14:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkl7hwjrBkIwQ31/Yo64ddizzF2dpSFiVbAGA5oGpeTY7Wju1XG2LoYJFdoDGEUBRCyWUI X-Received: by 2002:a17:902:dac5:b0:158:5db6:3503 with SMTP id q5-20020a170902dac500b001585db63503mr13013263plx.76.1649798063175; Tue, 12 Apr 2022 14:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649798063; cv=none; d=google.com; s=arc-20160816; b=chZWWe0wo4oFW6flGOtDOWBDFzWtZomdxmVDbR+nrEZbejsRrzggcfKbcQ6BpTUQAc xWugM8rHpoDuRq5dRQo5+7oZ8otaG89CCYdnyrf8aP/V3pfa2yRvrP6fGt2PhSKBGLuj hoLgZwgU0/VTUZHT0m1yhgYkkU3yx9d/TbXeEcN95u9ERtGWZiZE3nxw5xmAEpQUWzkQ hYa7w+/3qcmLcIYYRVGWjmvwbX0URlRCCewFuVhHhRLxu1dOqTEJxZpyC0yORo8YOW/6 S2Imdrq7pGtlzXuoVPERurL/tcCOX6qk60YhcRS7dCltGuoCqXS9XKoBMLLfDYDAq+BQ hZpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GJM0jYn00v1gzHURiVOdNItn1NFnRTfjl2UiVvY+3iE=; b=QV7AZQdYoqqrC3+8upTgSirixWL8n2iyS88NL3tTe/xdTEPPYflp2JE8q5N6o0fz2W kUia6ffv1k1kTnkg5BP08QzeC1LE4x7EEiSAAuWkUOIar3mWnmrDZ0/tkihGz/wcqqcR MitxWiYPGC1qNrMj6hbnfFRos2AbmTGURBLyjOU8mVNn3VWihk9sdZaBeC9dthyET4Pi cxEww07LoTJpBVLe3rWimLCvR1tD4aupE4HhADzGu1xdXMLMKd1envYm/sqNi/Tlp5jT KMJ0EPFe2ynWSb5Rmz84+pE0vS7gPBEvA0ZV3jm7rBxQk3UOSePFz2MUJI846BHkp104 0Zig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=S6U9Ukjb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id my13-20020a17090b4c8d00b001c6c8e19f0csi17618344pjb.98.2022.04.12.14.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:14:23 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=S6U9Ukjb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4B77269CFF; Tue, 12 Apr 2022 13:29:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245103AbiDKG6B (ORCPT + 99 others); Mon, 11 Apr 2022 02:58:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245135AbiDKG5u (ORCPT ); Mon, 11 Apr 2022 02:57:50 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79C21F627; Sun, 10 Apr 2022 23:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GJM0jYn00v1gzHURiVOdNItn1NFnRTfjl2UiVvY+3iE=; b=S6U9UkjbII+TZi9sq+N2w7jRIL gxayyYr/3ajrps4WfKYqkBXwe+qgjlqpClozl35qB24rRl150bmssg8ghyX0veUlZMGel3yDA4Kg9 iWtO74ihMEDlS0R4OWRidlpwSmQIAYjobNQuTCSO5FXSaZLumRPx3Mku81oGPVb8uPw2S1jjyPQ3T CKyyY/mh11QGYZXGYu8Ob6Yg8bJv5oNBsbfEWCbVc9T4Fyf13ET9sjHS4MQWNx6xg/XYyPQB/ZyUH SRYJ1r0yV4Y1xarcJs34friUNfRvATgVUw0N+0cxDzTP5eniAa+K6cI9Qb6cMAlWsKzI3Rh31tirf clpm8YTg==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ndnxX-0070Zq-Vb; Mon, 11 Apr 2022 06:55:36 +0000 Date: Sun, 10 Apr 2022 23:55:35 -0700 From: Christoph Hellwig To: Shiyang Ruan Cc: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, djwong@kernel.org, dan.j.williams@intel.com, david@fromorbit.com, hch@infradead.org, jane.chu@oracle.com Subject: Re: [PATCH v12 7/7] fsdax: set a CoW flag when associate reflink mappings Message-ID: References: <20220410160904.3758789-1-ruansy.fnst@fujitsu.com> <20220410160904.3758789-8-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220410160904.3758789-8-ruansy.fnst@fujitsu.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + * Set or Update the page->mapping with FS_DAX_MAPPING_COW flag. > + * Return true if it is an Update. > + */ > +static inline bool dax_mapping_set_cow(struct page *page) > +{ > + if (page->mapping) { > + /* flag already set */ > + if (dax_mapping_is_cow(page->mapping)) > + return false; > + > + /* > + * This page has been mapped even before it is shared, just > + * need to set this FS_DAX_MAPPING_COW flag. > + */ > + dax_mapping_set_cow_flag(&page->mapping); > + return true; > + } > + /* Newly associate CoW mapping */ > + dax_mapping_set_cow_flag(&page->mapping); > + return false; Given that this is the only place calling dax_mapping_set_cow I wonder if we should just open code it here, and also lift the page->index logic from the caller into this helper. static inline void dax_mapping_set_cow(struct page *page) { if ((uintptr_t)page->mapping != PAGE_MAPPING_DAX_COW) { /* * Reset the index if the page was already mapped * regularly before. */ if (page->mapping) page->index = 1; page->mapping = (void *)PAGE_MAPPING_DAX_COW; } page->index++; } > + if (!dax_mapping_is_cow(page->mapping)) { > + /* keep the CoW flag if this page is still shared */ > + if (page->index-- > 0) > + continue; > + } else > + WARN_ON_ONCE(page->mapping && page->mapping != mapping); Isnt the dax_mapping_is_cow check above inverted?