* [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
@ 2024-02-27 15:21 Dan Carpenter
2024-02-27 17:38 ` Jaegeuk Kim
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2024-02-27 15:21 UTC (permalink / raw)
To: zhiguo.niu; +Cc: linux-f2fs-devel
Hello Zhiguo Niu,
The patch 7a0392932f97: "f2fs: stop checkpoint when get a
out-of-bounds segment" from Feb 20, 2024 (linux-next), leads to the
following Smatch static checker warning:
fs/f2fs/checkpoint.c:34 f2fs_stop_checkpoint()
warn: sleeping in atomic context
fs/f2fs/segment.c
2650 static void get_new_segment(struct f2fs_sb_info *sbi,
2651 unsigned int *newseg, bool new_sec, bool pinning)
2652 {
2653 struct free_segmap_info *free_i = FREE_I(sbi);
2654 unsigned int segno, secno, zoneno;
2655 unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone;
2656 unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg);
2657 unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg);
2658 bool init = true;
2659 int i;
2660
2661 spin_lock(&free_i->segmap_lock);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
preempt disabled here
2662
2663 if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
2664 segno = find_next_zero_bit(free_i->free_segmap,
2665 GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
2666 if (segno < GET_SEG_FROM_SEC(sbi, hint + 1))
2667 goto got_it;
2668 }
2669
2670 /*
2671 * If we format f2fs on zoned storage, let's try to get pinned sections
2672 * from beginning of the storage, which should be a conventional one.
2673 */
2674 if (f2fs_sb_has_blkzoned(sbi)) {
2675 segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
2676 hint = GET_SEC_FROM_SEG(sbi, segno);
2677 }
2678
2679 find_other_zone:
2680 secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
2681 if (secno >= MAIN_SECS(sbi)) {
2682 secno = find_first_zero_bit(free_i->free_secmap,
2683 MAIN_SECS(sbi));
2684 if (secno >= MAIN_SECS(sbi)) {
2685 f2fs_stop_checkpoint(sbi, false,
^^^^^
This false means we sleep while holding a spin lock.
2686 STOP_CP_REASON_NO_SEGMENT);
2687 f2fs_bug_on(sbi, 1);
2688 }
2689 }
2690 segno = GET_SEG_FROM_SEC(sbi, secno);
2691 zoneno = GET_ZONE_FROM_SEC(sbi, secno);
fs/f2fs/checkpoint.c
29 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io,
30 unsigned char reason)
31 {
32 f2fs_build_fault_attr(sbi, 0, 0);
33 if (!end_io)
--> 34 f2fs_flush_merged_writes(sbi);
35 f2fs_handle_critical_error(sbi, reason, end_io);
36 }
regards,
dan carpenter
_______________________________________________
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] 4+ messages in thread
* Re: [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
2024-02-27 15:21 [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment Dan Carpenter
@ 2024-02-27 17:38 ` Jaegeuk Kim
2024-02-28 0:55 ` [f2fs-dev] 答复: " 牛志国 (Zhiguo Niu)
2024-02-28 1:25 ` 牛志国 (Zhiguo Niu)
0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2024-02-27 17:38 UTC (permalink / raw)
To: Dan Carpenter; +Cc: zhiguo.niu, linux-f2fs-devel
Hi,
I merged two patches, which addresses this.
f2fs: stop checkpoint when get a out-of-bounds segment
f2fs: fix to don't call f2fs_stop_checkpoint in spinlock coverage
On 02/27, Dan Carpenter wrote:
> Hello Zhiguo Niu,
>
> The patch 7a0392932f97: "f2fs: stop checkpoint when get a
> out-of-bounds segment" from Feb 20, 2024 (linux-next), leads to the
> following Smatch static checker warning:
>
> fs/f2fs/checkpoint.c:34 f2fs_stop_checkpoint()
> warn: sleeping in atomic context
>
> fs/f2fs/segment.c
> 2650 static void get_new_segment(struct f2fs_sb_info *sbi,
> 2651 unsigned int *newseg, bool new_sec, bool pinning)
> 2652 {
> 2653 struct free_segmap_info *free_i = FREE_I(sbi);
> 2654 unsigned int segno, secno, zoneno;
> 2655 unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone;
> 2656 unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg);
> 2657 unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg);
> 2658 bool init = true;
> 2659 int i;
> 2660
> 2661 spin_lock(&free_i->segmap_lock);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> preempt disabled here
>
> 2662
> 2663 if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
> 2664 segno = find_next_zero_bit(free_i->free_segmap,
> 2665 GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
> 2666 if (segno < GET_SEG_FROM_SEC(sbi, hint + 1))
> 2667 goto got_it;
> 2668 }
> 2669
> 2670 /*
> 2671 * If we format f2fs on zoned storage, let's try to get pinned sections
> 2672 * from beginning of the storage, which should be a conventional one.
> 2673 */
> 2674 if (f2fs_sb_has_blkzoned(sbi)) {
> 2675 segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> 2676 hint = GET_SEC_FROM_SEG(sbi, segno);
> 2677 }
> 2678
> 2679 find_other_zone:
> 2680 secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> 2681 if (secno >= MAIN_SECS(sbi)) {
> 2682 secno = find_first_zero_bit(free_i->free_secmap,
> 2683 MAIN_SECS(sbi));
> 2684 if (secno >= MAIN_SECS(sbi)) {
> 2685 f2fs_stop_checkpoint(sbi, false,
> ^^^^^
> This false means we sleep while holding a spin lock.
>
> 2686 STOP_CP_REASON_NO_SEGMENT);
> 2687 f2fs_bug_on(sbi, 1);
> 2688 }
> 2689 }
> 2690 segno = GET_SEG_FROM_SEC(sbi, secno);
> 2691 zoneno = GET_ZONE_FROM_SEC(sbi, secno);
>
> fs/f2fs/checkpoint.c
> 29 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io,
> 30 unsigned char reason)
> 31 {
> 32 f2fs_build_fault_attr(sbi, 0, 0);
> 33 if (!end_io)
> --> 34 f2fs_flush_merged_writes(sbi);
> 35 f2fs_handle_critical_error(sbi, reason, end_io);
> 36 }
>
> regards,
> dan carpenter
>
>
> _______________________________________________
> 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] 4+ messages in thread
* [f2fs-dev] 答复: [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
2024-02-27 17:38 ` Jaegeuk Kim
@ 2024-02-28 0:55 ` 牛志国 (Zhiguo Niu)
2024-02-28 1:25 ` 牛志国 (Zhiguo Niu)
1 sibling, 0 replies; 4+ messages in thread
From: 牛志国 (Zhiguo Niu) @ 2024-02-28 0:55 UTC (permalink / raw)
To: Jaegeuk Kim, Dan Carpenter
Cc: 金红宇 (Hongyu Jin),
linux-f2fs-devel@lists.sourceforge.net
Hi Jaegeuk,
Chao's patch fix should can fix this warning:
f2fs: fix to don't call f2fs_stop_checkpoint in spinlock coverage thanks!
-----邮件原件-----
发件人: Jaegeuk Kim <jaegeuk@kernel.org>
发送时间: 2024年2月28日 1:38
收件人: Dan Carpenter <dan.carpenter@linaro.org>
抄送: 牛志国 (Zhiguo Niu) <Zhiguo.Niu@unisoc.com>; linux-f2fs-devel@lists.sourceforge.net
主题: Re: [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
注意: 这封邮件来自于外部。除非你确定邮件内容安全,否则不要点击任何链接和附件。
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi,
I merged two patches, which addresses this.
f2fs: stop checkpoint when get a out-of-bounds segment
f2fs: fix to don't call f2fs_stop_checkpoint in spinlock coverage
On 02/27, Dan Carpenter wrote:
> Hello Zhiguo Niu,
>
> The patch 7a0392932f97: "f2fs: stop checkpoint when get a
> out-of-bounds segment" from Feb 20, 2024 (linux-next), leads to the
> following Smatch static checker warning:
>
> fs/f2fs/checkpoint.c:34 f2fs_stop_checkpoint()
> warn: sleeping in atomic context
>
> fs/f2fs/segment.c
> 2650 static void get_new_segment(struct f2fs_sb_info *sbi,
> 2651 unsigned int *newseg, bool new_sec, bool pinning)
> 2652 {
> 2653 struct free_segmap_info *free_i = FREE_I(sbi);
> 2654 unsigned int segno, secno, zoneno;
> 2655 unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone;
> 2656 unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg);
> 2657 unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg);
> 2658 bool init = true;
> 2659 int i;
> 2660
> 2661 spin_lock(&free_i->segmap_lock);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ preempt disabled here
>
> 2662
> 2663 if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
> 2664 segno = find_next_zero_bit(free_i->free_segmap,
> 2665 GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
> 2666 if (segno < GET_SEG_FROM_SEC(sbi, hint + 1))
> 2667 goto got_it;
> 2668 }
> 2669
> 2670 /*
> 2671 * If we format f2fs on zoned storage, let's try to get pinned sections
> 2672 * from beginning of the storage, which should be a conventional one.
> 2673 */
> 2674 if (f2fs_sb_has_blkzoned(sbi)) {
> 2675 segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> 2676 hint = GET_SEC_FROM_SEG(sbi, segno);
> 2677 }
> 2678
> 2679 find_other_zone:
> 2680 secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> 2681 if (secno >= MAIN_SECS(sbi)) {
> 2682 secno = find_first_zero_bit(free_i->free_secmap,
> 2683 MAIN_SECS(sbi));
> 2684 if (secno >= MAIN_SECS(sbi)) {
> 2685 f2fs_stop_checkpoint(sbi, false,
> ^^^^^ This
> false means we sleep while holding a spin lock.
>
> 2686 STOP_CP_REASON_NO_SEGMENT);
> 2687 f2fs_bug_on(sbi, 1);
> 2688 }
> 2689 }
> 2690 segno = GET_SEG_FROM_SEC(sbi, secno);
> 2691 zoneno = GET_ZONE_FROM_SEC(sbi, secno);
>
> fs/f2fs/checkpoint.c
> 29 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io,
> 30 unsigned char reason)
> 31 {
> 32 f2fs_build_fault_attr(sbi, 0, 0);
> 33 if (!end_io)
> --> 34 f2fs_flush_merged_writes(sbi);
> 35 f2fs_handle_critical_error(sbi, reason, end_io);
> 36 }
>
> regards,
> dan carpenter
>
>
> _______________________________________________
> 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] 4+ messages in thread
* [f2fs-dev] 答复: [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
2024-02-27 17:38 ` Jaegeuk Kim
2024-02-28 0:55 ` [f2fs-dev] 答复: " 牛志国 (Zhiguo Niu)
@ 2024-02-28 1:25 ` 牛志国 (Zhiguo Niu)
1 sibling, 0 replies; 4+ messages in thread
From: 牛志国 (Zhiguo Niu) @ 2024-02-28 1:25 UTC (permalink / raw)
To: Jaegeuk Kim, Dan Carpenter
Cc: 金红宇 (Hongyu Jin),
linux-f2fs-devel@lists.sourceforge.net
Hi Jaegeuk,
I understand what you mean^^,
please ignore my last email, sorry again:).
Thanks!
-----邮件原件-----
发件人: 牛志国 (Zhiguo Niu)
发送时间: 2024年2月28日 8:55
收件人: 'Jaegeuk Kim' <jaegeuk@kernel.org>; 'Dan Carpenter' <dan.carpenter@linaro.org>
抄送: 'linux-f2fs-devel@lists.sourceforge.net' <linux-f2fs-devel@lists.sourceforge.net>; 金红宇 (Hongyu Jin) <Hongyu.Jin@unisoc.com>; 'Chao Yu' <chao@kernel.org>
主题: 答复: [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
Hi Jaegeuk,
Chao's patch fix should can fix this warning:
f2fs: fix to don't call f2fs_stop_checkpoint in spinlock coverage thanks!
-----邮件原件-----
发件人: Jaegeuk Kim <jaegeuk@kernel.org>
发送时间: 2024年2月28日 1:38
收件人: Dan Carpenter <dan.carpenter@linaro.org>
抄送: 牛志国 (Zhiguo Niu) <Zhiguo.Niu@unisoc.com>; linux-f2fs-devel@lists.sourceforge.net
主题: Re: [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
注意: 这封邮件来自于外部。除非你确定邮件内容安全,否则不要点击任何链接和附件。
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi,
I merged two patches, which addresses this.
f2fs: stop checkpoint when get a out-of-bounds segment
f2fs: fix to don't call f2fs_stop_checkpoint in spinlock coverage
On 02/27, Dan Carpenter wrote:
> Hello Zhiguo Niu,
>
> The patch 7a0392932f97: "f2fs: stop checkpoint when get a
> out-of-bounds segment" from Feb 20, 2024 (linux-next), leads to the
> following Smatch static checker warning:
>
> fs/f2fs/checkpoint.c:34 f2fs_stop_checkpoint()
> warn: sleeping in atomic context
>
> fs/f2fs/segment.c
> 2650 static void get_new_segment(struct f2fs_sb_info *sbi,
> 2651 unsigned int *newseg, bool new_sec, bool pinning)
> 2652 {
> 2653 struct free_segmap_info *free_i = FREE_I(sbi);
> 2654 unsigned int segno, secno, zoneno;
> 2655 unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone;
> 2656 unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg);
> 2657 unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg);
> 2658 bool init = true;
> 2659 int i;
> 2660
> 2661 spin_lock(&free_i->segmap_lock);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ preempt disabled here
>
> 2662
> 2663 if (!new_sec && ((*newseg + 1) % SEGS_PER_SEC(sbi))) {
> 2664 segno = find_next_zero_bit(free_i->free_segmap,
> 2665 GET_SEG_FROM_SEC(sbi, hint + 1), *newseg + 1);
> 2666 if (segno < GET_SEG_FROM_SEC(sbi, hint + 1))
> 2667 goto got_it;
> 2668 }
> 2669
> 2670 /*
> 2671 * If we format f2fs on zoned storage, let's try to get pinned sections
> 2672 * from beginning of the storage, which should be a conventional one.
> 2673 */
> 2674 if (f2fs_sb_has_blkzoned(sbi)) {
> 2675 segno = pinning ? 0 : max(first_zoned_segno(sbi), *newseg);
> 2676 hint = GET_SEC_FROM_SEG(sbi, segno);
> 2677 }
> 2678
> 2679 find_other_zone:
> 2680 secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
> 2681 if (secno >= MAIN_SECS(sbi)) {
> 2682 secno = find_first_zero_bit(free_i->free_secmap,
> 2683 MAIN_SECS(sbi));
> 2684 if (secno >= MAIN_SECS(sbi)) {
> 2685 f2fs_stop_checkpoint(sbi, false,
> ^^^^^ This
> false means we sleep while holding a spin lock.
>
> 2686 STOP_CP_REASON_NO_SEGMENT);
> 2687 f2fs_bug_on(sbi, 1);
> 2688 }
> 2689 }
> 2690 segno = GET_SEG_FROM_SEC(sbi, secno);
> 2691 zoneno = GET_ZONE_FROM_SEC(sbi, secno);
>
> fs/f2fs/checkpoint.c
> 29 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io,
> 30 unsigned char reason)
> 31 {
> 32 f2fs_build_fault_attr(sbi, 0, 0);
> 33 if (!end_io)
> --> 34 f2fs_flush_merged_writes(sbi);
> 35 f2fs_handle_critical_error(sbi, reason, end_io);
> 36 }
>
> regards,
> dan carpenter
>
>
> _______________________________________________
> 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] 4+ messages in thread
end of thread, other threads:[~2024-02-28 1:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 15:21 [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment Dan Carpenter
2024-02-27 17:38 ` Jaegeuk Kim
2024-02-28 0:55 ` [f2fs-dev] 答复: " 牛志国 (Zhiguo Niu)
2024-02-28 1:25 ` 牛志国 (Zhiguo Niu)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.