Skip to content

Commit 1744a22

Browse files
dhowellstorvalds
authored andcommitted
afs: Fix mmap
Fix afs_add_open_map() to check that the vnode isn't already on the list when it adds it. It's possible that afs_drop_open_mmap() decremented the cb_nr_mmap counter, but hadn't yet got into the locked section to remove it. Also vnode->cb_mmap_link should be initialised, so fix that too. Fixes: 6e0e99d ("afs: Fix mmap coherency vs 3rd-party changes") Reported-by: [email protected] Suggested-by: Marc Dionne <[email protected]> Signed-off-by: David Howells <[email protected]> Tested-by: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ # v1 Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2b14864 commit 1744a22

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

fs/afs/file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,9 @@ static void afs_add_open_mmap(struct afs_vnode *vnode)
514514
if (atomic_inc_return(&vnode->cb_nr_mmap) == 1) {
515515
down_write(&vnode->volume->cell->fs_open_mmaps_lock);
516516

517-
list_add_tail(&vnode->cb_mmap_link,
518-
&vnode->volume->cell->fs_open_mmaps);
517+
if (list_empty(&vnode->cb_mmap_link))
518+
list_add_tail(&vnode->cb_mmap_link,
519+
&vnode->volume->cell->fs_open_mmaps);
519520

520521
up_write(&vnode->volume->cell->fs_open_mmaps_lock);
521522
}

fs/afs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ static void afs_i_init_once(void *_vnode)
667667
INIT_LIST_HEAD(&vnode->pending_locks);
668668
INIT_LIST_HEAD(&vnode->granted_locks);
669669
INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work);
670+
INIT_LIST_HEAD(&vnode->cb_mmap_link);
670671
seqlock_init(&vnode->cb_lock);
671672
}
672673

0 commit comments

Comments
 (0)