From: Dave Chinner <david@fromorbit.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, xfs@oss.sgi.com
Subject: Re: [RFC PATCH 1/6] xfs: introduce mmap/truncate lock
Date: Fri, 23 Jan 2015 08:30:14 +1100 [thread overview]
Message-ID: <20150122213014.GA24722@dastard> (raw)
In-Reply-To: <20150122130905.GA25345@bfoster.bfoster>
On Thu, Jan 22, 2015 at 08:09:06AM -0500, Brian Foster wrote:
> On Thu, Jan 08, 2015 at 09:25:38AM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > Right now we cannot serialise mmap against truncate or hole punch
> > sanely. ->page_mkwrite is not able to take locks that the read IO
> > path normally takes (i.e. the inode iolock) because that could
> > result in lock inversions (read - iolock - page fault - page_mkwrite
> > - iolock) and so we cannot use an IO path lock to serialise page
> > write faults against truncate operations.
.....
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -150,6 +150,8 @@ xfs_ilock(
> > */
> > ASSERT((lock_flags & (XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL)) !=
> > (XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL));
> > + ASSERT((lock_flags & (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL)) !=
> > + (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL));
>
> The comment that precedes xfs_ilock() explains the locks that exist
> within the inode, locking order, etc. We should probably update it to
> explain how i_mmap_lock fits in as well (e.g., text from the commit log
> description would suffice, imo).
*nod*. Will fix.
> > ASSERT((lock_flags & (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)) !=
> > (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
> > ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_DEP_MASK)) == 0);
> > @@ -159,6 +161,11 @@ xfs_ilock(
> > else if (lock_flags & XFS_IOLOCK_SHARED)
> > mraccess_nested(&ip->i_iolock, XFS_IOLOCK_DEP(lock_flags));
> >
> > + if (lock_flags & XFS_MMAPLOCK_EXCL)
> > + mrupdate_nested(&ip->i_mmaplock, XFS_IOLOCK_DEP(lock_flags));
> > + else if (lock_flags & XFS_MMAPLOCK_SHARED)
> > + mraccess_nested(&ip->i_mmaplock, XFS_IOLOCK_DEP(lock_flags));
> > +
>
> XFS_MMAPLOCK_DEP()?
Good catch.
> > @@ -455,8 +507,12 @@ xfs_lock_two_inodes(
> > int attempts = 0;
> > xfs_log_item_t *lp;
> >
> > - if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL))
> > - ASSERT((lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)) == 0);
> > + if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)) {
> > + ASSERT(!(lock_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL)));
> > + ASSERT(!(lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)));
> > + } else if (lock_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL))
> > + ASSERT(!(lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)));
> > +
>
> Should this last branch not also check for iolock flags? If not, how is
> that consistent with the function comment above?
If we hit that else branch, we already know that the lock mode
does not contain IOLOCK flags. :)
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
WARNING: multiple messages have this Message-ID (diff)
From: Dave Chinner <david@fromorbit.com>
To: Brian Foster <bfoster@redhat.com>
Cc: xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [RFC PATCH 1/6] xfs: introduce mmap/truncate lock
Date: Fri, 23 Jan 2015 08:30:14 +1100 [thread overview]
Message-ID: <20150122213014.GA24722@dastard> (raw)
In-Reply-To: <20150122130905.GA25345@bfoster.bfoster>
On Thu, Jan 22, 2015 at 08:09:06AM -0500, Brian Foster wrote:
> On Thu, Jan 08, 2015 at 09:25:38AM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> >
> > Right now we cannot serialise mmap against truncate or hole punch
> > sanely. ->page_mkwrite is not able to take locks that the read IO
> > path normally takes (i.e. the inode iolock) because that could
> > result in lock inversions (read - iolock - page fault - page_mkwrite
> > - iolock) and so we cannot use an IO path lock to serialise page
> > write faults against truncate operations.
.....
> > --- a/fs/xfs/xfs_inode.c
> > +++ b/fs/xfs/xfs_inode.c
> > @@ -150,6 +150,8 @@ xfs_ilock(
> > */
> > ASSERT((lock_flags & (XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL)) !=
> > (XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL));
> > + ASSERT((lock_flags & (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL)) !=
> > + (XFS_MMAPLOCK_SHARED | XFS_MMAPLOCK_EXCL));
>
> The comment that precedes xfs_ilock() explains the locks that exist
> within the inode, locking order, etc. We should probably update it to
> explain how i_mmap_lock fits in as well (e.g., text from the commit log
> description would suffice, imo).
*nod*. Will fix.
> > ASSERT((lock_flags & (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL)) !=
> > (XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
> > ASSERT((lock_flags & ~(XFS_LOCK_MASK | XFS_LOCK_DEP_MASK)) == 0);
> > @@ -159,6 +161,11 @@ xfs_ilock(
> > else if (lock_flags & XFS_IOLOCK_SHARED)
> > mraccess_nested(&ip->i_iolock, XFS_IOLOCK_DEP(lock_flags));
> >
> > + if (lock_flags & XFS_MMAPLOCK_EXCL)
> > + mrupdate_nested(&ip->i_mmaplock, XFS_IOLOCK_DEP(lock_flags));
> > + else if (lock_flags & XFS_MMAPLOCK_SHARED)
> > + mraccess_nested(&ip->i_mmaplock, XFS_IOLOCK_DEP(lock_flags));
> > +
>
> XFS_MMAPLOCK_DEP()?
Good catch.
> > @@ -455,8 +507,12 @@ xfs_lock_two_inodes(
> > int attempts = 0;
> > xfs_log_item_t *lp;
> >
> > - if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL))
> > - ASSERT((lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)) == 0);
> > + if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL)) {
> > + ASSERT(!(lock_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL)));
> > + ASSERT(!(lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)));
> > + } else if (lock_mode & (XFS_MMAPLOCK_SHARED|XFS_MMAPLOCK_EXCL))
> > + ASSERT(!(lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)));
> > +
>
> Should this last branch not also check for iolock flags? If not, how is
> that consistent with the function comment above?
If we hit that else branch, we already know that the lock mode
does not contain IOLOCK flags. :)
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-01-22 21:30 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 22:25 [RFC PATCH 0/6] xfs: truncate vs page fault IO exclusion Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` [RFC PATCH 1/6] xfs: introduce mmap/truncate lock Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-22 13:09 ` Brian Foster
2015-01-22 13:09 ` Brian Foster
2015-01-22 21:30 ` Dave Chinner [this message]
2015-01-22 21:30 ` Dave Chinner
2015-01-07 22:25 ` [RFC PATCH 2/6] xfs: use i_mmaplock on read faults Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` [RFC PATCH 3/6] xfs: use i_mmaplock on write faults Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` [RFC PATCH 4/6] xfs: take i_mmap_lock on extent manipulation operations Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-22 13:23 ` Brian Foster
2015-01-22 13:23 ` Brian Foster
2015-01-22 13:23 ` Brian Foster
2015-01-22 21:32 ` Dave Chinner
2015-01-22 21:32 ` Dave Chinner
2015-01-22 21:32 ` Dave Chinner
2015-01-07 22:25 ` [RFC PATCH 5/6] xfs: xfs_setattr_size no longer races with page faults Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-07 22:25 ` [RFC PATCH 6/6] xfs: lock out page faults from extent swap operations Dave Chinner
2015-01-07 22:25 ` Dave Chinner
2015-01-22 13:41 ` Brian Foster
2015-01-22 13:41 ` Brian Foster
2015-01-08 11:34 ` [RFC PATCH 0/6] xfs: truncate vs page fault IO exclusion Jan Kara
2015-01-08 11:34 ` Jan Kara
2015-01-08 11:34 ` Jan Kara
2015-01-08 12:24 ` Christoph Hellwig
2015-01-08 12:24 ` Christoph Hellwig
2015-01-08 12:24 ` Christoph Hellwig
2015-01-08 21:45 ` Dave Chinner
2015-01-08 21:45 ` Dave Chinner
2015-01-12 17:42 ` Jan Kara
2015-01-12 17:42 ` Jan Kara
2015-01-21 22:26 ` Dave Chinner
2015-01-21 22:26 ` Dave Chinner
2015-01-21 22:26 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150122213014.GA24722@dastard \
--to=david@fromorbit.com \
--cc=bfoster@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.