Btrfs: setup inode location during btrfs_init_inode_locked
authorChris Mason <clm@fb.com>
Fri, 10 Jan 2014 01:28:00 +0000 (17:28 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Feb 2014 19:34:11 +0000 (11:34 -0800)
commit5d4d57d2f5cd27b27505d24766fa0f0952e2a19b
tree27a308bbce5a70e3e591671d3930f3f7324d1895
parentfb0f7df29d50332f5b79c84e954d30acf7961884
Btrfs: setup inode location during btrfs_init_inode_locked

commit 90d3e592e99b8e374ead2b45148abf506493a959 upstream.

We have a race during inode init because the BTRFS_I(inode)->location is setup
after the inode hash table lock is dropped.  btrfs_find_actor uses the location
field, so our search might not find an existing inode in the hash table if we
race with the inode init code.

This commit changes things to setup the location field sooner.  Also the find actor now
uses only the location objectid to match inodes.  For inode hashing, we just
need a unique and stable test, it doesn't have to reflect the inode numbers we
show to userland.

Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/inode.c