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>
This commit is contained in:
@@ -117,14 +117,14 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
|
||||
if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode)))
|
||||
return -E2BIG;
|
||||
|
||||
ret = gfs2_qa_alloc(ip);
|
||||
ret = gfs2_qa_get(ip);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!gfs2_glock_is_locked_by_me(ip->i_gl)) {
|
||||
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out;
|
||||
need_unlock = true;
|
||||
}
|
||||
|
||||
@@ -144,5 +144,7 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
|
||||
unlock:
|
||||
if (need_unlock)
|
||||
gfs2_glock_dq_uninit(&gh);
|
||||
out:
|
||||
gfs2_qa_put(ip);
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user