GFS2: Check rs_free with rd_rsspin protection
authorBob Peterson <rpeterso@redhat.com>
Wed, 6 Jul 2016 15:36:43 +0000 (10:36 -0500)
committerBob Peterson <rpeterso@redhat.com>
Tue, 12 Jul 2016 16:48:22 +0000 (11:48 -0500)
commit44f52122a22004de9c3bae288bbc6dff3624fe9c
treedf0c36e3d387d2cd46b74c0f1228bc3da6fcad4e
parentfd4c5748b8d3f7420e8932ed0bde3d53cc8acc9d
GFS2: Check rs_free with rd_rsspin protection

For the last process to close a file opened for write, function
gfs2_rsqa_delete was deleting the file's inode's block reservation
out of the rgrp reservations tree. Then it was checking to make sure
rs_free was 0, but it was performing the check outside the protection
of rd_rsspin spin_lock. The rd_rsspin spin_lock protection is needed
to prevent a race between the process freeing the reservation and
another who is allocating a new set of blocks inside the same rgrp
for the same inode, thus changing its value.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/rgrp.c