[Devel] [PATCH rh8] ext4/balloon: Use proper O_ mode flags in balloon opening code

Konstantin Khorenko khorenko at virtuozzo.com
Fri May 21 17:32:29 MSK 2021


alloc_file() expects O_* mode flags, so provide them, not
internal FMODE_* ones.

Fixes: bee340a206d7 ("ext4: Provide a balloon nipple for management")
https://jira.sw.ru/browse/PSBM-129392

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 fs/ext4/ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index ecdc15881007..6d5b5e2eda91 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -775,11 +775,11 @@ static int ext4_open_balloon(struct super_block *sb, struct vfsmount *mnt)
 	path.mnt = mntget(mnt);
 	err = mnt_want_write(path.mnt);
 	if (err)
-		mode = FMODE_READ;
+		mode = O_RDONLY;
 	else
-		mode = FMODE_READ | FMODE_WRITE;
+		mode = O_RDWR;
 	filp = alloc_file(&path, mode, &ext4_file_operations);
-	if (mode & FMODE_WRITE)
+	if (filp->f_mode & FMODE_WRITE)
 		mnt_drop_write(path.mnt);
 	if (IS_ERR(filp)) {
 		err = PTR_ERR(filp);
-- 
2.28.0



More information about the Devel mailing list