f2fs: prevent compressed file from being disabled after releasing cblocks
PATCH 1/1 f2fs: prevent compressed file from being disabled after releasing cblocks
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)
fs/f2fs/f2fs.h +2 -0
@@ -3936,6 +3936,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ;if (S_ISREG (inode->i_mode)) { +if (IS_IMMUTABLE (inode)) +return 1 ;if (get_dirty_pages (inode))return 1 ;if (fi->i_compr_blocks)
Signature · 1 line
2.28.0.402.g5ffc5be6b7-goog
Chao Yu
maintainerQuoted 17 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)fs/f2fs/f2fs.h +0
-0
fs/f2fs/f2fs.h static inline u64 f2fs_disable_compressed_file(struct inode *inode) · line 3940
Quoted 5 lines
fs/f2fs/f2fs.h +2
-0@@ -3936,6 +3936,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ;if (S_ISREG (inode->i_mode)) { +if (IS_IMMUTABLE (inode)) +return 1 ;
It looks most of callers are from ioctl, should we add immutable check in f2fs ioctl interfaces if necessary? or I missed existed check.
Thanks,
Quoted 4 lines
fs/f2fs/f2fs.h +0
-0if (get_dirty_pages (inode))return 1 ;if (fi->i_compr_blocks)
Do you have any reason not to put this check here?
If we do this check outside of here, we definitely make a mistake sooner or later.
2020년 8월 30일 (일) 오후 12:24, Chao Yu <[email protected]>님이 작성:
Quoted 28 lines · Daeho Jeong
Quoted 17 lines
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)fs/f2fs/f2fs.h +0
-0fs/f2fs/f2fs.h static inline u64 f2fs_disable_compressed_file(struct inode *inode) · line 3940
Quoted 5 lines
fs/f2fs/f2fs.h +2
-0@@ -3936,6 +3936,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ;if (S_ISREG (inode->i_mode)) { +if (IS_IMMUTABLE (inode)) +return 1 ;It looks most of callers are from ioctl, should we add immutable check in f2fs ioctl interfaces if necessary? or I missed existed check.
Quoted 6 lines
Thanks,
Quoted 4 lines
fs/f2fs/f2fs.h +0
-0if (get_dirty_pages (inode))return 1 ;if (fi->i_compr_blocks)
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 1 line · Daeho Jeong
Do you have any reason not to put this check here?
No, the place is okay to me. :)
Quoted 2 lines
If we do this check outside of here, we definitely make a mistake sooner or later.
I just want to see whether we can cover all cases in where we missed to add immutable check condition if necessary.
Thanks,
Quoted 43 lines
2020년 8월 30일 (일) 오후 12:24, Chao Yu <[email protected]>님이 작성:
Quoted 28 lines · Daeho Jeong
Quoted 17 lines
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)fs/f2fs/f2fs.h +0
-0fs/f2fs/f2fs.h static inline u64 f2fs_disable_compressed_file(struct inode *inode) · line 3940
Quoted 5 lines
fs/f2fs/f2fs.h +2
-0@@ -3936,6 +3936,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ;if (S_ISREG (inode->i_mode)) { +if (IS_IMMUTABLE (inode)) +return 1 ;It looks most of callers are from ioctl, should we add immutable check in f2fs ioctl interfaces if necessary? or I missed existed check.
Quoted 6 lines
Thanks,
Quoted 4 lines
fs/f2fs/f2fs.h +0
-0if (get_dirty_pages (inode))return 1 ;if (fi->i_compr_blocks)_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Sorry, I didn't get your point.
So, do you think this patch is ok? And we need to consider that we need more immutable checks for other cases?
Or you want to remove this immutable check from here and add the check to each ioctl functions?
2020년 8월 31일 (월) 오전 10:24, Chao Yu <[email protected]>님이 작성:
Quoted 57 lines · Daeho Jeong
Quoted 1 line
Do you have any reason not to put this check here?
No, the place is okay to me. :)
Quoted 2 lines
If we do this check outside of here, we definitely make a mistake sooner or later.
I just want to see whether we can cover all cases in where we missed to add immutable check condition if necessary.
Thanks,
Quoted 43 lines
2020년 8월 30일 (일) 오후 12:24, Chao Yu <[email protected]>님이 작성:
Quoted 28 lines · Daeho Jeong
Quoted 17 lines
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)fs/f2fs/f2fs.h +0
-0fs/f2fs/f2fs.h static inline u64 f2fs_disable_compressed_file(struct inode *inode) · line 3940
Quoted 5 lines
fs/f2fs/f2fs.h +2
-0@@ -3936,6 +3936,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ;if (S_ISREG (inode->i_mode)) { +if (IS_IMMUTABLE (inode)) +return 1 ;It looks most of callers are from ioctl, should we add immutable check in f2fs ioctl interfaces if necessary? or I missed existed check.
Quoted 6 lines
Thanks,
Quoted 4 lines
fs/f2fs/f2fs.h +0
-0if (get_dirty_pages (inode))return 1 ;if (fi->i_compr_blocks)_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 4 lines · Daeho Jeong
Sorry, I didn't get your point.
So, do you think this patch is ok? And we need to consider that we need more immutable checks for other cases?
Yes, this patch looks good to me.
But, IMO, we should discuss about whether we need to add more immutable checks for other ioctl cases.
- open(O_RDWR)
- ioctl(FS_IOC_SETFLAGS, F2FS_COMPR_FL)
- write()
- ioctl(RELEASE_COMPRESS_BLOCKS) -- inode is immutable now
- ioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL) -- Should we allow to update immutable inode? as we know, normally, immutable inode should deny open(O_WRONLY or O_RDWR) and later update.
Thanks,
Quoted 62 lines
Or you want to remove this immutable check from here and add the check to each ioctl functions? >
2020년 8월 31일 (월) 오전 10:24, Chao Yu <[email protected]>님이 작성:Quoted 6 lines · Daeho Jeong
Quoted 1 line
Do you have any reason not to put this check here?
No, the place is okay to me. :)
Quoted 51 lines
Quoted 2 lines
If we do this check outside of here, we definitely make a mistake sooner or later.
I just want to see whether we can cover all cases in where we missed to add immutable check condition if necessary.
Thanks,
Quoted 43 lines
2020년 8월 30일 (일) 오후 12:24, Chao Yu <[email protected]>님이 작성:
Quoted 28 lines · Daeho Jeong
Quoted 17 lines
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
Signed-off-by Daeho Jeong <[email protected]>--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)fs/f2fs/f2fs.h +0
-0fs/f2fs/f2fs.h static inline u64 f2fs_disable_compressed_file(struct inode *inode) · line 3940
Quoted 5 lines
fs/f2fs/f2fs.h +2
-0@@ -3936,6 +3936,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ;if (S_ISREG (inode->i_mode)) { +if (IS_IMMUTABLE (inode)) +return 1 ;It looks most of callers are from ioctl, should we add immutable check in f2fs ioctl interfaces if necessary? or I missed existed check.
Quoted 6 lines
Thanks,
Quoted 4 lines
fs/f2fs/f2fs.h +0
-0if (get_dirty_pages (inode))return 1 ;if (fi->i_compr_blocks)_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel.
Quoted 7 lines
-
open(O_RDWR)
-ioctl(FS_IOC_SETFLAGS, F2FS_COMPR_FL)
-write()
-ioctl(RELEASE_COMPRESS_BLOCKS)-- inode is immutable now
-ioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL)-- Should we allow to update immutable inode? as we know, normally, immutable inode should denyopen(O_WRONLY or O_RDWR)and later update.
For this case, with this patch we'll return -EINVAL for ioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL).
I thought RESERVE_COMPRESS_BLOCKS ioctl is always required to get the file to normal mode after RELEASE_COMPRESS_BLOCKS is called.
Quoted 8 lines · Daeho Jeong
Quoted 7 lines
-
open(O_RDWR)
-ioctl(FS_IOC_SETFLAGS, F2FS_COMPR_FL)
-write()
-ioctl(RELEASE_COMPRESS_BLOCKS)-- inode is immutable now
-ioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL)-- Should we allow to update immutable inode? as we know, normally, immutable inode should denyopen(O_WRONLY or O_RDWR)and later update.
Quoted 4 lines
For this case, with this patch we'll return
-EINVALforioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL).
I thoughtRESERVE_COMPRESS_BLOCKSioctl is always required to get the file to normal mode afterRELEASE_COMPRESS_BLOCKSis called.
That's an example, after compressed block release, shouldn't we disallow other ioctl interface which updates immutable inode?
Quoted 2 lines
.
I think this patch is enough for now.
If you have anything else we should take care, please let me know~
2020년 8월 31일 (월) 오후 3:08, Chao Yu <[email protected]>님이 작성:
Quoted 20 lines · Daeho Jeong
Quoted 8 lines
Quoted 7 lines
-
open(O_RDWR)
-ioctl(FS_IOC_SETFLAGS, F2FS_COMPR_FL)
-write()
-ioctl(RELEASE_COMPRESS_BLOCKS)-- inode is immutable now
-ioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL)-- Should we allow to update immutable inode? as we know, normally, immutable inode should denyopen(O_WRONLY or O_RDWR)and later update.Quoted 4 lines
For this case, with this patch we'll return
-EINVALforioctl(FS_IOC_SETFLAGS, ~F2FS_COMPR_FL).
I thoughtRESERVE_COMPRESS_BLOCKSioctl is always required to get the file to normal mode afterRELEASE_COMPRESS_BLOCKSis called.That's an example, after compressed block release, shouldn't we disallow other ioctl interface which updates immutable inode?
Quoted 2 lines
.
Quoted 8 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
After releasing cblocks, the compressed file can be accidentally disabled in compression mode, since it has zero cblocks. As we are using IMMUTABLE flag to present released cblocks state, we can add IMMUTABLE state check when considering the compressed file disabling.
Signed-off-by Daeho Jeong <[email protected]>
Thanks,