linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix wrong segment count
@ 2023-02-10 21:32 Jaegeuk Kim
  2023-02-13  9:41 ` Chao Yu
  2023-02-13 17:59 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
  0 siblings, 2 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2023-02-10 21:32 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 8ee5e5db9287..6003fbaf4b7d 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
 
 static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
 {
-	f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
+	f2fs_bug_on(sbi, segno > MAIN_SEGS(sbi) - 1);
 }
 
 static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
@@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
 
 	/* check segment usage, and check boundary of a given segment number */
 	if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
-					|| segno > TOTAL_SEGS(sbi) - 1)) {
+					|| segno > MAIN_SEGS(sbi) - 1)) {
 		f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
 			 GET_SIT_VBLOCKS(raw_sit), segno);
 		set_sbi_flag(sbi, SBI_NEED_FSCK);
-- 
2.39.1.581.gbfd45094c4-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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix wrong segment count
  2023-02-10 21:32 [f2fs-dev] [PATCH] f2fs: fix wrong segment count Jaegeuk Kim
@ 2023-02-13  9:41 ` Chao Yu
  2023-02-13 17:48   ` Jaegeuk Kim
  2023-02-13 17:59 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
  1 sibling, 1 reply; 6+ messages in thread
From: Chao Yu @ 2023-02-13  9:41 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2023/2/11 5:32, Jaegeuk Kim wrote:
> MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.

Good catch!

Could you please add fixes line?

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>   fs/f2fs/segment.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index 8ee5e5db9287..6003fbaf4b7d 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
>   
>   static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
>   {
> -	f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
> +	f2fs_bug_on(sbi, segno > MAIN_SEGS(sbi) - 1);
>   }
>   
>   static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
> @@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
>   
>   	/* check segment usage, and check boundary of a given segment number */
>   	if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
> -					|| segno > TOTAL_SEGS(sbi) - 1)) {
> +					|| segno > MAIN_SEGS(sbi) - 1)) {
>   		f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
>   			 GET_SIT_VBLOCKS(raw_sit), segno);
>   		set_sbi_flag(sbi, SBI_NEED_FSCK);


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix wrong segment count
  2023-02-13  9:41 ` Chao Yu
@ 2023-02-13 17:48   ` Jaegeuk Kim
  2023-02-14  1:30     ` Chao Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2023-02-13 17:48 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 02/13, Chao Yu wrote:
> On 2023/2/11 5:32, Jaegeuk Kim wrote:
> > MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.
> 
> Good catch!
> 
> Could you please add fixes line?

It seems this is not a bug case, and exisits from the first F2FS patch. :)

> 
> Thanks,
> 
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >   fs/f2fs/segment.h | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> > index 8ee5e5db9287..6003fbaf4b7d 100644
> > --- a/fs/f2fs/segment.h
> > +++ b/fs/f2fs/segment.h
> > @@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
> >   static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
> >   {
> > -	f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
> > +	f2fs_bug_on(sbi, segno > MAIN_SEGS(sbi) - 1);
> >   }
> >   static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
> > @@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
> >   	/* check segment usage, and check boundary of a given segment number */
> >   	if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
> > -					|| segno > TOTAL_SEGS(sbi) - 1)) {
> > +					|| segno > MAIN_SEGS(sbi) - 1)) {
> >   		f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
> >   			 GET_SIT_VBLOCKS(raw_sit), segno);
> >   		set_sbi_flag(sbi, SBI_NEED_FSCK);


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: fix wrong segment count
  2023-02-10 21:32 [f2fs-dev] [PATCH] f2fs: fix wrong segment count Jaegeuk Kim
  2023-02-13  9:41 ` Chao Yu
@ 2023-02-13 17:59 ` Jaegeuk Kim
  1 sibling, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2023-02-13 17:59 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---

 Change log from v1:
  - replace check_seg_range with valid_main_segno to avoid confusion.

 fs/f2fs/segment.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 92c8be00d396..efdb7fc3b797 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -719,9 +719,10 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
 	return curseg->alloc_type;
 }
 
-static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
+static inline bool valid_main_segno(struct f2fs_sb_info *sbi,
+		unsigned int segno)
 {
-	f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
+	return segno <= (MAIN_SEGS(sbi) - 1);
 }
 
 static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
@@ -776,7 +777,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
 
 	/* check segment usage, and check boundary of a given segment number */
 	if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
-					|| segno > TOTAL_SEGS(sbi) - 1)) {
+					|| !valid_main_segno(sbi, segno))) {
 		f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
 			 GET_SIT_VBLOCKS(raw_sit), segno);
 		set_sbi_flag(sbi, SBI_NEED_FSCK);
