* [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks @ 2020-08-28 5:46 Daeho Jeong 2020-08-30 3:23 ` Chao Yu 2020-08-31 6:22 ` Chao Yu 0 siblings, 2 replies; 10+ messages in thread From: Daeho Jeong @ 2020-08-28 5:46 UTC (permalink / raw) To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong From: Daeho Jeong <daehojeong@google.com> 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 <daehojeong@google.com> --- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 02811ce15059..14d30740ba03 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -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) -- 2.28.0.402.g5ffc5be6b7-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-28 5:46 [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks Daeho Jeong @ 2020-08-30 3:23 ` Chao Yu 2020-08-30 23:42 ` Daeho Jeong 2020-08-31 6:22 ` Chao Yu 1 sibling, 1 reply; 10+ messages in thread From: Chao Yu @ 2020-08-30 3:23 UTC (permalink / raw) To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong On 2020-8-28 13:46, Daeho Jeong wrote: > From: Daeho Jeong <daehojeong@google.com> > > 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 <daehojeong@google.com> > --- > fs/f2fs/f2fs.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 02811ce15059..14d30740ba03 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -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, > if (get_dirty_pages(inode)) > return 1; > if (fi->i_compr_blocks) > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-30 3:23 ` Chao Yu @ 2020-08-30 23:42 ` Daeho Jeong 2020-08-31 1:24 ` Chao Yu 0 siblings, 1 reply; 10+ messages in thread From: Daeho Jeong @ 2020-08-30 23:42 UTC (permalink / raw) To: Chao Yu; +Cc: Daeho Jeong, kernel-team, linux-kernel, linux-f2fs-devel 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 <chao@kernel.org>님이 작성: > > On 2020-8-28 13:46, Daeho Jeong wrote: > > From: Daeho Jeong <daehojeong@google.com> > > > > 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 <daehojeong@google.com> > > --- > > fs/f2fs/f2fs.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > > index 02811ce15059..14d30740ba03 100644 > > --- a/fs/f2fs/f2fs.h > > +++ b/fs/f2fs/f2fs.h > > @@ -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, > > > if (get_dirty_pages(inode)) > > return 1; > > if (fi->i_compr_blocks) > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-30 23:42 ` Daeho Jeong @ 2020-08-31 1:24 ` Chao Yu 2020-08-31 1:44 ` Daeho Jeong 0 siblings, 1 reply; 10+ messages in thread From: Chao Yu @ 2020-08-31 1:24 UTC (permalink / raw) To: Daeho Jeong, Chao Yu Cc: linux-f2fs-devel, kernel-team, Daeho Jeong, linux-kernel On 2020/8/31 7:42, Daeho Jeong wrote: > Do you have any reason not to put this check here? No, the place is okay to me. :) > 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, > > 2020년 8월 30일 (일) 오후 12:24, Chao Yu <chao@kernel.org>님이 작성: >> >> On 2020-8-28 13:46, Daeho Jeong wrote: >>> From: Daeho Jeong <daehojeong@google.com> >>> >>> 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 <daehojeong@google.com> >>> --- >>> fs/f2fs/f2fs.h | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >>> index 02811ce15059..14d30740ba03 100644 >>> --- a/fs/f2fs/f2fs.h >>> +++ b/fs/f2fs/f2fs.h >>> @@ -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, >> >>> if (get_dirty_pages(inode)) >>> return 1; >>> if (fi->i_compr_blocks) >>> > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-31 1:24 ` Chao Yu @ 2020-08-31 1:44 ` Daeho Jeong 2020-08-31 2:31 ` Chao Yu 0 siblings, 1 reply; 10+ messages in thread From: Daeho Jeong @ 2020-08-31 1:44 UTC (permalink / raw) To: Chao Yu; +Cc: kernel-team, Daeho Jeong, linux-f2fs-devel, linux-kernel 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 <yuchao0@huawei.com>님이 작성: > > On 2020/8/31 7:42, Daeho Jeong wrote: > > Do you have any reason not to put this check here? > > No, the place is okay to me. :) > > > 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, > > > > > 2020년 8월 30일 (일) 오후 12:24, Chao Yu <chao@kernel.org>님이 작성: > >> > >> On 2020-8-28 13:46, Daeho Jeong wrote: > >>> From: Daeho Jeong <daehojeong@google.com> > >>> > >>> 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 <daehojeong@google.com> > >>> --- > >>> fs/f2fs/f2fs.h | 2 ++ > >>> 1 file changed, 2 insertions(+) > >>> > >>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > >>> index 02811ce15059..14d30740ba03 100644 > >>> --- a/fs/f2fs/f2fs.h > >>> +++ b/fs/f2fs/f2fs.h > >>> @@ -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, > >> > >>> if (get_dirty_pages(inode)) > >>> return 1; > >>> if (fi->i_compr_blocks) > >>> > > > > > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-31 1:44 ` Daeho Jeong @ 2020-08-31 2:31 ` Chao Yu 2020-08-31 3:55 ` Daeho Jeong 0 siblings, 1 reply; 10+ messages in thread From: Chao Yu @ 2020-08-31 2:31 UTC (permalink / raw) To: Daeho Jeong; +Cc: kernel-team, Daeho Jeong, linux-f2fs-devel, linux-kernel On 2020/8/31 9:44, Daeho Jeong wrote: > 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, > 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 <yuchao0@huawei.com>님이 작성: >> >> On 2020/8/31 7:42, Daeho Jeong wrote: >>> Do you have any reason not to put this check here? >> >> No, the place is okay to me. :) >> >>> 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, >> >>> >>> 2020년 8월 30일 (일) 오후 12:24, Chao Yu <chao@kernel.org>님이 작성: >>>> >>>> On 2020-8-28 13:46, Daeho Jeong wrote: >>>>> From: Daeho Jeong <daehojeong@google.com> >>>>> >>>>> 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 <daehojeong@google.com> >>>>> --- >>>>> fs/f2fs/f2fs.h | 2 ++ >>>>> 1 file changed, 2 insertions(+) >>>>> >>>>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >>>>> index 02811ce15059..14d30740ba03 100644 >>>>> --- a/fs/f2fs/f2fs.h >>>>> +++ b/fs/f2fs/f2fs.h >>>>> @@ -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, >>>> >>>>> if (get_dirty_pages(inode)) >>>>> return 1; >>>>> if (fi->i_compr_blocks) >>>>> >>> >>> >>> _______________________________________________ >>> Linux-f2fs-devel mailing list >>> Linux-f2fs-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel >>> > . > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-31 2:31 ` Chao Yu @ 2020-08-31 3:55 ` Daeho Jeong 2020-08-31 6:06 ` Chao Yu 0 siblings, 1 reply; 10+ messages in thread From: Daeho Jeong @ 2020-08-31 3:55 UTC (permalink / raw) To: Chao Yu; +Cc: kernel-team, Daeho Jeong, linux-f2fs-devel, linux-kernel > - 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. > 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. _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-31 3:55 ` Daeho Jeong @ 2020-08-31 6:06 ` Chao Yu 2020-08-31 6:15 ` Daeho Jeong 0 siblings, 1 reply; 10+ messages in thread From: Chao Yu @ 2020-08-31 6:06 UTC (permalink / raw) To: Daeho Jeong; +Cc: kernel-team, Daeho Jeong, linux-f2fs-devel, linux-kernel On 2020/8/31 11:55, Daeho Jeong wrote: >> - 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. >> > > 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. That's an example, after compressed block release, shouldn't we disallow other ioctl interface which updates immutable inode? > . > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-31 6:06 ` Chao Yu @ 2020-08-31 6:15 ` Daeho Jeong 0 siblings, 0 replies; 10+ messages in thread From: Daeho Jeong @ 2020-08-31 6:15 UTC (permalink / raw) To: Chao Yu; +Cc: kernel-team, Daeho Jeong, linux-f2fs-devel, linux-kernel 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 <yuchao0@huawei.com>님이 작성: > > On 2020/8/31 11:55, Daeho Jeong wrote: > >> - 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. > >> > > > > 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. > > That's an example, after compressed block release, shouldn't we disallow other ioctl > interface which updates immutable inode? > > > . > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks 2020-08-28 5:46 [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks Daeho Jeong 2020-08-30 3:23 ` Chao Yu @ 2020-08-31 6:22 ` Chao Yu 1 sibling, 0 replies; 10+ messages in thread From: Chao Yu @ 2020-08-31 6:22 UTC (permalink / raw) To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong On 2020/8/28 13:46, Daeho Jeong wrote: > From: Daeho Jeong <daehojeong@google.com> > > 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 <daehojeong@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Thanks, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-08-31 6:23 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-28 5:46 [f2fs-dev] [PATCH] f2fs: prevent compressed file from being disabled after releasing cblocks Daeho Jeong 2020-08-30 3:23 ` Chao Yu 2020-08-30 23:42 ` Daeho Jeong 2020-08-31 1:24 ` Chao Yu 2020-08-31 1:44 ` Daeho Jeong 2020-08-31 2:31 ` Chao Yu 2020-08-31 3:55 ` Daeho Jeong 2020-08-31 6:06 ` Chao Yu 2020-08-31 6:15 ` Daeho Jeong 2020-08-31 6:22 ` Chao Yu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).