Lines Matching +full:status +full:- +full:sizes

1 // SPDX-License-Identifier: GPL-2.0-or-later
33 #define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab))
63 * ocfs2_la_default_mb() - determine a default size, in megabytes of
74 * - We need to ensure our sizing is picked to leave enough space in
76 * etc). Picking default sizes which are a multiple of 4 could help
77 * - block groups are allocated in 2mb and 4mb chunks.
79 * - Likewise, we don't want to starve other nodes of bits on small
81 * default to a reasonable size (256M) on larger cluster sizes.
83 * - Some file systems can't support very large sizes - 4k and 8k in
87 * alloc maximums at various cluster sizes (4k blocksize)
107 struct super_block *sb = osb->sb; in ocfs2_la_default_mb()
109 gd_mb = ocfs2_clusters_to_megabytes(osb->sb, in ocfs2_la_default_mb()
110 8 * ocfs2_group_bitmap_size(sb, 0, osb->s_feature_incompat)); in ocfs2_la_default_mb()
114 * descriptors - 512 byte blocksize at cluster sizes lower in ocfs2_la_default_mb()
117 if ((sb->s_blocksize == 512 && osb->s_clustersize <= 8192) in ocfs2_la_default_mb()
118 || (sb->s_blocksize == 1024 && osb->s_clustersize == 4096)) in ocfs2_la_default_mb()
125 gd_mb -= 16; in ocfs2_la_default_mb()
131 * Keep window sizes down to a reasonable default in ocfs2_la_default_mb()
147 * Larger cluster group sizes actually work out pretty in ocfs2_la_default_mb()
164 megs_per_slot = osb->osb_clusters_at_boot / osb->max_slots; in ocfs2_la_default_mb()
165 megs_per_slot = ocfs2_clusters_to_megabytes(osb->sb, megs_per_slot); in ocfs2_la_default_mb()
171 la_max_mb = ocfs2_clusters_to_megabytes(osb->sb, in ocfs2_la_default_mb()
181 struct super_block *sb = osb->sb; in ocfs2_la_set_sizes()
190 if (requested_mb == -1) { in ocfs2_la_set_sizes()
191 /* No user request - use defaults */ in ocfs2_la_set_sizes()
192 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
196 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
199 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
203 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_la_set_sizes()
208 return (osb->local_alloc_state == OCFS2_LA_THROTTLED || in ocfs2_la_state_enabled()
209 osb->local_alloc_state == OCFS2_LA_ENABLED); in ocfs2_la_state_enabled()
215 if (num_clusters >= osb->local_alloc_default_bits) { in ocfs2_local_alloc_seen_free_bits()
216 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
217 if (osb->local_alloc_state == OCFS2_LA_DISABLED || in ocfs2_local_alloc_seen_free_bits()
218 osb->local_alloc_state == OCFS2_LA_THROTTLED) { in ocfs2_local_alloc_seen_free_bits()
219 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_local_alloc_seen_free_bits()
220 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_local_alloc_seen_free_bits()
222 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
231 spin_lock(&osb->osb_lock); in ocfs2_la_enable_worker()
232 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_la_enable_worker()
233 spin_unlock(&osb->osb_lock); in ocfs2_la_enable_worker()
240 * This function does semi-dirty reads of local alloc size and state!
241 * This is ok however, as the values are re-checked once under mutex.
248 spin_lock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
249 la_bits = osb->local_alloc_bits; in ocfs2_alloc_should_use_local()
264 (unsigned long long)bits, osb->local_alloc_state, la_bits, ret); in ocfs2_alloc_should_use_local()
265 spin_unlock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
271 int status = 0; in ocfs2_load_local_alloc() local
278 if (osb->local_alloc_bits == 0) in ocfs2_load_local_alloc()
281 if (osb->local_alloc_bits >= osb->bitmap_cpg) { in ocfs2_load_local_alloc()
284 osb->local_alloc_bits, (osb->bitmap_cpg - 1)); in ocfs2_load_local_alloc()
285 osb->local_alloc_bits = in ocfs2_load_local_alloc()
286 ocfs2_megabytes_to_clusters(osb->sb, in ocfs2_load_local_alloc()
292 osb->slot_num); in ocfs2_load_local_alloc()
294 status = -EINVAL; in ocfs2_load_local_alloc()
295 mlog_errno(status); in ocfs2_load_local_alloc()
299 status = ocfs2_read_inode_block_full(inode, &alloc_bh, in ocfs2_load_local_alloc()
301 if (status < 0) { in ocfs2_load_local_alloc()
302 mlog_errno(status); in ocfs2_load_local_alloc()
306 alloc = (struct ocfs2_dinode *) alloc_bh->b_data; in ocfs2_load_local_alloc()
309 if (!(le32_to_cpu(alloc->i_flags) & in ocfs2_load_local_alloc()
312 (unsigned long long)OCFS2_I(inode)->ip_blkno); in ocfs2_load_local_alloc()
313 status = -EINVAL; in ocfs2_load_local_alloc()
317 if ((la->la_size == 0) || in ocfs2_load_local_alloc()
318 (le16_to_cpu(la->la_size) > ocfs2_local_alloc_size(inode->i_sb))) { in ocfs2_load_local_alloc()
320 le16_to_cpu(la->la_size)); in ocfs2_load_local_alloc()
321 status = -EINVAL; in ocfs2_load_local_alloc()
331 || alloc->id1.bitmap1.i_used in ocfs2_load_local_alloc()
332 || alloc->id1.bitmap1.i_total in ocfs2_load_local_alloc()
333 || la->la_bm_off) { in ocfs2_load_local_alloc()
337 num_used, le32_to_cpu(alloc->id1.bitmap1.i_used), in ocfs2_load_local_alloc()
338 le32_to_cpu(alloc->id1.bitmap1.i_total), in ocfs2_load_local_alloc()
339 le32_to_cpu(OCFS2_LOCAL_ALLOC(alloc)->la_bm_off)); in ocfs2_load_local_alloc()
341 status = -EINVAL; in ocfs2_load_local_alloc()
345 osb->local_alloc_bh = alloc_bh; in ocfs2_load_local_alloc()
346 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_load_local_alloc()
349 if (status < 0) in ocfs2_load_local_alloc()
353 trace_ocfs2_load_local_alloc(osb->local_alloc_bits); in ocfs2_load_local_alloc()
355 if (status) in ocfs2_load_local_alloc()
356 mlog_errno(status); in ocfs2_load_local_alloc()
357 return status; in ocfs2_load_local_alloc()
369 int status; in ocfs2_shutdown_local_alloc() local
378 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_shutdown_local_alloc()
379 if (osb->ocfs2_wq) in ocfs2_shutdown_local_alloc()
380 flush_workqueue(osb->ocfs2_wq); in ocfs2_shutdown_local_alloc()
382 if (osb->local_alloc_state == OCFS2_LA_UNUSED) in ocfs2_shutdown_local_alloc()
388 osb->slot_num); in ocfs2_shutdown_local_alloc()
390 status = -ENOENT; in ocfs2_shutdown_local_alloc()
391 mlog_errno(status); in ocfs2_shutdown_local_alloc()
395 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_shutdown_local_alloc()
397 ocfs2_resmap_uninit(&osb->osb_la_resmap); in ocfs2_shutdown_local_alloc()
403 status = -EINVAL; in ocfs2_shutdown_local_alloc()
404 mlog_errno(status); in ocfs2_shutdown_local_alloc()
410 status = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1); in ocfs2_shutdown_local_alloc()
411 if (status < 0) { in ocfs2_shutdown_local_alloc()
412 mlog_errno(status); in ocfs2_shutdown_local_alloc()
424 bh = osb->local_alloc_bh; in ocfs2_shutdown_local_alloc()
425 alloc = (struct ocfs2_dinode *) bh->b_data; in ocfs2_shutdown_local_alloc()
427 alloc_copy = kmemdup(alloc, bh->b_size, GFP_NOFS); in ocfs2_shutdown_local_alloc()
429 status = -ENOMEM; in ocfs2_shutdown_local_alloc()
433 status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode), in ocfs2_shutdown_local_alloc()
435 if (status < 0) { in ocfs2_shutdown_local_alloc()
436 mlog_errno(status); in ocfs2_shutdown_local_alloc()
444 osb->local_alloc_bh = NULL; in ocfs2_shutdown_local_alloc()
445 osb->local_alloc_state = OCFS2_LA_UNUSED; in ocfs2_shutdown_local_alloc()
447 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_shutdown_local_alloc()
449 if (status < 0) in ocfs2_shutdown_local_alloc()
450 mlog_errno(status); in ocfs2_shutdown_local_alloc()
481 int status = 0; in ocfs2_begin_local_alloc_recovery() local
494 status = -EINVAL; in ocfs2_begin_local_alloc_recovery()
495 mlog_errno(status); in ocfs2_begin_local_alloc_recovery()
501 status = ocfs2_read_inode_block_full(inode, &alloc_bh, in ocfs2_begin_local_alloc_recovery()
503 if (status < 0) { in ocfs2_begin_local_alloc_recovery()
504 mlog_errno(status); in ocfs2_begin_local_alloc_recovery()
508 *alloc_copy = kmalloc(alloc_bh->b_size, GFP_KERNEL); in ocfs2_begin_local_alloc_recovery()
510 status = -ENOMEM; in ocfs2_begin_local_alloc_recovery()
513 memcpy((*alloc_copy), alloc_bh->b_data, alloc_bh->b_size); in ocfs2_begin_local_alloc_recovery()
515 alloc = (struct ocfs2_dinode *) alloc_bh->b_data; in ocfs2_begin_local_alloc_recovery()
518 ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check); in ocfs2_begin_local_alloc_recovery()
519 status = ocfs2_write_block(osb, alloc_bh, INODE_CACHE(inode)); in ocfs2_begin_local_alloc_recovery()
520 if (status < 0) in ocfs2_begin_local_alloc_recovery()
521 mlog_errno(status); in ocfs2_begin_local_alloc_recovery()
524 if (status < 0) { in ocfs2_begin_local_alloc_recovery()
536 if (status) in ocfs2_begin_local_alloc_recovery()
537 mlog_errno(status); in ocfs2_begin_local_alloc_recovery()
538 return status; in ocfs2_begin_local_alloc_recovery()
550 int status; in ocfs2_complete_local_alloc_recovery() local
559 status = -EINVAL; in ocfs2_complete_local_alloc_recovery()
560 mlog_errno(status); in ocfs2_complete_local_alloc_recovery()
566 status = ocfs2_inode_lock(main_bm_inode, &main_bm_bh, 1); in ocfs2_complete_local_alloc_recovery()
567 if (status < 0) { in ocfs2_complete_local_alloc_recovery()
568 mlog_errno(status); in ocfs2_complete_local_alloc_recovery()
574 status = PTR_ERR(handle); in ocfs2_complete_local_alloc_recovery()
576 mlog_errno(status); in ocfs2_complete_local_alloc_recovery()
581 handle->h_sync = 1; in ocfs2_complete_local_alloc_recovery()
583 status = ocfs2_sync_local_to_main(osb, handle, alloc, in ocfs2_complete_local_alloc_recovery()
585 if (status < 0) in ocfs2_complete_local_alloc_recovery()
586 mlog_errno(status); in ocfs2_complete_local_alloc_recovery()
601 if (!status) in ocfs2_complete_local_alloc_recovery()
603 if (status) in ocfs2_complete_local_alloc_recovery()
604 mlog_errno(status); in ocfs2_complete_local_alloc_recovery()
605 return status; in ocfs2_complete_local_alloc_recovery()
619 int status; in ocfs2_reserve_local_alloc_bits() local
629 osb->slot_num); in ocfs2_reserve_local_alloc_bits()
631 status = -ENOENT; in ocfs2_reserve_local_alloc_bits()
632 mlog_errno(status); in ocfs2_reserve_local_alloc_bits()
642 spin_lock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
644 (bits_wanted > osb->local_alloc_bits)) { in ocfs2_reserve_local_alloc_bits()
645 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
646 status = -ENOSPC; in ocfs2_reserve_local_alloc_bits()
649 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
651 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_reserve_local_alloc_bits()
654 if (le32_to_cpu(alloc->id1.bitmap1.i_used) != in ocfs2_reserve_local_alloc_bits()
656status = ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows … in ocfs2_reserve_local_alloc_bits()
657 (unsigned long long)le64_to_cpu(alloc->i_blkno), in ocfs2_reserve_local_alloc_bits()
658 le32_to_cpu(alloc->id1.bitmap1.i_used), in ocfs2_reserve_local_alloc_bits()
664 free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) - in ocfs2_reserve_local_alloc_bits()
665 le32_to_cpu(alloc->id1.bitmap1.i_used); in ocfs2_reserve_local_alloc_bits()
668 status = in ocfs2_reserve_local_alloc_bits()
670 if (status < 0) { in ocfs2_reserve_local_alloc_bits()
671 if (status != -ENOSPC) in ocfs2_reserve_local_alloc_bits()
672 mlog_errno(status); in ocfs2_reserve_local_alloc_bits()
679 * disabled the local alloc entirely. Re-check in ocfs2_reserve_local_alloc_bits()
680 * here and return -ENOSPC if necessary. in ocfs2_reserve_local_alloc_bits()
682 status = -ENOSPC; in ocfs2_reserve_local_alloc_bits()
686 free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) - in ocfs2_reserve_local_alloc_bits()
687 le32_to_cpu(alloc->id1.bitmap1.i_used); in ocfs2_reserve_local_alloc_bits()
692 ac->ac_inode = local_alloc_inode; in ocfs2_reserve_local_alloc_bits()
694 ac->ac_alloc_slot = osb->slot_num; in ocfs2_reserve_local_alloc_bits()
695 ac->ac_which = OCFS2_AC_USE_LOCAL; in ocfs2_reserve_local_alloc_bits()
696 get_bh(osb->local_alloc_bh); in ocfs2_reserve_local_alloc_bits()
697 ac->ac_bh = osb->local_alloc_bh; in ocfs2_reserve_local_alloc_bits()
698 status = 0; in ocfs2_reserve_local_alloc_bits()
700 if (status < 0 && local_alloc_inode) { in ocfs2_reserve_local_alloc_bits()
706 (unsigned long long)ac->ac_max_block, in ocfs2_reserve_local_alloc_bits()
707 bits_wanted, osb->slot_num, status); in ocfs2_reserve_local_alloc_bits()
709 if (status) in ocfs2_reserve_local_alloc_bits()
710 mlog_errno(status); in ocfs2_reserve_local_alloc_bits()
711 return status; in ocfs2_reserve_local_alloc_bits()
721 int status, start; in ocfs2_claim_local_alloc_bits() local
727 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); in ocfs2_claim_local_alloc_bits()
729 local_alloc_inode = ac->ac_inode; in ocfs2_claim_local_alloc_bits()
730 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_claim_local_alloc_bits()
734 ac->ac_resv); in ocfs2_claim_local_alloc_bits()
735 if (start == -1) { in ocfs2_claim_local_alloc_bits()
737 status = -ENOSPC; in ocfs2_claim_local_alloc_bits()
738 mlog_errno(status); in ocfs2_claim_local_alloc_bits()
742 bitmap = la->la_bitmap; in ocfs2_claim_local_alloc_bits()
743 *bit_off = le32_to_cpu(la->la_bm_off) + start; in ocfs2_claim_local_alloc_bits()
746 status = ocfs2_journal_access_di(handle, in ocfs2_claim_local_alloc_bits()
748 osb->local_alloc_bh, in ocfs2_claim_local_alloc_bits()
750 if (status < 0) { in ocfs2_claim_local_alloc_bits()
751 mlog_errno(status); in ocfs2_claim_local_alloc_bits()
755 ocfs2_resmap_claimed_bits(&osb->osb_la_resmap, ac->ac_resv, start, in ocfs2_claim_local_alloc_bits()
758 while(bits_wanted--) in ocfs2_claim_local_alloc_bits()
761 le32_add_cpu(&alloc->id1.bitmap1.i_used, *num_bits); in ocfs2_claim_local_alloc_bits()
762 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_claim_local_alloc_bits()
765 if (status) in ocfs2_claim_local_alloc_bits()
766 mlog_errno(status); in ocfs2_claim_local_alloc_bits()
767 return status; in ocfs2_claim_local_alloc_bits()
776 int status, start; in ocfs2_free_local_alloc_bits() local
783 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); in ocfs2_free_local_alloc_bits()
785 local_alloc_inode = ac->ac_inode; in ocfs2_free_local_alloc_bits()
786 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_free_local_alloc_bits()
789 bitmap = la->la_bitmap; in ocfs2_free_local_alloc_bits()
790 start = bit_off - le32_to_cpu(la->la_bm_off); in ocfs2_free_local_alloc_bits()
793 status = ocfs2_journal_access_di(handle, in ocfs2_free_local_alloc_bits()
795 osb->local_alloc_bh, in ocfs2_free_local_alloc_bits()
797 if (status < 0) { in ocfs2_free_local_alloc_bits()
798 mlog_errno(status); in ocfs2_free_local_alloc_bits()
802 while (clear_bits--) in ocfs2_free_local_alloc_bits()
805 le32_add_cpu(&alloc->id1.bitmap1.i_used, -num_bits); in ocfs2_free_local_alloc_bits()
806 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_free_local_alloc_bits()
809 return status; in ocfs2_free_local_alloc_bits()
817 count = memweight(la->la_bitmap, le16_to_cpu(la->la_size)); in ocfs2_local_alloc_count_bits()
832 struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; in ocfs2_local_alloc_find_clear_bits()
834 if (!alloc->id1.bitmap1.i_total) { in ocfs2_local_alloc_find_clear_bits()
835 bitoff = -1; in ocfs2_local_alloc_find_clear_bits()
857 BUG_ON(osb->osb_resv_level != 0); in ocfs2_local_alloc_find_clear_bits()
863 bitmap = OCFS2_LOCAL_ALLOC(alloc)->la_bitmap; in ocfs2_local_alloc_find_clear_bits()
866 left = le32_to_cpu(alloc->id1.bitmap1.i_total); in ocfs2_local_alloc_find_clear_bits()
890 bitoff = startoff - numfound; in ocfs2_local_alloc_find_clear_bits()
892 bitoff = -1; in ocfs2_local_alloc_find_clear_bits()
899 le32_to_cpu(alloc->id1.bitmap1.i_total), in ocfs2_local_alloc_find_clear_bits()
910 alloc->id1.bitmap1.i_total = 0; in ocfs2_clear_local_alloc()
911 alloc->id1.bitmap1.i_used = 0; in ocfs2_clear_local_alloc()
912 la->la_bm_off = 0; in ocfs2_clear_local_alloc()
913 for(i = 0; i < le16_to_cpu(la->la_size); i++) in ocfs2_clear_local_alloc()
914 la->la_bitmap[i] = 0; in ocfs2_clear_local_alloc()
924 while(tmp--) {
939 * assumes you've already locked the main bitmap -- the bitmap inode
948 int status = 0; in ocfs2_sync_local_to_main() local
956 le32_to_cpu(alloc->id1.bitmap1.i_total), in ocfs2_sync_local_to_main()
957 le32_to_cpu(alloc->id1.bitmap1.i_used)); in ocfs2_sync_local_to_main()
959 if (!alloc->id1.bitmap1.i_total) { in ocfs2_sync_local_to_main()
963 if (le32_to_cpu(alloc->id1.bitmap1.i_used) == in ocfs2_sync_local_to_main()
964 le32_to_cpu(alloc->id1.bitmap1.i_total)) { in ocfs2_sync_local_to_main()
968 la_start_blk = ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
969 le32_to_cpu(la->la_bm_off)); in ocfs2_sync_local_to_main()
970 bitmap = la->la_bitmap; in ocfs2_sync_local_to_main()
972 left = le32_to_cpu(alloc->id1.bitmap1.i_total); in ocfs2_sync_local_to_main()
983 ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
984 start - count); in ocfs2_sync_local_to_main()
987 count, start - count, in ocfs2_sync_local_to_main()
991 status = ocfs2_release_clusters(handle, in ocfs2_sync_local_to_main()
995 if (status < 0) { in ocfs2_sync_local_to_main()
996 mlog_errno(status); in ocfs2_sync_local_to_main()
1008 if (status) in ocfs2_sync_local_to_main()
1009 mlog_errno(status); in ocfs2_sync_local_to_main()
1010 return status; in ocfs2_sync_local_to_main()
1041 spin_lock(&osb->osb_lock); in ocfs2_recalc_la_window()
1042 if (osb->local_alloc_state == OCFS2_LA_DISABLED) { in ocfs2_recalc_la_window()
1043 WARN_ON_ONCE(osb->local_alloc_state == OCFS2_LA_DISABLED); in ocfs2_recalc_la_window()
1057 bits = osb->local_alloc_bits >> 1; in ocfs2_recalc_la_window()
1058 if (bits > ocfs2_megabytes_to_clusters(osb->sb, 1)) { in ocfs2_recalc_la_window()
1066 osb->local_alloc_state = OCFS2_LA_THROTTLED; in ocfs2_recalc_la_window()
1067 osb->local_alloc_bits = bits; in ocfs2_recalc_la_window()
1069 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_recalc_la_window()
1071 queue_delayed_work(osb->ocfs2_wq, &osb->la_enable_wq, in ocfs2_recalc_la_window()
1082 if (osb->local_alloc_state != OCFS2_LA_THROTTLED) in ocfs2_recalc_la_window()
1083 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_recalc_la_window()
1086 state = osb->local_alloc_state; in ocfs2_recalc_la_window()
1087 spin_unlock(&osb->osb_lock); in ocfs2_recalc_la_window()
1097 int status; in ocfs2_local_alloc_reserve_for_window() local
1101 status = -ENOMEM; in ocfs2_local_alloc_reserve_for_window()
1102 mlog_errno(status); in ocfs2_local_alloc_reserve_for_window()
1107 (*ac)->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_reserve_for_window()
1108 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_local_alloc_reserve_for_window()
1109 if (status == -ENOSPC) { in ocfs2_local_alloc_reserve_for_window()
1118 if (status < 0) { in ocfs2_local_alloc_reserve_for_window()
1119 mlog_errno(status); in ocfs2_local_alloc_reserve_for_window()
1123 *bitmap_inode = (*ac)->ac_inode; in ocfs2_local_alloc_reserve_for_window()
1125 *bitmap_bh = (*ac)->ac_bh; in ocfs2_local_alloc_reserve_for_window()
1127 status = 0; in ocfs2_local_alloc_reserve_for_window()
1129 if ((status < 0) && *ac) { in ocfs2_local_alloc_reserve_for_window()
1134 if (status) in ocfs2_local_alloc_reserve_for_window()
1135 mlog_errno(status); in ocfs2_local_alloc_reserve_for_window()
1136 return status; in ocfs2_local_alloc_reserve_for_window()
1146 int status = 0; in ocfs2_local_alloc_new_window() local
1151 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_new_window()
1155 le32_to_cpu(alloc->id1.bitmap1.i_total), in ocfs2_local_alloc_new_window()
1156 osb->local_alloc_bits); in ocfs2_local_alloc_new_window()
1159 * cluster group. We'll re-record the group used this pass in ocfs2_local_alloc_new_window()
1161 ac->ac_last_group = osb->la_last_gd; in ocfs2_local_alloc_new_window()
1166 status = ocfs2_claim_clusters(handle, ac, osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1168 if (status == -ENOSPC) { in ocfs2_local_alloc_new_window()
1173 * transaction can't give us access to. --Mark in ocfs2_local_alloc_new_window()
1179 ac->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_new_window()
1180 status = ocfs2_claim_clusters(handle, ac, in ocfs2_local_alloc_new_window()
1181 osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1184 if (status == -ENOSPC) in ocfs2_local_alloc_new_window()
1188 * request - it's entirely possible that the allocator in ocfs2_local_alloc_new_window()
1191 if (status == 0) { in ocfs2_local_alloc_new_window()
1192 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1193 osb->local_alloc_bits = cluster_count; in ocfs2_local_alloc_new_window()
1194 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1197 if (status < 0) { in ocfs2_local_alloc_new_window()
1198 if (status != -ENOSPC) in ocfs2_local_alloc_new_window()
1199 mlog_errno(status); in ocfs2_local_alloc_new_window()
1203 osb->la_last_gd = ac->ac_last_group; in ocfs2_local_alloc_new_window()
1205 la->la_bm_off = cpu_to_le32(cluster_off); in ocfs2_local_alloc_new_window()
1206 alloc->id1.bitmap1.i_total = cpu_to_le32(cluster_count); in ocfs2_local_alloc_new_window()
1208 * we don't have to get all contiguous -- but we'll have to in ocfs2_local_alloc_new_window()
1211 alloc->id1.bitmap1.i_used = 0; in ocfs2_local_alloc_new_window()
1212 memset(OCFS2_LOCAL_ALLOC(alloc)->la_bitmap, 0, in ocfs2_local_alloc_new_window()
1213 le16_to_cpu(la->la_size)); in ocfs2_local_alloc_new_window()
1215 ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, in ocfs2_local_alloc_new_window()
1216 OCFS2_LOCAL_ALLOC(alloc)->la_bitmap); in ocfs2_local_alloc_new_window()
1219 le32_to_cpu(OCFS2_LOCAL_ALLOC(alloc)->la_bm_off), in ocfs2_local_alloc_new_window()
1220 le32_to_cpu(alloc->id1.bitmap1.i_total)); in ocfs2_local_alloc_new_window()
1223 if (status) in ocfs2_local_alloc_new_window()
1224 mlog_errno(status); in ocfs2_local_alloc_new_window()
1225 return status; in ocfs2_local_alloc_new_window()
1233 int status = 0; in ocfs2_local_alloc_slide_window() local
1244 status = ocfs2_local_alloc_reserve_for_window(osb, in ocfs2_local_alloc_slide_window()
1248 if (status < 0) { in ocfs2_local_alloc_slide_window()
1249 if (status != -ENOSPC) in ocfs2_local_alloc_slide_window()
1250 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1256 status = PTR_ERR(handle); in ocfs2_local_alloc_slide_window()
1258 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1262 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_slide_window()
1269 alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS); in ocfs2_local_alloc_slide_window()
1271 status = -ENOMEM; in ocfs2_local_alloc_slide_window()
1272 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1276 status = ocfs2_journal_access_di(handle, in ocfs2_local_alloc_slide_window()
1278 osb->local_alloc_bh, in ocfs2_local_alloc_slide_window()
1280 if (status < 0) { in ocfs2_local_alloc_slide_window()
1281 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1286 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_local_alloc_slide_window()
1288 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_local_alloc_slide_window()
1290 if (status < 0) { in ocfs2_local_alloc_slide_window()
1291 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1295 status = ocfs2_local_alloc_new_window(osb, handle, ac); in ocfs2_local_alloc_slide_window()
1296 if (status < 0) { in ocfs2_local_alloc_slide_window()
1297 if (status != -ENOSPC) in ocfs2_local_alloc_slide_window()
1298 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1302 atomic_inc(&osb->alloc_stats.moves); in ocfs2_local_alloc_slide_window()
1316 if (status) in ocfs2_local_alloc_slide_window()
1317 mlog_errno(status); in ocfs2_local_alloc_slide_window()
1318 return status; in ocfs2_local_alloc_slide_window()