linux-stable/fs/gfs2
Bob Peterson 4134396f99 gfs2: Fix gfs2_release for non-writers regression
commit d3add1a951 upstream.

When a file is opened for writing, the vfs code (do_dentry_open)
calls get_write_access for the inode, thus incrementing the inode's write
count. That writer normally then creates a multi-block reservation for
the inode (i_res) that can be re-used by other writers, which speeds up
writes for applications that stupidly loop on open/write/close.
When the writes are all done, the multi-block reservation should be
deleted when the file is closed by the last "writer."

Commit 0ec9b9ea4f broke that concept when it moved the call to
gfs2_rs_delete before the check for FMODE_WRITE.  Non-writers have no
business removing the multi-block reservations of writers. In fact, if
someone opens and closes the file for RO while a writer has a
multi-block reservation, the RO closer will delete the reservation
midway through the write, and this results in:

kernel BUG at fs/gfs2/rgrp.c:677! (or thereabouts) which is:
BUG_ON(rs->rs_requested); from function gfs2_rs_deltree.

This patch moves the check back inside the check for FMODE_WRITE.

Fixes: 0ec9b9ea4f ("gfs2: Check for active reservation in gfs2_release")
Cc: stable@vger.kernel.org # v5.12+
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-16 12:56:18 +01:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
aops.c gfs2: Don't release and reacquire local statfs bh 2021-08-20 09:03:46 -05:00
aops.h
bmap.c gfs2: Fix length of holes reported at end-of-file 2021-12-08 09:04:37 +01:00
bmap.h gfs2: Clean up gfs2_unstuff_dinode 2021-06-29 10:56:51 +02:00
dentry.c
dir.c gfs2: Clean up gfs2_unstuff_dinode 2021-06-29 10:56:51 +02:00
dir.h
export.c
file.c gfs2: Fix gfs2_release for non-writers regression 2022-02-16 12:56:18 +01:00
gfs2.h
glock.c gfs2: Fix glock_hash_walk bugs 2021-11-18 19:16:19 +01:00
glock.h
glops.c gfs2: Delay withdraw from atomic context 2021-08-20 09:03:46 -05:00
glops.h
incore.h gfs2: Eliminate vestigial HIF_FIRST 2021-08-20 09:03:46 -05:00
inode.c gfs2: Switch to may_setattr in gfs2_setattr 2021-08-13 00:41:05 -04:00
inode.h Changes in gfs2: 2021-04-29 10:33:35 -07:00
Kconfig
lock_dlm.c gfs2: Don't call dlm after protocol is unmounted 2021-08-20 09:03:46 -05:00
log.c gfs2: tiny cleanup in gfs2_log_reserve 2021-08-19 12:31:17 -05:00
log.h gfs2: Clean up revokes on normal withdraws 2021-05-20 13:31:37 +02:00
lops.c gfs2: be more verbose replaying invalid rgrp blocks 2021-08-19 12:31:17 -05:00
lops.h gfs2: Clean up revokes on normal withdraws 2021-05-20 13:31:37 +02:00
main.c
Makefile
meta_io.c gfs2: don't stop reads while withdraw in progress 2021-08-20 09:03:46 -05:00
meta_io.h gfs2: Turn gfs2_meta_indirect_buffer into gfs2_meta_buffer 2021-04-03 21:38:12 +02:00
ops_fstype.c gfs2: Mark journal inodes as "don't cache" 2021-08-20 09:03:46 -05:00
quota.c gfs2: Clean up gfs2_unstuff_dinode 2021-06-29 10:56:51 +02:00
quota.h
recovery.c gfs2: Fix fall-through warnings for Clang 2021-04-20 22:38:21 +02:00
recovery.h
rgrp.c gfs2: Fix a number of kernel-doc warnings 2021-04-09 22:14:13 +02:00
rgrp.h
super.c gfs2: release iopen glock early in evict 2021-12-08 09:04:37 +01:00
super.h gfs2: Don't release and reacquire local statfs bh 2021-08-20 09:03:46 -05:00
sys.c gfs2: Add new sysfs file for gfs2 status 2021-04-08 15:07:21 +02:00
sys.h
trace_gfs2.h
trans.c gfs2: fix use-after-free in trans_drain 2021-03-07 17:04:55 +01:00
trans.h
util.c gfs2: Mark journal inodes as "don't cache" 2021-08-20 09:03:46 -05:00
util.h gfs2: don't stop reads while withdraw in progress 2021-08-20 09:03:46 -05:00
xattr.c gfs2: Fix a number of kernel-doc warnings 2021-04-09 22:14:13 +02:00
xattr.h