]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
gfs2: Check for active reservation in gfs2_release
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 21 Oct 2020 14:37:54 +0000 (16:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 19:00:54 +0000 (21:00 +0200)
[ Upstream commit 0ec9b9ea4f83303bfd8f052a3d8b2bd179b002e1 ]

In gfs2_release, check if the inode has an active reservation to avoid
unnecessary lock taking.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/gfs2/file.c

index cfd9d03f604fee4a79cd6ad5a0bd01c8de6f6a78..59318b1eaa6025b37c61eecf8d68aab640785116 100644 (file)
@@ -716,10 +716,10 @@ static int gfs2_release(struct inode *inode, struct file *file)
        kfree(file->private_data);
        file->private_data = NULL;
 
-       if (file->f_mode & FMODE_WRITE) {
+       if (gfs2_rs_active(&ip->i_res))
                gfs2_rs_delete(ip, &inode->i_writecount);
+       if (file->f_mode & FMODE_WRITE)
                gfs2_qa_put(ip);
-       }
        return 0;
 }