@@ -793,7 +794,7 @@ static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,
 	unsigned int offset = SIT_BLOCK_OFFSET(start);
 	block_t blk_addr = sit_i->sit_base_addr + offset;
 
-	check_seg_range(sbi, start);
+	f2fs_bug_on(sbi, !valid_main_segno(sbi, start));
 
 #ifdef CONFIG_F2FS_CHECK_FS
 	if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
-- 
2.39.1.581.gbfd45094c4-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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix wrong segment count
  2023-02-13 17:48   ` Jaegeuk Kim
@ 2023-02-14  1:30     ` Chao Yu
  2023-02-14 18:00       ` Jaegeuk Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Chao Yu @ 2023-02-14  1:30 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

On 2023/2/14 1:48, Jaegeuk Kim wrote:
> On 02/13, Chao Yu wrote:
>> On 2023/2/11 5:32, Jaegeuk Kim wrote:
>>> MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.
>>
>> Good catch!
>>
>> Could you please add fixes line?
> 
> It seems this is not a bug case, and exisits from the first F2FS patch. :)

Alright, anyway, it looks good to me.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> 
>>
>> Thanks,
>>
>>>
>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>> ---
>>>    fs/f2fs/segment.h | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
>>> index 8ee5e5db9287..6003fbaf4b7d 100644
>>> --- a/fs/f2fs/segment.h
>>> +++ b/fs/f2fs/segment.h
>>> @@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
>>>    static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
>>>    {
>>> -	f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
>>> +	f2fs_bug_on(sbi, segno > MAIN_SEGS(sbi) - 1);
>>>    }
>>>    static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
>>> @@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
>>>    	/* check segment usage, and check boundary of a given segment number */
>>>    	if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
>>> -					|| segno > TOTAL_SEGS(sbi) - 1)) {
>>> +					|| segno > MAIN_SEGS(sbi) - 1)) {
>>>    		f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
>>>    			 GET_SIT_VBLOCKS(raw_sit), segno);
>>>    		set_sbi_flag(sbi, SBI_NEED_FSCK);


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix wrong segment count
  2023-02-14  1:30     ` Chao Yu
@ 2023-02-14 18:00       ` Jaegeuk Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2023-02-14 18:00 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 02/14, Chao Yu wrote:
> On 2023/2/14 1:48, Jaegeuk Kim wrote:
> > On 02/13, Chao Yu wrote:
> > > On 2023/2/11 5:32, Jaegeuk Kim wrote:
> > > > MAIN_SEGS is for data area, while TOTAL_SEGS includes data and metadata.
> > > 
> > > Good catch!
> > > 
> > > Could you please add fixes line?
> > 
> > It seems this is not a bug case, and exisits from the first F2FS patch. :)
> 
> Alright, anyway, it looks good to me.
> 
> Reviewed-by: Chao Yu <chao@kernel.org>

I assumed this for v2. Let me know if you have other concern.

> 
> Thanks,
> 
> > 
> > > 
> > > Thanks,
> > > 
> > > > 
> > > > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > > > ---
> > > >    fs/f2fs/segment.h | 4 ++--
> > > >    1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> > > > index 8ee5e5db9287..6003fbaf4b7d 100644
> > > > --- a/fs/f2fs/segment.h
> > > > +++ b/fs/f2fs/segment.h
> > > > @@ -720,7 +720,7 @@ static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
> > > >    static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
> > > >    {
> > > > -	f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
> > > > +	f2fs_bug_on(sbi, segno > MAIN_SEGS(sbi) - 1);
> > > >    }
> > > >    static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
> > > > @@ -775,7 +775,7 @@ static inline int check_block_count(struct f2fs_sb_info *sbi,
> > > >    	/* check segment usage, and check boundary of a given segment number */
> > > >    	if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
> > > > -					|| segno > TOTAL_SEGS(sbi) - 1)) {
> > > > +					|| segno > MAIN_SEGS(sbi) - 1)) {
> > > >    		f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
> > > >    			 GET_SIT_VBLOCKS(raw_sit), segno);
> > > >    		set_sbi_flag(sbi, SBI_NEED_FSCK);


_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2023-02-14 18:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10 21:32 [f2fs-dev] [PATCH] f2fs: fix wrong segment count Jaegeuk Kim
2023-02-13  9:41 ` Chao Yu
2023-02-13 17:48   ` Jaegeuk Kim
2023-02-14  1:30     ` Chao Yu
2023-02-14 18:00       ` Jaegeuk Kim
2023-02-13 17:59 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim

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).