Lines Matching refs:group

36  *   - track min/max extents in each group for better group selection
47 * group preallocation or inode preallocation depending on the size of
51 * select to use the group preallocation. The default value of
56 * The main motivation for having small file use group preallocation is to
79 * have the group allocation flag set then we look at the locality group
84 * The reason for having a per cpu locality group is to reduce the contention
87 * The locality group prealloc space is used looking at whether we have
90 * If we can't allocate blocks via inode prealloc or/and locality group
96 * each group is loaded via ext4_mb_load_buddy. The information involve
101 * [ group 0 bitmap][ group 0 buddy] [group 1][ group 1]...
104 * one block each for bitmap and buddy information. So for each group we
121 * we are doing a group prealloc we try to normalize the request to
127 * stripe=<value> option the group prealloc request is normalized to the
143 * not, we search in the specific group using bitmap for best extents. The
148 * the group specified as the goal value in allocation context via
149 * ac_g_ex. Each group is first checked based on the criteria whether it
175 * - locality group
176 * assigned to specific locality group which does not translate to
177 * permanent set of inodes: inode can join and leave group. space
200 * - use locality group PA on-disk += N; PA -= N
201 * - discard locality group PA buddy -= PA; PA = 0
222 * until PA is linked to allocation group to avoid concurrent buddy init
228 * - use locality group PA
230 * - discard locality group PA
237 * - use locality group PA
239 * - discard locality group PA
246 * - use locality group PA
248 * - discard locality group PA
268 * load group
271 * release group
274 * find proper PA (per-inode or group)
275 * load group
277 * release group
281 * load group
283 * release group
285 * - discard preallocations in group:
289 * load group
290 * remove PA from object (inode or locality group)
300 * - bitlock on a group (group)
307 * group
314 * group
318 * group
321 * - discard all for given object (inode, locality group):
324 * group
326 * - discard all for given group:
327 * group
329 * group
350 ext4_group_t group);
352 ext4_group_t group);
530 "corruption in group %u "
541 struct ext4_group_info *grp, ext4_group_t group)
549 bh = ext4_read_block_bitmap(sb, group);
582 struct ext4_group_info *grp, ext4_group_t group)
752 * group.
773 void *buddy, void *bitmap, ext4_group_t group,
805 ext4_grp_locked_error(sb, group, 0, 0,
810 * If we intend to continue, we consider group descriptor
814 ext4_mark_group_bitmap_corrupted(sb, group,
845 * for convenience. The information regarding each group
851 * [ group 0 bitmap][ group 0 buddy] [group 1][ group 1]...
855 * So for each group we take up 2 blocks. A page can
860 * Locking note: This routine takes the block group lock of all groups
872 ext4_group_t first_group, group;
908 for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
909 if (group >= ngroups)
912 grinfo = ext4_get_group_info(sb, group);
917 * which added some new uninitialized group info structs, so
925 bh[i] = ext4_read_block_bitmap_nowait(sb, group, false);
931 mb_debug(sb, "read bitmap for group %u\n", group);
935 for (i = 0, group = first_group; i < groups_per_page; i++, group++) {
940 err2 = ext4_wait_block_bitmap(sb, group, bh[i]);
947 group = (first_block + i) >> 1;
948 if (group >= ngroups)
951 if (!bh[group - first_group])
955 if (!buffer_verified(bh[group - first_group]))
962 * particular group in the format specified
967 bitmap = bh[group - first_group]->b_data;
976 mb_debug(sb, "put buddy for group %u in page %lu/%x\n",
977 group, page->index, i * blocksize);
978 trace_ext4_mb_buddy_bitmap_load(sb, group);
979 grinfo = ext4_get_group_info(sb, group);
989 * incore got set to the group block bitmap below
991 ext4_lock_group(sb, group);
994 ext4_mb_generate_buddy(sb, data, incore, group, grinfo);
995 ext4_unlock_group(sb, group);
1000 mb_debug(sb, "put bitmap for group %u in page %lu/%x\n",
1001 group, page->index, i * blocksize);
1002 trace_ext4_mb_bitmap_load(sb, group);
1005 ext4_lock_group(sb, group);
1009 ext4_mb_generate_from_pa(sb, data, group);
1010 ext4_mb_generate_from_freelist(sb, data, group);
1011 ext4_unlock_group(sb, group);
1038 ext4_group_t group, struct ext4_buddy *e4b, gfp_t gfp)
1052 * So for each group we need two blocks.
1054 block = group * 2;
1093 * block group lock of all groups for this page; do not hold the BG lock when
1097 int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
1106 mb_debug(sb, "init group %u\n", group);
1107 this_grp = ext4_get_group_info(sb, group);
1113 * page which map to the group from which we are already
1120 ret = ext4_mb_get_buddy_page_lock(sb, group, &e4b, gfp);
1123 * somebody initialized the group
1163 * block group lock of all groups for this page; do not hold the BG lock when
1167 ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
1181 mb_debug(sb, "load group %u\n", group);
1184 grp = ext4_get_group_info(sb, group);
1191 e4b->bd_group = group;
1197 * we need full data about the group
1200 ret = ext4_mb_init_group(sb, group, gfp);
1208 * So for each group we need two blocks.
1210 block = group * 2;
1305 static int ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
1308 return ext4_mb_load_buddy_gfp(sb, group, e4b, GFP_NOFS);
1434 * Releasing entire group is all about clearing
1490 /* Don't bother if the block group is corrupt. */
1702 * Must be called under group lock!
1728 * group until we update the bitmap. That would mean we
1867 ext4_group_t group = ex.fe_group;
1872 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
1876 ext4_lock_group(ac->ac_sb, group);
1888 ext4_unlock_group(ac->ac_sb, group);
1898 ext4_group_t group = ac->ac_g_ex.fe_group;
1902 struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
1912 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
1916 ext4_lock_group(ac->ac_sb, group);
1953 ext4_unlock_group(ac->ac_sb, group);
2010 * The routine scans the group and measures all found extents.
2012 * free blocks in the group, so the routine can know upper limit.
2036 * free blocks even though group info says we
2041 "group info. But bitmap says 0",
2054 "group info. But got %d blocks",
2094 /* find first stripe-aligned block in group */
2118 * Returns either 1 or 0 indicating that the group is either suitable
2122 ext4_group_t group, int cr)
2126 struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
2148 ((group % flex_size) == 0))
2184 ext4_group_t group, int cr)
2186 struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
2198 ext4_lock_group(sb, group);
2207 ext4_unlock_group(sb, group);
2212 ext4_get_group_desc(sb, group, NULL);
2218 * we never skip the first block group in a flex_bg,
2221 * in the first block group in the flex_bg if possible.
2225 ((group & ((1 << sbi->s_log_groups_per_flex) - 1)) != 0)) &&
2229 ret = ext4_mb_init_group(sb, group, GFP_NOFS);
2235 ext4_lock_group(sb, group);
2236 ret = ext4_mb_good_group(ac, group, cr);
2239 ext4_unlock_group(sb, group);
2244 * Start prefetching @nr block bitmaps starting at @group.
2245 * Return the next group which needs to be prefetched.
2247 ext4_group_t ext4_mb_prefetch(struct super_block *sb, ext4_group_t group,
2256 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group,
2258 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
2272 bh = ext4_read_block_bitmap_nowait(sb, group, true);
2279 if (++group >= ngroups)
2280 group = 0;
2283 return group;
2298 void ext4_mb_prefetch_fini(struct super_block *sb, ext4_group_t group,
2302 struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group,
2304 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
2306 if (!group)
2307 group = ext4_get_groups_count(sb);
2308 group--;
2309 grp = ext4_get_group_info(sb, group);
2315 if (ext4_mb_init_group(sb, group, GFP_NOFS))
2324 ext4_group_t prefetch_grp = 0, ngroups, group, i;
2392 * searching for the right group start
2395 group = ac->ac_g_ex.fe_group;
2396 prefetch_grp = group;
2398 for (i = 0; i < ngroups; group++, i++) {
2403 * files makes group > ngroups possible on first loop.
2405 if (group >= ngroups)
2406 group = 0;
2414 if ((prefetch_grp == group) &&
2422 nr -= group & (nr - 1);
2425 prefetch_grp = ext4_mb_prefetch(sb, group,
2432 ret = ext4_mb_good_group_nolock(ac, group, cr);
2439 err = ext4_mb_load_buddy(sb, group, &e4b);
2443 ext4_lock_group(sb, group);
2447 * block group
2449 ret = ext4_mb_good_group(ac, group, cr);
2451 ext4_unlock_group(sb, group);
2465 ext4_unlock_group(sb, group);
2490 mb_debug(sb, "lost chunk, group: %u, start: %d, len: %d, lost: %d\n",
2523 ext4_group_t group;
2527 group = *pos + 1;
2528 return (void *) ((unsigned long) group);
2534 ext4_group_t group;
2539 group = *pos + 1;
2540 return (void *) ((unsigned long) group);
2546 ext4_group_t group = (ext4_group_t) ((unsigned long) v);
2559 group--;
2560 if (group == 0)
2561 seq_puts(seq, "#group: free frags first ["
2568 grinfo = ext4_get_group_info(sb, group);
2571 /* Load the group info in memory only if not already loaded. */
2573 err = ext4_mb_load_buddy(sb, group, &e4b);
2575 seq_printf(seq, "#%-5u: I/O error\n", group);
2586 seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
2695 ext4_msg(sb, KERN_ERR, "can't allocate buddy meta group");
2713 /* Create and initialize ext4_group_info data for the given group. */
2714 int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group,
2719 int idx = group >> EXT4_DESC_PER_BLOCK_BITS(sb);
2725 * First check if this group is the first of a reserved block.
2729 if (group % EXT4_DESC_PER_BLOCK(sb) == 0) {
2735 "for a buddy group");
2744 i = group & (EXT4_DESC_PER_BLOCK(sb) - 1);
2761 ext4_free_clusters_after_init(sb, group, desc);
2772 mb_group_bb_bitmap_alloc(sb, meta_group_info[i], group);
2777 if (group % EXT4_DESC_PER_BLOCK(sb) == 0) {
2827 /* a single flex group is supposed to be read by a single IO.
2832 ext4_msg(sb, KERN_ERR, "too many log groups per flexible block group");
2982 * The default group preallocation is 512, which for 4k block
2985 * is 1 megabyte, then group preallocation size becomes half a
2987 * group pralloc size for cluster sizes up to 64k, and after
2988 * that, we will force a minimum group preallocation size of
3040 /* need to called with the ext4 group lock held */
3151 mb_debug(sb, "gonna free %u blocks in group %u (0x%p):",
3167 /* Take it out of per group rb tree */
3172 * Clear the trimmed flag for the group so that the next
3181 /* No more items in the per group rb tree
3229 " group:%d block:%d count:%d failed"
3327 ext4_debug("using block group %u(%d)\n", ac->ac_b_ex.fe_group,
3418 ext4_group_t group;
3425 ext4_get_group_no_and_offset(sb, block, &group, &blkoff);
3428 * Check to see if we are freeing blocks across a group
3431 * span across more than one group. In that case we need to
3432 * get the corresponding group metadata to work with.
3439 bitmap_bh = ext4_read_block_bitmap(sb, group);
3447 gdp = ext4_get_group_desc(sb, group, &gdp_bh);
3451 ext4_lock_group(sb, group);
3467 ext4_free_clusters_after_init(sb, group, gdp));
3475 ext4_block_bitmap_csum_set(sb, group, gdp, bitmap_bh);
3476 ext4_group_desc_csum_set(sb, group, gdp);
3478 ext4_unlock_group(sb, group);
3481 ext4_group_t flex_group = ext4_flex_group(sbi, group);
3512 * here we normalize request for locality group
3518 * XXX: should we try to preallocate more than the group has now?
3527 mb_debug(sb, "goal %u blocks for locality group\n", ac->ac_g_ex.fe_len);
3622 * alignment may be larger than group size. Make sure the
3623 * alignment does not move allocation to a different group which
3835 * use blocks preallocated to locality group
3850 * possible race when the group is being loaded concurrently
3855 mb_debug(ac->ac_sb, "use %u/%u from group pa %p\n",
3935 /* can we use group allocation? */
3939 /* inode may have no locality group for some reason */
3977 * the function goes through all block freed in the group
3980 * Need to be called with the ext4 group lock held
3983 ext4_group_t group)
3989 grp = ext4_get_group_info(sb, group);
4003 * the function goes through all preallocation in this group and marks them
4005 * Need to be called with ext4 group lock held
4009 ext4_group_t group)
4011 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
4022 /* all form of preallocation discards first load group,
4039 BUG_ON(groupnr != group);
4043 mb_debug(sb, "preallocated %d for group %u\n", preallocated, group);
4103 * If doing group-based preallocation, pa_pstart may be in the
4104 * next group when pa is used up
4118 * drop PA from group
4237 * creates new preallocated space for locality group inodes belongs to
4269 mb_debug(sb, "new group pa %p: %llu/%d for %u\n", pa, pa->pa_pstart,
4304 * @pa must be unlinked from inode and group lists, so that
4306 * the caller MUST hold group/inode locks.
4317 ext4_group_t group;
4323 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
4325 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
4333 mb_debug(sb, "free preallocated %u/%u in group %u\n",
4334 (unsigned) ext4_group_first_block_no(sb, group) + bit,
4335 (unsigned) next - bit, (unsigned) group);
4338 trace_ext4_mballoc_discard(sb, NULL, group, bit, next - bit);
4351 ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u",
4368 ext4_group_t group;
4373 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
4374 if (unlikely(group != e4b->bd_group && pa->pa_len != 0)) {
4375 ext4_warning(sb, "bad group: expected %u, group %u, pa_start %llu",
4376 e4b->bd_group, group, pa->pa_pstart);
4381 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
4387 * releases all preallocations in given group
4397 ext4_group_t group, int *busy)
4399 struct ext4_group_info *grp = ext4_get_group_info(sb, group);
4409 mb_debug(sb, "discard preallocation for group %u\n", group);
4413 bitmap_bh = ext4_read_block_bitmap(sb, group);
4418 err, group);
4422 err = ext4_mb_load_buddy(sb, group, &e4b);
4425 err, group);
4431 ext4_lock_group(sb, group);
4463 /* remove from object (inode or locality group) */
4477 ext4_unlock_group(sb, group);
4481 mb_debug(sb, "discarded (%d) blocks preallocated for group %u bb_free (%d)\n",
4482 free, group, grp->bb_free);
4501 ext4_group_t group = 0;
4576 group = ext4_get_group_number(sb, pa->pa_pstart);
4578 err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
4582 err, group);
4586 bitmap_bh = ext4_read_block_bitmap(sb, group);
4590 err, group);
4595 ext4_lock_group(sb, group);
4598 ext4_unlock_group(sb, group);
4709 * We use locality group preallocation for small size file. The size of the
4742 /* don't use group allocation for large files */
4751 * locality group prealloc space are per cpu. The reason for having
4752 * per cpu locality group is to reduce the contention between block
4757 /* we're going to use group allocation */
4760 /* serialize all allocations in the group */
4771 ext4_group_t group;
4776 /* we can't allocate > group size */
4788 ext4_get_group_no_and_offset(sb, goal, &group, &block);
4796 ac->ac_o_ex.fe_group = group;
4803 * locality group. this is a policy, actually */
4822 ext4_group_t group = 0;
4827 mb_debug(sb, "discard locality group preallocation\n");
4875 group = ext4_get_group_number(sb, pa->pa_pstart);
4876 err = ext4_mb_load_buddy_gfp(sb, group, &e4b,
4880 err, group);
4883 ext4_lock_group(sb, group);
4886 ext4_unlock_group(sb, group);
5233 * AND the blocks are associated with the same group.
5263 ext4_group_t group = e4b->bd_group;
5297 ext4_grp_locked_error(sb, group, 0,
5298 ext4_group_first_block_no(sb, group) +
5341 ext4_group_t group;
5354 ext4_get_group_no_and_offset(sb, goal, &group, &blkoff);
5355 for (; group < ext4_get_groups_count(sb); group++) {
5356 bitmap_bh = ext4_read_block_bitmap(sb, group);
5364 max(ext4_group_first_block_no(sb, group), goal),
5372 ext4_group_first_block_no(sb, group) + i)) {
5382 if (group >= ext4_get_groups_count(sb) || i >= max) {
5387 block = ext4_group_first_block_no(sb, group) + i;
5401 ext4_group_t group;
5405 ext4_get_group_no_and_offset(sb, block, &group, &blkoff);
5406 bitmap_bh = ext4_read_block_bitmap(sb, group);
5412 gdp = ext4_get_group_desc(sb, group, &gdp_bh);
5427 ext4_block_bitmap_csum_set(sb, group, gdp, bitmap_bh);
5428 ext4_group_desc_csum_set(sb, group, gdp);
5483 * Check to see if we are freeing blocks across a group
5569 * with group lock held. generate_buddy look at
5570 * them with group lock_held
5577 " group:%u block:%d count:%lu failed"
5619 /* And the group descriptor block */
5620 BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
5743 * ext4_group_add_blocks() -- Add given blocks to an existing group
5746 * @block: start physical block to add to the block group
5775 * Check to see if we are freeing blocks across a group
5779 ext4_warning(sb, "too many blocks added to group %u",
5838 * with group lock held. generate_buddy look at
5839 * them with group lock_held
5866 /* And the group descriptor block */
5867 BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
5879 * ext4_trim_extent -- function to TRIM one single free extent in the group
5881 * @start: starting block of the free extent in the alloc. group
5883 * @e4b: ext4 buddy for the group
5885 * Trim "count" blocks starting at "start" in the "group". To assure that no
5887 * be called with under the group lock.
5895 ext4_group_t group = e4b->bd_group;
5898 trace_ext4_trim_extent(sb, group, start, count);
5900 assert_spin_locked(ext4_group_lock_ptr(sb, group));
5903 ex.fe_group = group;
5911 ext4_unlock_group(sb, group);
5912 ret = ext4_issue_discard(sb, group, start, count, NULL);
5913 ext4_lock_group(sb, group);
5994 * ext4_trim_all_free -- function to trim all free space in alloc. group
5996 * @group: group to be trimmed
5997 * @start: first group block to examine
5998 * @max: last group block to examine
6001 * ext4_trim_all_free walks through group's buddy bitmap searching for free
6006 * ext4_trim_all_free walks through group's block bitmap searching for free
6007 * extents. When the free extent is found, mark it as used in group buddy
6009 * the group buddy bitmap. This is done until whole group is scanned.
6012 ext4_trim_all_free(struct super_block *sb, ext4_group_t group,
6019 trace_ext4_trim_all_free(sb, group, start, max);
6021 ret = ext4_mb_load_buddy(sb, group, &e4b);
6024 ret, group);
6028 ext4_lock_group(sb, group);
6036 ext4_unlock_group(sb, group);
6039 ext4_debug("trimmed %d blocks in the group %d\n",
6040 ret, group);
6054 * start to start+len. For each such a group ext4_trim_all_free function
6061 ext4_group_t group, first_group, last_group;
6092 /* Determine first and last group to examine based on start and end */
6098 /* end now represents the last cluster to discard in this group */
6101 for (group = first_group; group <= last_group; group++) {
6104 grp = ext4_get_group_info(sb, group);
6109 ret = ext4_mb_init_group(sb, group, GFP_NOFS);
6117 * change it for the last group, note that last_cluster is
6120 if (group == last_group)
6123 cnt = ext4_trim_all_free(sb, group, first_cluster,
6133 * For every group except the first one, we are sure
6147 /* Iterate all the free extents in the group. */
6151 ext4_group_t group,
6162 error = ext4_mb_load_buddy(sb, group, &e4b);
6167 ext4_lock_group(sb, group);
6179 ext4_unlock_group(sb, group);
6180 error = formatter(sb, group, start, next - start, priv);
6183 ext4_lock_group(sb, group);
6188 ext4_unlock_group(sb, group);