Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4597893ybl; Mon, 13 Jan 2020 16:50:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyB4q/lgHTygbdCWwL1IMuggBMFRMHAXT/90vaYvHRi8SkgLvpJCPEg4IFcr4rCess7WeJ1 X-Received: by 2002:a05:6830:1257:: with SMTP id s23mr15158078otp.241.1578963049967; Mon, 13 Jan 2020 16:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578963049; cv=none; d=google.com; s=arc-20160816; b=hlCDfeCkGpF367VzmefV+F9/MBnoZbL13knYnMMzfd2MnKo2vnyYoiAsk1AZe4m/j0 3eL2dcf3ZkeKt98TWJHYLcs1IOKyih39sTKgcw2jE3Wf8yKAwJEkKhSYFVDVrFa0fhqx FJ1mwXb6WcJKAOA7ku05XwULlk8MoPJJ61hyLrRKnykEK02OxyV/ta+1EP3PD2Jy3vs0 F+7vyxxqV6voNcuLr9dI5lLLHgDQNhIwyW/seCwwtol1gbxh4ySG00A08GS7HeQXBXun PQ+asGRFmSkzsg+wz8HlcD1iBVhGCdbamcCg/5BQS4Ciy57WQ8CNWu/ak8Oci/edl+/g 08vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AX2Fwg3XvyIseaEKoI299XB03pxeeJuC2eGjufRHf8s=; b=TrHlZRpxBE4Jp9C+mk6blHtx4M9NChSIa4fU20gaQ/4jGH+WYIC7mrLYe+fLH+s9WZ EOhbJ1dItn5Q+EOaf7hnHveR50XkCwjSCp2rS8E+Fjg4d+0QYcVDIryY3V3oqqQam59a 6evVCrXsUkN+71FJ9IB0FAx9kuF9ELw+oroYIeV/n0zDKsRVr21wZPXLW9zf+/po84zm 1vACvryUZNU6F+oYYm3Xi8QLDSdf1Z4k/P/Ymaq6jFaPHcBNJYLif969sOuc2MWGCcS7 keAnAeQQ65dwlt7GzZSAzP3YvT5bE1aLpDG0pWYQp3aAQl79YmbSGQ49vNq+8BoRTg1e Qw+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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. [209.132.180.67]) by mx.google.com with ESMTP id b11si7002131oie.152.2020.01.13.16.50.39; Mon, 13 Jan 2020 16:50:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 S1729256AbgANAqL (ORCPT + 99 others); Mon, 13 Jan 2020 19:46:11 -0500 Received: from mga01.intel.com ([192.55.52.88]:44320 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbgANAqL (ORCPT ); Mon, 13 Jan 2020 19:46:11 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2020 16:46:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,431,1571727600"; d="scan'208";a="247869908" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga004.fm.intel.com with ESMTP; 13 Jan 2020 16:46:10 -0800 Date: Mon, 13 Jan 2020 16:46:10 -0800 From: Ira Weiny To: "Darrick J. Wong" Cc: linux-kernel@vger.kernel.org, Alexander Viro , Dan Williams , Dave Chinner , Christoph Hellwig , "Theodore Y. Ts'o" , Jan Kara , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [RFC PATCH V2 09/12] fs: Prevent mode change if file is mmap'ed Message-ID: <20200114004610.GD29860@iweiny-DESK2.sc.intel.com> References: <20200110192942.25021-1-ira.weiny@intel.com> <20200110192942.25021-10-ira.weiny@intel.com> <20200113222212.GO8247@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200113222212.GO8247@magnolia> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Jan 13, 2020 at 02:22:12PM -0800, Darrick J. Wong wrote: > On Fri, Jan 10, 2020 at 11:29:39AM -0800, ira.weiny@intel.com wrote: > > From: Ira Weiny > > [snip] > > > > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > > index bc3654fe3b5d..1ab0906c6c7f 100644 > > --- a/fs/xfs/xfs_ioctl.c > > +++ b/fs/xfs/xfs_ioctl.c > > @@ -1200,6 +1200,14 @@ xfs_ioctl_setattr_dax_invalidate( > > goto out_unlock; > > } > > > > + /* > > + * If there is a mapping in place we must remain in our current mode. > > + */ > > + if (atomic64_read(&inode->i_mapped)) { > > Urk, should we really be messing around with the address space > internals? I contemplated a function call instead of checking i_mapped directly? Is that what you mean? > > > + error = -EBUSY; > > + goto out_unlock; > > + } > > + > > error = filemap_write_and_wait(inode->i_mapping); > > if (error) > > goto out_unlock; > > diff --git a/include/linux/fs.h b/include/linux/fs.h > > index 631f11d6246e..6e7dc626b657 100644 > > --- a/include/linux/fs.h > > +++ b/include/linux/fs.h > > @@ -740,6 +740,7 @@ struct inode { > > #endif > > > > void *i_private; /* fs or device private pointer */ > > + atomic64_t i_mapped; > > I would have expected to find this in struct address_space since the > mapping count is a function of the address space, right? I suppose but the only external call (above) would be passing an inode. So to me it seemed better here. Ira > > --D >