Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp957637pxb; Thu, 19 Aug 2021 15:56:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+sHesp5xBv0ESHBf9xButU3LvkIxR5BsrX1JMal7jVwl7Bw5nMc2u3Eomntc3nEqZyAHr X-Received: by 2002:a17:906:488a:: with SMTP id v10mr17842738ejq.91.1629413783167; Thu, 19 Aug 2021 15:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629413783; cv=none; d=google.com; s=arc-20160816; b=JiTmk+dxOJ4FGlNSTyIWbREIHLL/weqoczs1/54+ze3lhqs7t7b8AsI+ZiLKs/9J6u b9IPouDMgRO4Y2b9tOHPzdtIxDsnXW8VJyNYNLjaoqvhj9h/W8W7AbY/21QJyjIaNGf2 SetdefxUC2ot9BaSXh5Vt7LcbgMAJHlBJzSE0yE0DQ7VRUbFXx9Q02hI0YB5aTsJHIDs CYV9XFNPprio3g41JkM1kVazf4edwkzMP3Pz0dE5bQurq3ZDjgA2lvk7RdiKT0TnQmJ5 WZG0Xkgm5aNYmcv6DKFMxgi7rcEraXo3QESC8Rjmr7jYd3t9JQr+7bpgv72c7ZvGJpzB Npxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Lv2BeH4bgVl/il3tYjXjqwuIZSwlS9CtCv+JW+Pfbnk=; b=r/37lVlVS8RV1BgAYYXsMfwXx51iveuIlfJUDlk2zyBgG6RQryySOQB0EKyQJDiFCn JF7skx+Qo54l4U/oCmzM1yXVGl49F/ha3ZUfj+H2KlVyHaSLd8AZTpVMWXnztLkktZHq kJ6fP8T1aH9d65gVoMSzpb2flwsHp++DANU0ZLq86WMUSfiIRRbQ55yWt8kFJMtoiP3D N5tpxAcxhgaoOI10XEzf495HyWUn3mJG1S2B7dim7KRZRIwNFjcQl69cCYBFkz2LWL2i g2isacgZWMgl9j2/0FMUp9RZkFuiTEcs1GfnTAPB2duaDJdvNpkTqeVFJ3mz2c26E3UN BmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=dEJPorhN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si5778371edb.418.2021.08.19.15.55.57; Thu, 19 Aug 2021 15:56:23 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=dEJPorhN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233819AbhHSWyu (ORCPT + 99 others); Thu, 19 Aug 2021 18:54:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhHSWyu (ORCPT ); Thu, 19 Aug 2021 18:54:50 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E5BBC061575 for ; Thu, 19 Aug 2021 15:54:13 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id t1so7326318pgv.3 for ; Thu, 19 Aug 2021 15:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Lv2BeH4bgVl/il3tYjXjqwuIZSwlS9CtCv+JW+Pfbnk=; b=dEJPorhN3VxbZejMS9q6PqBKwfMxKo1HPdf3+5BUH3dfXPgs88YSbj05k1hkBef+nM 7vvU9XbId6WFv2lSIWSM6XXy2UPxLdeQ01Wfso2qKlbUco0zvIots/ul6DKzQ3DZcYNi P23cHa+p9+b2jIJWKtu1dQDl7lc5qIeAeuXdBKWusDgdFF5Zj6LRxzv+LIlIsEDHbKIC bA+OW2FTcspqya2PhtHxAy1glalU05anLkdQRHMAOe/TGgzUsBpfY3vrr6LgE6ZRnpxT PRy9SHdri/5ppUNRZwQkgaG+JzE/XBJi92LOIl7cj7phiuPVPAc4PUoOZ9875GEsDMjs SlKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Lv2BeH4bgVl/il3tYjXjqwuIZSwlS9CtCv+JW+Pfbnk=; b=eHdJPVB0Gz2RyFyhfyAMZnMRzecFCUH/Iu4ZbXt+35Q3Ukx2G5Q9pD27SgC7dIzmrg 1sZHKDch/IzTyvr0L1OCAigYtgKVYQ1M55JilH8tADz3Wt1wbuzAJmFxSTHRBGPyczEl CuXzP0gSMCnHqUT7M8CoJxqKPahBpJ4OYuFkBLaN3LVRXLPwWZD2TN93qbNgi6QTIhQL cTVnmdkTgGH9ywnMjTL+FvCn367/P9hwremrBcxZwtxopRMLxEAmE5vbpGJYBVbabXSj VPAMutwmXvLob2A1tjqXUfX5DPKMaN4YYFCbMGGvqb6Q3VWftxgQ8fw39eL3GLrBgbds lqZg== X-Gm-Message-State: AOAM533HvGW92RPsyCYlGsh+91vdWs0bUuDy+/wi3s/eeHpfTL/C4F8f HxAyzLrhaFPHEhfCKFU3bVHCbQNsb6BlgScKGLcWVw== X-Received: by 2002:a05:6a00:16c6:b029:32d:e190:9dd0 with SMTP id l6-20020a056a0016c6b029032de1909dd0mr16584327pfc.70.1629413652651; Thu, 19 Aug 2021 15:54:12 -0700 (PDT) MIME-Version: 1.0 References: <20210816060359.1442450-1-ruansy.fnst@fujitsu.com> <20210816060359.1442450-4-ruansy.fnst@fujitsu.com> In-Reply-To: <20210816060359.1442450-4-ruansy.fnst@fujitsu.com> From: Dan Williams Date: Thu, 19 Aug 2021 15:54:01 -0700 Message-ID: Subject: Re: [PATCH v7 3/8] fsdax: Replace mmap entry in case of CoW To: Shiyang Ruan Cc: "Darrick J. Wong" , Christoph Hellwig , linux-xfs , david , linux-fsdevel , Linux Kernel Mailing List , Linux NVDIMM , Goldwyn Rodrigues , Al Viro , Matthew Wilcox , Goldwyn Rodrigues , Ritesh Harjani Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 15, 2021 at 11:05 PM Shiyang Ruan wrote: > > We replace the existing entry to the newly allocated one in case of CoW. > Also, we mark the entry as PAGECACHE_TAG_TOWRITE so writeback marks this > entry as writeprotected. This helps us snapshots so new write > pagefaults after snapshots trigger a CoW. > > Signed-off-by: Goldwyn Rodrigues > Signed-off-by: Shiyang Ruan > Reviewed-by: Christoph Hellwig > Reviewed-by: Ritesh Harjani > Reviewed-by: Darrick J. Wong > --- > fs/dax.c | 39 ++++++++++++++++++++++++++++----------- > 1 file changed, 28 insertions(+), 11 deletions(-) > > diff --git a/fs/dax.c b/fs/dax.c > index 697a7b7bb96f..e49ba68cc7e4 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -734,6 +734,10 @@ static int copy_cow_page_dax(struct block_device *bdev, struct dax_device *dax_d > return 0; > } > > +/* DAX Insert Flag: The state of the entry we insert */ > +#define DAX_IF_DIRTY (1 << 0) > +#define DAX_IF_COW (1 << 1) > + > /* > * By this point grab_mapping_entry() has ensured that we have a locked entry > * of the appropriate size so we don't have to worry about downgrading PMDs to > @@ -741,16 +745,19 @@ static int copy_cow_page_dax(struct block_device *bdev, struct dax_device *dax_d > * already in the tree, we will skip the insertion and just dirty the PMD as > * appropriate. > */ > -static void *dax_insert_entry(struct xa_state *xas, > - struct address_space *mapping, struct vm_fault *vmf, > - void *entry, pfn_t pfn, unsigned long flags, bool dirty) > +static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, > + void *entry, pfn_t pfn, unsigned long flags, > + unsigned int insert_flags) I'm late, so feel free to ignore this style feedback, but what about changing the signature to: static void *dax_insert_entry(struct xa_state *xas, struct vm_fault *vmf, const struct iomap_iter *iter, void *entry, pfn_t pfn, unsigned long flags) > { > + struct address_space *mapping = vmf->vma->vm_file->f_mapping; > void *new_entry = dax_make_entry(pfn, flags); > + bool dirty = insert_flags & DAX_IF_DIRTY; > + bool cow = insert_flags & DAX_IF_COW; ...and then calculate these flags from the source data. I'm just reacting to "yet more flags". So, take it or leave it, Reviewed-by: Dan Williams