]> git.baikalelectronics.ru Git - kernel.git/commit
GFS2: Fix inode deallocation race
authorSteven Whitehouse <swhiteho@redhat.com>
Wed, 3 Nov 2010 20:01:07 +0000 (20:01 +0000)
committerSteven Whitehouse <swhiteho@redhat.com>
Mon, 15 Nov 2010 12:44:42 +0000 (12:44 +0000)
commit3bb190b3f0d8f659d747e679819971b40b7d36b3
tree9596bb669a68b04eebc40864c3b3fd71d3d1e273
parent007194d0a640dc0a9dfc86649e15108d9502004a
GFS2: Fix inode deallocation race

This area of the code has always been a bit delicate due to the
subtleties of lock ordering. The problem is that for "normal"
alloc/dealloc, we always grab the inode locks first and the rgrp lock
later.

In order to ensure no races in looking up the unlinked, but still
allocated inodes, we need to hold the rgrp lock when we do the lookup,
which means that we can't take the inode glock.

The solution is to borrow the technique already used by NFS to solve
what is essentially the same problem (given an inode number, look up
the inode carefully, checking that it really is in the expected
state).

We cannot do that directly from the allocation code (lock ordering
again) so we give the job to the pre-existing delete workqueue and
carry on with the allocation as normal.

If we find there is no space, we do a journal flush (required anyway
if space from a deallocation is to be released) which should block
against the pending deallocations, so we should always get the space
back.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/export.c
fs/gfs2/glock.c
fs/gfs2/inode.c
fs/gfs2/inode.h
fs/gfs2/rgrp.c