hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/fs/f2fs/segment.c
....@@ -1547,7 +1547,7 @@
15471547 if (i + 1 < dpolicy->granularity)
15481548 break;
15491549
1550
- if (i < DEFAULT_DISCARD_GRANULARITY && dpolicy->ordered)
1550
+ if (i + 1 < DEFAULT_DISCARD_GRANULARITY && dpolicy->ordered)
15511551 return __issue_discard_cmd_orderly(sbi, dpolicy);
15521552
15531553 pend_list = &dcc->pend_list[i];
....@@ -4713,6 +4713,13 @@
47134713 dirty_i->victim_secmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL);
47144714 if (!dirty_i->victim_secmap)
47154715 return -ENOMEM;
4716
+
4717
+ dirty_i->pinned_secmap = f2fs_kvzalloc(sbi, bitmap_size, GFP_KERNEL);
4718
+ if (!dirty_i->pinned_secmap)
4719
+ return -ENOMEM;
4720
+
4721
+ dirty_i->pinned_secmap_cnt = 0;
4722
+ dirty_i->enable_pin_section = true;
47164723 return 0;
47174724 }
47184725
....@@ -5047,54 +5054,6 @@
50475054 return 0;
50485055 }
50495056
5050
-static bool is_conv_zone(struct f2fs_sb_info *sbi, unsigned int zone_idx,
5051
- unsigned int dev_idx)
5052
-{
5053
- if (!bdev_is_zoned(FDEV(dev_idx).bdev))
5054
- return true;
5055
- return !test_bit(zone_idx, FDEV(dev_idx).blkz_seq);
5056
-}
5057
-
5058
-/* Return the zone index in the given device */
5059
-static unsigned int get_zone_idx(struct f2fs_sb_info *sbi, unsigned int secno,
5060
- int dev_idx)
5061
-{
5062
- block_t sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno));
5063
-
5064
- return (sec_start_blkaddr - FDEV(dev_idx).start_blk) >>
5065
- sbi->log_blocks_per_blkz;
5066
-}
5067
-
5068
-/*
5069
- * Return the usable segments in a section based on the zone's
5070
- * corresponding zone capacity. Zone is equal to a section.
5071
- */
5072
-static inline unsigned int f2fs_usable_zone_segs_in_sec(
5073
- struct f2fs_sb_info *sbi, unsigned int segno)
5074
-{
5075
- unsigned int dev_idx, zone_idx, unusable_segs_in_sec;
5076
-
5077
- dev_idx = f2fs_target_device_index(sbi, START_BLOCK(sbi, segno));
5078
- zone_idx = get_zone_idx(sbi, GET_SEC_FROM_SEG(sbi, segno), dev_idx);
5079
-
5080
- /* Conventional zone's capacity is always equal to zone size */
5081
- if (is_conv_zone(sbi, zone_idx, dev_idx))
5082
- return sbi->segs_per_sec;
5083
-
5084
- /*
5085
- * If the zone_capacity_blocks array is NULL, then zone capacity
5086
- * is equal to the zone size for all zones
5087
- */
5088
- if (!FDEV(dev_idx).zone_capacity_blocks)
5089
- return sbi->segs_per_sec;
5090
-
5091
- /* Get the segment count beyond zone capacity block */
5092
- unusable_segs_in_sec = (sbi->blocks_per_blkz -
5093
- FDEV(dev_idx).zone_capacity_blocks[zone_idx]) >>
5094
- sbi->log_blocks_per_seg;
5095
- return sbi->segs_per_sec - unusable_segs_in_sec;
5096
-}
5097
-
50985057 /*
50995058 * Return the number of usable blocks in a segment. The number of blocks
51005059 * returned is always equal to the number of blocks in a segment for
....@@ -5107,26 +5066,15 @@
51075066 struct f2fs_sb_info *sbi, unsigned int segno)
51085067 {
51095068 block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr;
5110
- unsigned int zone_idx, dev_idx, secno;
5069
+ unsigned int secno;
5070
+
5071
+ if (!sbi->unusable_blocks_per_sec)
5072
+ return sbi->blocks_per_seg;
51115073
51125074 secno = GET_SEC_FROM_SEG(sbi, segno);
51135075 seg_start = START_BLOCK(sbi, segno);
5114
- dev_idx = f2fs_target_device_index(sbi, seg_start);
5115
- zone_idx = get_zone_idx(sbi, secno, dev_idx);
5116
-
5117
- /*
5118
- * Conventional zone's capacity is always equal to zone size,
5119
- * so, blocks per segment is unchanged.
5120
- */
5121
- if (is_conv_zone(sbi, zone_idx, dev_idx))
5122
- return sbi->blocks_per_seg;
5123
-
5124
- if (!FDEV(dev_idx).zone_capacity_blocks)
5125
- return sbi->blocks_per_seg;
5126
-
51275076 sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno));
5128
- sec_cap_blkaddr = sec_start_blkaddr +
5129
- FDEV(dev_idx).zone_capacity_blocks[zone_idx];
5077
+ sec_cap_blkaddr = sec_start_blkaddr + CAP_BLKS_PER_SEC(sbi);
51305078
51315079 /*
51325080 * If segment starts before zone capacity and spans beyond
....@@ -5158,11 +5106,6 @@
51585106 return 0;
51595107 }
51605108
5161
-static inline unsigned int f2fs_usable_zone_segs_in_sec(struct f2fs_sb_info *sbi,
5162
- unsigned int segno)
5163
-{
5164
- return 0;
5165
-}
51665109 #endif
51675110 unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi,
51685111 unsigned int segno)
....@@ -5177,7 +5120,7 @@
51775120 unsigned int segno)
51785121 {
51795122 if (f2fs_sb_has_blkzoned(sbi))
5180
- return f2fs_usable_zone_segs_in_sec(sbi, segno);
5123
+ return CAP_SEGS_PER_SEC(sbi);
51815124
51825125 return sbi->segs_per_sec;
51835126 }
....@@ -5301,6 +5244,7 @@
53015244 {
53025245 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
53035246
5247
+ kvfree(dirty_i->pinned_secmap);
53045248 kvfree(dirty_i->victim_secmap);
53055249 }
53065250