From: David Howells <dhowells@redhat.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: dhowells@redhat.com, linux-afs@lists.infradead.org,
linux-ext4@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] vfs: Allow searching of the icache under RCU conditions [ver #2]
Date: Thu, 25 Apr 2019 16:45:27 +0100 [thread overview]
Message-ID: <8105.1556207127@warthog.procyon.org.uk> (raw)
In-Reply-To: <20190425151911.GR2217@ZenIV.linux.org.uk>
Al Viro <viro@zeniv.linux.org.uk> wrote:
> Hmm... Why do these stores to ->i_state need WRITE_ONCE, while an arseload
> of similar in fs/fs-writeback.c does not?
Because what matters in find_inode_rcu() are the I_WILL_FREE and I_FREEING
flags - and there's a gap during iput_final() where neither is set.
if (!drop) {
inode->i_state |= I_WILL_FREE;
spin_unlock(&inode->i_lock);
write_inode_now(inode, 1);
spin_lock(&inode->i_lock);
WARN_ON(inode->i_state & I_NEW);
inode->i_state &= ~I_WILL_FREE;
--->
}
inode->i_state |= I_FREEING;
It's normally covered by i_lock, but it's a problem if anyone looks at the
pair without taking i_lock.
Even flipping the order:
if (!drop) {
inode->i_state |= I_WILL_FREE;
spin_unlock(&inode->i_lock);
write_inode_now(inode, 1);
spin_lock(&inode->i_lock);
WARN_ON(inode->i_state & I_NEW);
inode->i_state |= I_FREEING;
inode->i_state &= ~I_WILL_FREE;
} else {
inode->i_state |= I_FREEING;
}
isn't a guarantee of the order in which the compiler will do things AIUI.
Maybe I've been listening to Paul McKenney too much. So the WRITE_ONCE()
should guarantee that both bits will change atomically.
Note that ocfs2_drop_inode() looks a tad suspicious:
int ocfs2_drop_inode(struct inode *inode)
{
struct ocfs2_inode_info *oi = OCFS2_I(inode);
trace_ocfs2_drop_inode((unsigned long long)oi->ip_blkno,
inode->i_nlink, oi->ip_flags);
assert_spin_locked(&inode->i_lock);
inode->i_state |= I_WILL_FREE;
spin_unlock(&inode->i_lock);
write_inode_now(inode, 1);
spin_lock(&inode->i_lock);
WARN_ON(inode->i_state & I_NEW);
inode->i_state &= ~I_WILL_FREE;
return 1;
}
David
next prev parent reply other threads:[~2019-04-25 15:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 15:01 [PATCH 0/6] vfs: Make icache searchable under RCU [ver #2] David Howells
2019-04-25 15:01 ` [PATCH 1/6] vfs, coda: Fix the lack of locking in FID replacement inode rehashing " David Howells
2019-04-25 15:01 ` [PATCH 2/6] vfs: Change inode_hash_lock to a seqlock " David Howells
2019-04-25 15:02 ` [PATCH 3/6] vfs: Allow searching of the icache under RCU conditions " David Howells
2019-04-25 15:19 ` Al Viro
2019-04-25 15:45 ` David Howells [this message]
2019-04-25 15:02 ` [PATCH 4/6] afs: Use RCU inode cache search for callback resolution " David Howells
2019-04-25 15:02 ` [PATCH 5/6] ext4: Search for an inode to update under the RCU lock if we can " David Howells
2019-04-25 15:02 ` [PATCH 6/6] vfs: Delete find_inode_nowait() " David Howells
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=8105.1556207127@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
--cc=viro@zeniv.linux.org.uk \
/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