From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: xfs <linux-xfs@vger.kernel.org>
Subject: [RFC PATCH] xfs: fix cow_seq locking behavior
Date: Sun, 29 Jul 2018 22:55:39 -0700 [thread overview]
Message-ID: <20180730055539.GT30972@magnolia> (raw)
From: Darrick J. Wong <darrick.wong@oracle.com>
In Christoph Hellwig's patch "xfs: avoid COW fork extent lookups in
writeback if the fork didn't change" (which has not yet graduated to
for-next), we sample the COW fork sequence number without taking the
ilock. This is a little strange, since in general we always take it
before accessing anything in a block mapping. I think we get lucky in
that the unlocking during actual cow fork changes will erect the
necessary memory barriers (on x86 anyway) but let's not play fast and
loose with breaking everyone else's model of how locking works.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/xfs_aops.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index aff9d44fa338..2e178ef89a15 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -338,16 +338,21 @@ xfs_map_blocks(
* COW one, or the COW fork hasn't changed from the last time we looked
* at it.
*/
+ xfs_ilock(ip, XFS_ILOCK_SHARED);
imap_valid = offset_fsb >= wpc->imap.br_startoff &&
offset_fsb < wpc->imap.br_startoff + wpc->imap.br_blockcount;
if (imap_valid &&
(!xfs_inode_has_cow_data(ip) ||
wpc->io_type == XFS_IO_COW ||
- wpc->cow_seq == ip->i_cowfp->if_seq))
+ wpc->cow_seq == ip->i_cowfp->if_seq)) {
+ xfs_iunlock(ip, XFS_ILOCK_SHARED);
return 0;
+ }
- if (XFS_FORCED_SHUTDOWN(mp))
+ if (XFS_FORCED_SHUTDOWN(mp)) {
+ xfs_iunlock(ip, XFS_ILOCK_SHARED);
return -EIO;
+ }
/*
* If we don't have a valid map, now it's time to get a new one for this
@@ -355,7 +360,6 @@ xfs_map_blocks(
* into real extents. If we return without a valid map, it means we
* landed in a hole and we skip the block.
*/
- xfs_ilock(ip, XFS_ILOCK_SHARED);
ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
(ip->i_df.if_flags & XFS_IFEXTENTS));
ASSERT(offset <= mp->m_super->s_maxbytes);
next reply other threads:[~2018-07-30 7:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 5:55 Darrick J. Wong [this message]
2018-07-30 8:14 ` [RFC PATCH] xfs: fix cow_seq locking behavior Christoph Hellwig
2018-07-30 15:52 ` Darrick J. Wong
2018-07-30 16:22 ` Christoph Hellwig
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=20180730055539.GT30972@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).