Skip to content

Commit a28f239

Browse files
dhowellstorvalds
authored andcommitted
afs: Fix race in commit bulk status fetch
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: 39db981 ("afs: Fix application of the results of a inline bulk status fetch") Signed-off-by: David Howells <[email protected]> Reviewed-by: Marc Dionne <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent eb70e26 commit a28f239

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/afs/dir.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,12 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
803803
continue;
804804

805805
if (cookie->inodes[i]) {
806-
afs_vnode_commit_status(&fc, AFS_FS_I(cookie->inodes[i]),
806+
struct afs_vnode *iv = AFS_FS_I(cookie->inodes[i]);
807+
808+
if (test_bit(AFS_VNODE_UNSET, &iv->flags))
809+
continue;
810+
811+
afs_vnode_commit_status(&fc, iv,
807812
scb->cb_break, NULL, scb);
808813
continue;
809814
}

0 commit comments

Comments
 (0)