All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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.