[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200114004610.GD29860@iweiny-DESK2.sc.intel.com>
Date: Mon, 13 Jan 2020 16:46:10 -0800
From: Ira Weiny <ira.weiny@...el.com>
To: "Darrick J. Wong" <darrick.wong@...cle.com>
Cc: linux-kernel@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Dan Williams <dan.j.williams@...el.com>,
Dave Chinner <david@...morbit.com>,
Christoph Hellwig <hch@....de>,
"Theodore Y. Ts'o" <tytso@....edu>, Jan Kara <jack@...e.cz>,
linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: Re: [RFC PATCH V2 09/12] fs: Prevent mode change if file is mmap'ed
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@...el.com wrote:
> > From: Ira Weiny <ira.weiny@...el.com>
> >
[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
>
Powered by blists - more mailing lists