Linux-f2fs-devel Archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: zhiguo.niu@unisoc.com
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment
Date: Tue, 27 Feb 2024 18:21:58 +0300	[thread overview]
Message-ID: <bb8814a4-09e1-49b7-ab13-391624a0658c@moroto.mountain> (raw)

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

             reply	other threads:[~2024-02-27 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 15:21 Dan Carpenter [this message]
2024-02-27 17:38 ` [f2fs-dev] [bug report] f2fs: stop checkpoint when get a out-of-bounds segment Jaegeuk Kim
2024-02-28  0:55   ` [f2fs-dev] 答复: " 牛志国 (Zhiguo Niu)
2024-02-28  1:25   ` 牛志国 (Zhiguo Niu)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb8814a4-09e1-49b7-ab13-391624a0658c@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=zhiguo.niu@unisoc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).