gfs2: Change inode qa_data to allow multiple users
authorBob Peterson <rpeterso@redhat.com>
Thu, 27 Feb 2020 18:47:53 +0000 (12:47 -0600)
committerBob Peterson <rpeterso@redhat.com>
Fri, 27 Mar 2020 19:08:04 +0000 (14:08 -0500)
commit2fba46a04c383f91e7fe837d43bf1ab33ce32b6a
tree3137e791a08473e956a2a6ac477cb20b8677081b
parentd580712a37272182cb63002878f3bb7bcebbb8bd
gfs2: Change inode qa_data to allow multiple users

Before this patch, multiple users called gfs2_qa_alloc which allocated
a qadata structure to the inode, if quotas are turned on. Later, in
file close or evict, the structure was deleted with gfs2_qa_delete.
But there can be several competing processes who need access to the
structure. There were races between file close (release) and the others.
Thus, a release could delete the structure out from under a process
that relied upon its existence. For example, chown.

This patch changes the management of the qadata structures to be
a get/put scheme. Function gfs2_qa_alloc has been changed to gfs2_qa_get
and if the structure is allocated, the count essentially starts out at
1. Function gfs2_qa_delete has been renamed to gfs2_qa_put, and the
last guy to decrement the count to 0 frees the memory.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/acl.c
fs/gfs2/bmap.c
fs/gfs2/file.c
fs/gfs2/incore.h
fs/gfs2/inode.c
fs/gfs2/quota.c
fs/gfs2/quota.h
fs/gfs2/rgrp.c
fs/gfs2/super.c
fs/gfs2/xattr.c