Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6804321ybl; Wed, 15 Jan 2020 10:25:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzRasJPtCAk6TRR9lLFUo9MOJl/cEw2sgAKjqr+Rn6X6dJ0yqiKWamwtOSd5hMULBIS5SRU X-Received: by 2002:a9d:6c52:: with SMTP id g18mr3736900otq.356.1579112739530; Wed, 15 Jan 2020 10:25:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579112739; cv=none; d=google.com; s=arc-20160816; b=ieZx5cTtS9fJpGkvoZ4/5kOng73Yy0tHhBkfGFRt3kqi0b0rAYa4fc+vWOPeLetQVv BwfBLPGeovyC1+xGQRYKNBit8Jmk6UW90TG++ACsyPEEMnPZ32zJfektNbbkSUGli20V HxnfhpGI9t4Y1JZy12AE9q4DiMef/TZuG7FwnXYpfouWkBogp7pjNk7mdi+z5J2nGLez YIF+kFaRR7TIwY4VgTlG71iQKWC1waVqPKrKcSV9PUTWLrCgzptrlt2sTy2VffdNKegP oClLZ/XXSzFHut24v3UGWIujntS5y/g2fgzFEVuS1geeNMw2sL5yK4cBZ4sFPDfZd9jp T4Cw== 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=BIOvx2OyXuGuFWYHuTWVrCl0vF011QtUQNWwpHnCbBI=; b=Wu8G+VaWD1EEi+f3PEkIGbDzXOHuanSsW4tNLwfPqKpWdQm2M4IJFAkOHrDkoqjnHH o+901Htf5EveLD2TLxjS0X22QEy6H7vleLtrEqKg1c4veq45wZomgXX1tsBj0rkrUGz+ evDvQuwdhBsGuz/Ko9+3O5kstRoU0talc3wlhKfbqdOAIHWzfmMvo4Qbm0CvhtnH80+W uaxCqs9p3Ef6yQcZJBftSX5WfgfHnL65DGp47JFsJW2YwjY1taqZ0PpsVfC2AoR3Ahs2 u38nsX2TS7T7zc8wncjlwBrmMjXoJ1GXkcDYOccNZhJLeF0xm1fp73xAJXMjs37pr8f3 EfZQ== 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 o7si11586000otk.185.2020.01.15.10.25.24; Wed, 15 Jan 2020 10:25:39 -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 S1729130AbgAOSYr (ORCPT + 99 others); Wed, 15 Jan 2020 13:24:47 -0500 Received: from mga01.intel.com ([192.55.52.88]:40076 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729014AbgAOSYr (ORCPT ); Wed, 15 Jan 2020 13:24:47 -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; 15 Jan 2020 10:24:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,323,1574150400"; d="scan'208";a="248498688" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by fmsmga004.fm.intel.com with ESMTP; 15 Jan 2020 10:24:46 -0800 Date: Wed, 15 Jan 2020 10:24:46 -0800 From: Ira Weiny To: Jan Kara Cc: "Darrick J. Wong" , linux-kernel@vger.kernel.org, Alexander Viro , Dan Williams , Dave Chinner , Christoph Hellwig , "Theodore Y. Ts'o" , 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: <20200115182446.GD23311@iweiny-DESK2.sc.intel.com> References: <20200110192942.25021-1-ira.weiny@intel.com> <20200110192942.25021-10-ira.weiny@intel.com> <20200113222212.GO8247@magnolia> <20200114004610.GD29860@iweiny-DESK2.sc.intel.com> <20200114013004.GU8247@magnolia> <20200114175353.GA7871@iweiny-DESK2.sc.intel.com> <20200115113455.GA2595@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200115113455.GA2595@quack2.suse.cz> 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 Wed, Jan 15, 2020 at 12:34:55PM +0100, Jan Kara wrote: > On Tue 14-01-20 09:53:54, Ira Weiny wrote: > > On Mon, Jan 13, 2020 at 05:30:04PM -0800, Darrick J. Wong wrote: > > > > > > + 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. > > > > > > But the number of memory mappings reflects the state of the address > > > space, not the inode. Or maybe put another way, if I were an mm > > > developer I would not expect to look in struct inode for mm state. > > > > This is a good point... > > > > > > > > static inline bool inode_has_mappings(struct inode *inode) > > > { > > > return atomic64_read(&inode->i_mapping->mapcount) > 0; > > > } > > > > > > OTOH if there exist other mm developers who /do/ find that storing the > > > mmap count in struct inode is more logical, please let me know. :) > > > > ... My thinking was that the number of mappings does not matters to the mm > > system... However, I'm starting to think you are correct... ;-) > > > > I've made a note of it and we will see what others think. > > Well, more importantly mapping != inode. There can be multiple inodes > pointing to the same mapping (struct address_space) as is the case for > example for block devices. So this counter definitely belongs into struct > address_space. Ah Yes, great point. Done. Ira