Lines Matching +full:keys +full:- +full:per +full:- +full:group

1 // SPDX-License-Identifier: GPL-2.0+
19 dest->fmr_device = src->fmr_device; in ext4_fsmap_from_internal()
20 dest->fmr_flags = src->fmr_flags; in ext4_fsmap_from_internal()
21 dest->fmr_physical = src->fmr_physical << sb->s_blocksize_bits; in ext4_fsmap_from_internal()
22 dest->fmr_owner = src->fmr_owner; in ext4_fsmap_from_internal()
23 dest->fmr_offset = 0; in ext4_fsmap_from_internal()
24 dest->fmr_length = src->fmr_length << sb->s_blocksize_bits; in ext4_fsmap_from_internal()
25 dest->fmr_reserved[0] = 0; in ext4_fsmap_from_internal()
26 dest->fmr_reserved[1] = 0; in ext4_fsmap_from_internal()
27 dest->fmr_reserved[2] = 0; in ext4_fsmap_from_internal()
34 dest->fmr_device = src->fmr_device; in ext4_fsmap_to_internal()
35 dest->fmr_flags = src->fmr_flags; in ext4_fsmap_to_internal()
36 dest->fmr_physical = src->fmr_physical >> sb->s_blocksize_bits; in ext4_fsmap_to_internal()
37 dest->fmr_owner = src->fmr_owner; in ext4_fsmap_to_internal()
38 dest->fmr_length = src->fmr_length >> sb->s_blocksize_bits; in ext4_fsmap_to_internal()
59 struct ext4_fsmap *keys,
70 return d1->gfd_dev - d2->gfd_dev; in ext4_getfsmap_dev_compare()
77 return rec->fmr_physical < info->gfi_low.fmr_physical; in ext4_getfsmap_rec_before_low_key()
90 ext4_fsblk_t rec_fsblk = rec->fmr_physical; in ext4_getfsmap_helper()
96 return -EINTR; in ext4_getfsmap_helper()
103 rec_fsblk += rec->fmr_length; in ext4_getfsmap_helper()
104 if (info->gfi_next_fsblk < rec_fsblk) in ext4_getfsmap_helper()
105 info->gfi_next_fsblk = rec_fsblk; in ext4_getfsmap_helper()
110 if (info->gfi_head->fmh_count == 0) { in ext4_getfsmap_helper()
111 if (info->gfi_head->fmh_entries == UINT_MAX) in ext4_getfsmap_helper()
114 if (rec_fsblk > info->gfi_next_fsblk) in ext4_getfsmap_helper()
115 info->gfi_head->fmh_entries++; in ext4_getfsmap_helper()
117 if (info->gfi_last) in ext4_getfsmap_helper()
120 info->gfi_head->fmh_entries++; in ext4_getfsmap_helper()
122 rec_fsblk += rec->fmr_length; in ext4_getfsmap_helper()
123 if (info->gfi_next_fsblk < rec_fsblk) in ext4_getfsmap_helper()
124 info->gfi_next_fsblk = rec_fsblk; in ext4_getfsmap_helper()
133 if (rec_fsblk > info->gfi_next_fsblk) { in ext4_getfsmap_helper()
134 if (info->gfi_head->fmh_entries >= info->gfi_head->fmh_count) in ext4_getfsmap_helper()
137 ext4_get_group_no_and_offset(sb, info->gfi_next_fsblk, in ext4_getfsmap_helper()
139 trace_ext4_fsmap_mapping(sb, info->gfi_dev, agno, in ext4_getfsmap_helper()
141 rec_fsblk - info->gfi_next_fsblk, in ext4_getfsmap_helper()
144 fmr.fmr_device = info->gfi_dev; in ext4_getfsmap_helper()
145 fmr.fmr_physical = info->gfi_next_fsblk; in ext4_getfsmap_helper()
147 fmr.fmr_length = rec_fsblk - info->gfi_next_fsblk; in ext4_getfsmap_helper()
149 error = info->gfi_formatter(&fmr, info->gfi_format_arg); in ext4_getfsmap_helper()
152 info->gfi_head->fmh_entries++; in ext4_getfsmap_helper()
155 if (info->gfi_last) in ext4_getfsmap_helper()
159 if (info->gfi_head->fmh_entries >= info->gfi_head->fmh_count) in ext4_getfsmap_helper()
163 trace_ext4_fsmap_mapping(sb, info->gfi_dev, agno, EXT4_C2B(sbi, cno), in ext4_getfsmap_helper()
164 rec->fmr_length, rec->fmr_owner); in ext4_getfsmap_helper()
166 fmr.fmr_device = info->gfi_dev; in ext4_getfsmap_helper()
168 fmr.fmr_owner = rec->fmr_owner; in ext4_getfsmap_helper()
170 fmr.fmr_length = rec->fmr_length; in ext4_getfsmap_helper()
171 error = info->gfi_formatter(&fmr, info->gfi_format_arg); in ext4_getfsmap_helper()
174 info->gfi_head->fmh_entries++; in ext4_getfsmap_helper()
177 rec_fsblk += rec->fmr_length; in ext4_getfsmap_helper()
178 if (info->gfi_next_fsblk < rec_fsblk) in ext4_getfsmap_helper()
179 info->gfi_next_fsblk = rec_fsblk; in ext4_getfsmap_helper()
185 return fmr->fmr_physical + fmr->fmr_length; in ext4_fsmap_next_pblk()
206 if (info->gfi_lastfree.fmr_owner) { in ext4_getfsmap_datadev_helper()
208 if (ext4_fsmap_next_pblk(&info->gfi_lastfree) == fsb) { in ext4_getfsmap_datadev_helper()
209 info->gfi_lastfree.fmr_length += fslen; in ext4_getfsmap_datadev_helper()
217 error = ext4_getfsmap_helper(sb, info, &info->gfi_lastfree); in ext4_getfsmap_datadev_helper()
220 info->gfi_lastfree.fmr_owner = 0; in ext4_getfsmap_datadev_helper()
224 list_for_each_entry_safe(p, tmp, &info->gfi_meta_list, fmr_list) { in ext4_getfsmap_datadev_helper()
225 if (p->fmr_physical + p->fmr_length <= info->gfi_next_fsblk) { in ext4_getfsmap_datadev_helper()
226 list_del(&p->fmr_list); in ext4_getfsmap_datadev_helper()
228 } else if (p->fmr_physical < fsb) { in ext4_getfsmap_datadev_helper()
233 list_del(&p->fmr_list); in ext4_getfsmap_datadev_helper()
247 info->gfi_lastfree = irec; in ext4_getfsmap_datadev_helper()
256 static int ext4_getfsmap_logdev(struct super_block *sb, struct ext4_fsmap *keys, in ext4_getfsmap_logdev() argument
259 journal_t *journal = EXT4_SB(sb)->s_journal; in ext4_getfsmap_logdev()
262 /* Set up search keys */ in ext4_getfsmap_logdev()
263 info->gfi_low = keys[0]; in ext4_getfsmap_logdev()
264 info->gfi_low.fmr_length = 0; in ext4_getfsmap_logdev()
266 memset(&info->gfi_high, 0xFF, sizeof(info->gfi_high)); in ext4_getfsmap_logdev()
268 trace_ext4_fsmap_low_key(sb, info->gfi_dev, 0, in ext4_getfsmap_logdev()
269 info->gfi_low.fmr_physical, in ext4_getfsmap_logdev()
270 info->gfi_low.fmr_length, in ext4_getfsmap_logdev()
271 info->gfi_low.fmr_owner); in ext4_getfsmap_logdev()
273 trace_ext4_fsmap_high_key(sb, info->gfi_dev, 0, in ext4_getfsmap_logdev()
274 info->gfi_high.fmr_physical, in ext4_getfsmap_logdev()
275 info->gfi_high.fmr_length, in ext4_getfsmap_logdev()
276 info->gfi_high.fmr_owner); in ext4_getfsmap_logdev()
278 if (keys[0].fmr_physical > 0) in ext4_getfsmap_logdev()
282 irec.fmr_physical = journal->j_blk_offset; in ext4_getfsmap_logdev()
283 irec.fmr_length = journal->j_total_len; in ext4_getfsmap_logdev()
299 return -ENOMEM; in ext4_getfsmap_fill()
300 fsm->fmr_device = 0; in ext4_getfsmap_fill()
301 fsm->fmr_flags = 0; in ext4_getfsmap_fill()
302 fsm->fmr_physical = fsb; in ext4_getfsmap_fill()
303 fsm->fmr_owner = owner; in ext4_getfsmap_fill()
304 fsm->fmr_length = len; in ext4_getfsmap_fill()
305 list_add_tail(&fsm->fmr_list, meta_list); in ext4_getfsmap_fill()
312 * the beginning of a block group, including the reserved gdt blocks.
321 unsigned long first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); in ext4_getfsmap_find_sb()
333 /* Record the group descriptors. */ in ext4_getfsmap_find_sb()
345 len = le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks); in ext4_getfsmap_find_sb()
365 if (fa->fmr_physical < fb->fmr_physical) in ext4_getfsmap_compare()
366 return -1; in ext4_getfsmap_compare()
367 else if (fa->fmr_physical > fb->fmr_physical) in ext4_getfsmap_compare()
385 if (prev->fmr_owner == p->fmr_owner && in ext4_getfsmap_merge_fixed_metadata()
386 prev->fmr_physical + prev->fmr_length == p->fmr_physical) { in ext4_getfsmap_merge_fixed_metadata()
387 prev->fmr_length += p->fmr_length; in ext4_getfsmap_merge_fixed_metadata()
388 list_del(&p->fmr_list); in ext4_getfsmap_merge_fixed_metadata()
402 list_del(&p->fmr_list); in ext4_getfsmap_free_fixed_metadata()
418 for (agno = 0; agno < EXT4_SB(sb)->s_groups_count; agno++) { in ext4_getfsmap_find_fixed_metadata()
421 error = -EFSCORRUPTED; in ext4_getfsmap_find_fixed_metadata()
447 EXT4_SB(sb)->s_itb_per_group, in ext4_getfsmap_find_fixed_metadata()
467 struct ext4_fsmap *keys, in ext4_getfsmap_datadev() argument
481 bofs = le32_to_cpu(sbi->s_es->s_first_data_block); in ext4_getfsmap_datadev()
482 eofs = ext4_blocks_count(sbi->s_es); in ext4_getfsmap_datadev()
483 if (keys[0].fmr_physical >= eofs) in ext4_getfsmap_datadev()
485 else if (keys[0].fmr_physical < bofs) in ext4_getfsmap_datadev()
486 keys[0].fmr_physical = bofs; in ext4_getfsmap_datadev()
487 if (keys[1].fmr_physical >= eofs) in ext4_getfsmap_datadev()
488 keys[1].fmr_physical = eofs - 1; in ext4_getfsmap_datadev()
489 if (keys[1].fmr_physical < keys[0].fmr_physical) in ext4_getfsmap_datadev()
491 start_fsb = keys[0].fmr_physical; in ext4_getfsmap_datadev()
492 end_fsb = keys[1].fmr_physical; in ext4_getfsmap_datadev()
494 /* Determine first and last group to examine based on start and end */ in ext4_getfsmap_datadev()
499 * Convert the fsmap low/high keys to bg based keys. Initialize in ext4_getfsmap_datadev()
503 info->gfi_low = keys[0]; in ext4_getfsmap_datadev()
504 info->gfi_low.fmr_physical = EXT4_C2B(sbi, first_cluster); in ext4_getfsmap_datadev()
505 info->gfi_low.fmr_length = 0; in ext4_getfsmap_datadev()
507 memset(&info->gfi_high, 0xFF, sizeof(info->gfi_high)); in ext4_getfsmap_datadev()
509 /* Assemble a list of all the fixed-location metadata. */ in ext4_getfsmap_datadev()
510 error = ext4_getfsmap_find_fixed_metadata(sb, &info->gfi_meta_list); in ext4_getfsmap_datadev()
515 for (info->gfi_agno = start_ag; in ext4_getfsmap_datadev()
516 info->gfi_agno <= end_ag; in ext4_getfsmap_datadev()
517 info->gfi_agno++) { in ext4_getfsmap_datadev()
522 if (info->gfi_agno == end_ag) { in ext4_getfsmap_datadev()
523 info->gfi_high = keys[1]; in ext4_getfsmap_datadev()
524 info->gfi_high.fmr_physical = EXT4_C2B(sbi, in ext4_getfsmap_datadev()
526 info->gfi_high.fmr_length = 0; in ext4_getfsmap_datadev()
529 trace_ext4_fsmap_low_key(sb, info->gfi_dev, info->gfi_agno, in ext4_getfsmap_datadev()
530 info->gfi_low.fmr_physical, in ext4_getfsmap_datadev()
531 info->gfi_low.fmr_length, in ext4_getfsmap_datadev()
532 info->gfi_low.fmr_owner); in ext4_getfsmap_datadev()
534 trace_ext4_fsmap_high_key(sb, info->gfi_dev, info->gfi_agno, in ext4_getfsmap_datadev()
535 info->gfi_high.fmr_physical, in ext4_getfsmap_datadev()
536 info->gfi_high.fmr_length, in ext4_getfsmap_datadev()
537 info->gfi_high.fmr_owner); in ext4_getfsmap_datadev()
539 error = ext4_mballoc_query_range(sb, info->gfi_agno, in ext4_getfsmap_datadev()
540 EXT4_B2C(sbi, info->gfi_low.fmr_physical), in ext4_getfsmap_datadev()
541 EXT4_B2C(sbi, info->gfi_high.fmr_physical), in ext4_getfsmap_datadev()
550 if (info->gfi_agno == start_ag) in ext4_getfsmap_datadev()
551 memset(&info->gfi_low, 0, sizeof(info->gfi_low)); in ext4_getfsmap_datadev()
555 if (info->gfi_lastfree.fmr_owner) { in ext4_getfsmap_datadev()
556 error = ext4_getfsmap_helper(sb, info, &info->gfi_lastfree); in ext4_getfsmap_datadev()
562 info->gfi_last = true; in ext4_getfsmap_datadev()
568 ext4_getfsmap_free_fixed_metadata(&info->gfi_meta_list); in ext4_getfsmap_datadev()
576 if (fm->fmr_device == 0 || fm->fmr_device == UINT_MAX || in ext4_getfsmap_is_valid_device()
577 fm->fmr_device == new_encode_dev(sb->s_bdev->bd_dev)) in ext4_getfsmap_is_valid_device()
579 if (EXT4_SB(sb)->s_journal_bdev && in ext4_getfsmap_is_valid_device()
580 fm->fmr_device == new_encode_dev(EXT4_SB(sb)->s_journal_bdev->bd_dev)) in ext4_getfsmap_is_valid_device()
589 if (low_key->fmr_device > high_key->fmr_device) in ext4_getfsmap_check_keys()
591 if (low_key->fmr_device < high_key->fmr_device) in ext4_getfsmap_check_keys()
594 if (low_key->fmr_physical > high_key->fmr_physical) in ext4_getfsmap_check_keys()
596 if (low_key->fmr_physical < high_key->fmr_physical) in ext4_getfsmap_check_keys()
599 if (low_key->fmr_owner > high_key->fmr_owner) in ext4_getfsmap_check_keys()
601 if (low_key->fmr_owner < high_key->fmr_owner) in ext4_getfsmap_check_keys()
611 * extents are mapped, until the passed-in head->fmh_count slots have
612 * been filled, or until the formatter short-circuits the loop, if it
613 * is tracking filled-in extents on its own.
616 * ----------------
617 * There are multiple levels of keys and counters at work here:
618 * _fsmap_head.fmh_keys -- low and high fsmap keys passed in;
619 * these reflect fs-wide block addrs.
620 * dkeys -- fmh_keys used to query each device;
623 * _getfsmap_info.gfi_next_fsblk-- next fs block we expect to see; this
626 * _getfsmap_info.gfi_low/high -- per-bg low/high keys computed from
632 struct ext4_fsmap dkeys[2]; /* per-dev keys */ in ext4_getfsmap()
638 if (head->fmh_iflags & ~FMH_IF_VALID) in ext4_getfsmap()
639 return -EINVAL; in ext4_getfsmap()
640 if (!ext4_getfsmap_is_valid_device(sb, &head->fmh_keys[0]) || in ext4_getfsmap()
641 !ext4_getfsmap_is_valid_device(sb, &head->fmh_keys[1])) in ext4_getfsmap()
642 return -EINVAL; in ext4_getfsmap()
644 head->fmh_entries = 0; in ext4_getfsmap()
648 handlers[0].gfd_dev = new_encode_dev(sb->s_bdev->bd_dev); in ext4_getfsmap()
650 if (EXT4_SB(sb)->s_journal_bdev) { in ext4_getfsmap()
652 EXT4_SB(sb)->s_journal_bdev->bd_dev); in ext4_getfsmap()
662 * This is identified by a non-zero length in the low key. We in ext4_getfsmap()
670 dkeys[0] = head->fmh_keys[0]; in ext4_getfsmap()
676 if (!ext4_getfsmap_check_keys(dkeys, &head->fmh_keys[1])) in ext4_getfsmap()
677 return -EINVAL; in ext4_getfsmap()
679 info.gfi_next_fsblk = head->fmh_keys[0].fmr_physical + in ext4_getfsmap()
680 head->fmh_keys[0].fmr_length; in ext4_getfsmap()
690 if (head->fmh_keys[0].fmr_device > handlers[i].gfd_dev) in ext4_getfsmap()
692 if (head->fmh_keys[1].fmr_device < handlers[i].gfd_dev) in ext4_getfsmap()
702 if (handlers[i].gfd_dev == head->fmh_keys[1].fmr_device) in ext4_getfsmap()
703 dkeys[1] = head->fmh_keys[1]; in ext4_getfsmap()
704 if (handlers[i].gfd_dev > head->fmh_keys[0].fmr_device) in ext4_getfsmap()
709 info.gfi_agno = -1; in ext4_getfsmap()
716 head->fmh_oflags = FMH_OF_DEV_T; in ext4_getfsmap()