All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] afs: Fix race in commit bulk status fetch
@ 2019-11-14 18:41 David Howells
  2019-11-15 18:51 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2019-11-14 18:41 UTC (permalink / raw)
  To: torvalds; +Cc: dhowells, marc.dionne, linux-afs, linux-fsdevel, linux-kernel

When a lookup is done, the afs filesystem will perform a bulk status-fetch
operation on the requested vnode (file) plus the next 49 other vnodes from
the directory list (in AFS, directory contents are downloaded as blobs and
parsed locally).  When the results are received, it will speculatively
populate the inode cache from the extra data.

However, if the lookup races with another lookup on the same directory, but
for a different file - one that's in the 49 extra fetches, then if the bulk
status-fetch operation finishes first, it will try and update the inode
from the other lookup.

If this other inode is still in the throes of being created, however, this
will cause an assertion failure in afs_apply_status():

	BUG_ON(test_bit(AFS_VNODE_UNSET, &vnode->flags));

on or about fs/afs/inode.c:175 because it expects data to be there already
that it can compare to.

Fix this by skipping the update if the inode is being created as the
creator will presumably set up the inode with the same information.

Fixes: 39db9815da48 ("afs: Fix application of the results of a inline bulk status fetch")
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
---

 fs/afs/dir.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index cc12772d0a4d..497f979018c2 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -803,7 +803,12 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
 			continue;
 
 		if (cookie->inodes[i]) {
-			afs_vnode_commit_status(&fc, AFS_FS_I(cookie->inodes[i]),
+			struct afs_vnode *iv = AFS_FS_I(cookie->inodes[i]);
+
+			if (test_bit(AFS_VNODE_UNSET, &iv->flags))
+				continue;
+
+			afs_vnode_commit_status(&fc, iv,
 						scb->cb_break, NULL, scb);
 			continue;
 		}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] afs: Fix race in commit bulk status fetch
  2019-11-14 18:41 [PATCH] afs: Fix race in commit bulk status fetch David Howells
@ 2019-11-15 18:51 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2019-11-15 18:51 UTC (permalink / raw)
  To: David Howells
  Cc: Marc Dionne, linux-afs, linux-fsdevel, Linux Kernel Mailing List

On Thu, Nov 14, 2019 at 10:41 AM David Howells <dhowells@redhat.com> wrote:
>
> Fix this by skipping the update if the inode is being created as the
> creator will presumably set up the inode with the same information.

Applied,

          Linus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-15 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 18:41 [PATCH] afs: Fix race in commit bulk status fetch David Howells
2019-11-15 18:51 ` Linus Torvalds

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.