Commit 3d36e57
Andreas Gruenbacher
gfs2: gfs2_create_inode rework
When gfs2_lookup_by_inum() calls gfs2_inode_lookup() for an uncached
inode, gfs2_inode_lookup() will place a new tentative inode into the
inode cache before verifying that there is a valid inode at the given
address. This can race with gfs2_create_inode() which doesn't check for
duplicates inodes. gfs2_create_inode() will try to assign the new inode
to the corresponding inode glock, and glock_set_object() will complain
that the glock is still in use by gfs2_inode_lookup's tentative inode.
We noticed this bug after adding commit 486408d ("gfs2: Cancel
remote delete work asynchronously") which allowed delete_work_func() to
race with gfs2_create_inode(), but the same race exists for
open-by-handle.
Fix that by switching from insert_inode_hash() to
insert_inode_locked4(), which does check for duplicate inodes. We know
we've just managed to to allocate the new inode, so an inode tentatively
created by gfs2_inode_lookup() will eventually go away and
insert_inode_locked4() will always succeed.
In addition, don't flush the inode glock work anymore (this can now only
make things worse) and clean up glock_{set,clear}_object for the inode
glock somewhat.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>1 parent 5f6e13b commit 3d36e57
1 file changed
Lines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
710 | | - | |
711 | 710 | | |
712 | 711 | | |
713 | 712 | | |
714 | 713 | | |
715 | 714 | | |
716 | 715 | | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
717 | 719 | | |
718 | 720 | | |
719 | 721 | | |
720 | 722 | | |
721 | | - | |
722 | 723 | | |
723 | 724 | | |
724 | 725 | | |
| |||
734 | 735 | | |
735 | 736 | | |
736 | 737 | | |
| 738 | + | |
737 | 739 | | |
738 | 740 | | |
739 | | - | |
740 | 741 | | |
741 | 742 | | |
742 | 743 | | |
| |||
778 | 779 | | |
779 | 780 | | |
780 | 781 | | |
| 782 | + | |
781 | 783 | | |
782 | 784 | | |
783 | 785 | | |
| 786 | + | |
784 | 787 | | |
785 | 788 | | |
786 | 789 | | |
787 | | - | |
788 | 790 | | |
789 | 791 | | |
790 | 792 | | |
791 | | - | |
792 | 793 | | |
793 | 794 | | |
794 | 795 | | |
| |||
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
809 | | - | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
810 | 814 | | |
811 | 815 | | |
812 | 816 | | |
| |||
0 commit comments