]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
GFS2: Fix allocation error bug with recursive rgrp glocking
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 31 May 2018 12:20:55 +0000 (07:20 -0500)
committerBob Peterson <rpeterso@redhat.com>
Mon, 4 Jun 2018 12:33:17 +0000 (07:33 -0500)
Before this patch function gfs2_write_begin, upon discovering an
error, called gfs2_trim_blocks while the rgrp glock was still held.
That's because gfs2_inplace_release is not called until later.
This patch reorganizes the logic a bit so gfs2_inplace_release
is called to release the lock prior to the call to gfs2_trim_blocks,
thus preventing the glock recursion.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/aops.c

index f58716567972ec121762db4ce94a4da4245b6a8d..66e7172e013409370ed4abfd3a41cd7d43ac340f 100644 (file)
@@ -747,18 +747,21 @@ out:
        put_page(page);
 
        gfs2_trans_end(sdp);
-       if (pos + len > ip->i_inode.i_size)
-               gfs2_trim_blocks(&ip->i_inode);
-       goto out_trans_fail;
+       if (alloc_required) {
+               gfs2_inplace_release(ip);
+               if (pos + len > ip->i_inode.i_size)
+                       gfs2_trim_blocks(&ip->i_inode);
+       }
+       goto out_qunlock;
 
 out_endtrans:
        gfs2_trans_end(sdp);
 out_trans_fail:
-       if (alloc_required) {
+       if (alloc_required)
                gfs2_inplace_release(ip);
 out_qunlock:
+       if (alloc_required)
                gfs2_quota_unlock(ip);
-       }
 out_unlock:
        if (&ip->i_inode == sdp->sd_rindex) {
                gfs2_glock_dq(&m_ip->i_gh);