[PATCH] gfs2: Fix the inverted barrier mount option

From: Yifan Feng

Date: Tue Dec 01 2026 - 19:39:40 EST


For an option that can be negated, result.boolean is true when the
option is given without "no". So since the conversion to fs_context
"barrier" sets ar_nobarrier and "nobarrier" clears it. A mount with
-o barrier sends no cache flushes to the disk, and -o nobarrier has no
effect:

# mount -o barrier /dev/vda /mnt
# grep /mnt /proc/mounts
/dev/vda /mnt gfs2 rw,relatime,localflocks,nobarrier,rgrplvb 0 0

Use result.negated.

Fixes: 1f52aa08d12f ("gfs2: Convert gfs2 to fs_context")
Signed-off-by: Yifan Feng <evanfengff@xxxxxxxxx>
---
Tested in QEMU: with -o barrier the disk gets 0 flush requests for 20 fsync() calls before the patch and 80 with it; -o nobarrier and the two remounts are the reverse.
Found and written with the help of an AI coding assistant.

fs/gfs2/ops_fstype.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 6ec47376aecf..95ac305e99ab 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1526,7 +1526,7 @@ static int gfs2_parse_param(struct fs_context *fc, struct fs_parameter *param)
args->ar_errors = result.uint_32;
break;
case Opt_barrier:
- args->ar_nobarrier = result.boolean;
+ args->ar_nobarrier = result.negated;
break;
case Opt_rgrplvb:
args->ar_rgrplvb = result.boolean;

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.39.3 (Apple Git-146)