• Home
  • Raw
  • Download

Lines Matching refs:space_info

175 	struct list_head *head = &info->space_info;  in btrfs_clear_space_info_full()
185 struct btrfs_space_info *space_info; in create_space_info() local
189 space_info = kzalloc(sizeof(*space_info), GFP_NOFS); in create_space_info()
190 if (!space_info) in create_space_info()
193 ret = percpu_counter_init(&space_info->total_bytes_pinned, 0, in create_space_info()
196 kfree(space_info); in create_space_info()
201 INIT_LIST_HEAD(&space_info->block_groups[i]); in create_space_info()
202 init_rwsem(&space_info->groups_sem); in create_space_info()
203 spin_lock_init(&space_info->lock); in create_space_info()
204 space_info->flags = flags & BTRFS_BLOCK_GROUP_TYPE_MASK; in create_space_info()
205 space_info->force_alloc = CHUNK_ALLOC_NO_FORCE; in create_space_info()
206 INIT_LIST_HEAD(&space_info->ro_bgs); in create_space_info()
207 INIT_LIST_HEAD(&space_info->tickets); in create_space_info()
208 INIT_LIST_HEAD(&space_info->priority_tickets); in create_space_info()
210 ret = btrfs_sysfs_add_space_info_type(info, space_info); in create_space_info()
214 list_add(&space_info->list, &info->space_info); in create_space_info()
216 info->data_sinfo = space_info; in create_space_info()
261 struct btrfs_space_info **space_info) in btrfs_update_space_info() argument
280 *space_info = found; in btrfs_update_space_info()
286 struct list_head *head = &info->space_info; in btrfs_find_space_info()
299 struct btrfs_space_info *space_info, in calc_available_free_space() argument
306 if (space_info->flags & BTRFS_BLOCK_GROUP_SYSTEM) in calc_available_free_space()
335 struct btrfs_space_info *space_info, u64 bytes, in btrfs_can_overcommit() argument
342 if (space_info->flags & BTRFS_BLOCK_GROUP_DATA) in btrfs_can_overcommit()
345 used = btrfs_space_info_used(space_info, true); in btrfs_can_overcommit()
346 avail = calc_available_free_space(fs_info, space_info, flush); in btrfs_can_overcommit()
348 if (used + bytes < space_info->total_bytes + avail) in btrfs_can_overcommit()
353 static void remove_ticket(struct btrfs_space_info *space_info, in remove_ticket() argument
358 ASSERT(space_info->reclaim_size >= ticket->bytes); in remove_ticket()
359 space_info->reclaim_size -= ticket->bytes; in remove_ticket()
368 struct btrfs_space_info *space_info) in btrfs_try_granting_tickets() argument
373 lockdep_assert_held(&space_info->lock); in btrfs_try_granting_tickets()
375 head = &space_info->priority_tickets; in btrfs_try_granting_tickets()
379 u64 used = btrfs_space_info_used(space_info, true); in btrfs_try_granting_tickets()
384 if ((used + ticket->bytes <= space_info->total_bytes) || in btrfs_try_granting_tickets()
385 btrfs_can_overcommit(fs_info, space_info, ticket->bytes, in btrfs_try_granting_tickets()
388 space_info, in btrfs_try_granting_tickets()
390 remove_ticket(space_info, ticket); in btrfs_try_granting_tickets()
392 space_info->tickets_id++; in btrfs_try_granting_tickets()
399 if (head == &space_info->priority_tickets) { in btrfs_try_granting_tickets()
400 head = &space_info->tickets; in btrfs_try_granting_tickets()
488 struct btrfs_space_info *space_info, in shrink_delalloc() argument
549 spin_lock(&space_info->lock); in shrink_delalloc()
550 if (list_empty(&space_info->tickets) && in shrink_delalloc()
551 list_empty(&space_info->priority_tickets)) { in shrink_delalloc()
552 spin_unlock(&space_info->lock); in shrink_delalloc()
555 spin_unlock(&space_info->lock); in shrink_delalloc()
574 struct btrfs_space_info *space_info) in may_commit_transaction() argument
589 spin_lock(&space_info->lock); in may_commit_transaction()
590 cur_free_bytes = btrfs_space_info_used(space_info, true); in may_commit_transaction()
591 if (cur_free_bytes < space_info->total_bytes) in may_commit_transaction()
592 cur_free_bytes = space_info->total_bytes - cur_free_bytes; in may_commit_transaction()
596 if (!list_empty(&space_info->priority_tickets)) in may_commit_transaction()
597 ticket = list_first_entry(&space_info->priority_tickets, in may_commit_transaction()
599 else if (!list_empty(&space_info->tickets)) in may_commit_transaction()
600 ticket = list_first_entry(&space_info->tickets, in may_commit_transaction()
609 spin_unlock(&space_info->lock); in may_commit_transaction()
624 __percpu_counter_compare(&space_info->total_bytes_pinned, in may_commit_transaction()
635 if (space_info != delayed_rsv->space_info) in may_commit_transaction()
654 if (__percpu_counter_compare(&space_info->total_bytes_pinned, in may_commit_transaction()
672 struct btrfs_space_info *space_info, u64 num_bytes, in flush_space() argument
698 shrink_delalloc(fs_info, space_info, num_bytes, in flush_space()
723 btrfs_get_alloc_profile(fs_info, space_info->flags), in flush_space()
740 ret = may_commit_transaction(fs_info, space_info); in flush_space()
747 trace_btrfs_flush_space(fs_info, space_info->flags, num_bytes, state, in flush_space()
754 struct btrfs_space_info *space_info) in btrfs_calc_reclaim_metadata_size() argument
759 u64 to_reclaim = space_info->reclaim_size; in btrfs_calc_reclaim_metadata_size()
761 lockdep_assert_held(&space_info->lock); in btrfs_calc_reclaim_metadata_size()
763 avail = calc_available_free_space(fs_info, space_info, in btrfs_calc_reclaim_metadata_size()
765 used = btrfs_space_info_used(space_info, true); in btrfs_calc_reclaim_metadata_size()
773 if (space_info->total_bytes + avail < used) in btrfs_calc_reclaim_metadata_size()
774 to_reclaim += used - (space_info->total_bytes + avail); in btrfs_calc_reclaim_metadata_size()
780 if (btrfs_can_overcommit(fs_info, space_info, to_reclaim, in btrfs_calc_reclaim_metadata_size()
784 used = btrfs_space_info_used(space_info, true); in btrfs_calc_reclaim_metadata_size()
786 if (btrfs_can_overcommit(fs_info, space_info, SZ_1M, in btrfs_calc_reclaim_metadata_size()
788 expected = div_factor_fine(space_info->total_bytes, 95); in btrfs_calc_reclaim_metadata_size()
790 expected = div_factor_fine(space_info->total_bytes, 90); in btrfs_calc_reclaim_metadata_size()
796 to_reclaim = min(to_reclaim, space_info->bytes_may_use + in btrfs_calc_reclaim_metadata_size()
797 space_info->bytes_reserved); in btrfs_calc_reclaim_metadata_size()
802 struct btrfs_space_info *space_info, in need_do_async_reclaim() argument
805 u64 thresh = div_factor_fine(space_info->total_bytes, 98); in need_do_async_reclaim()
808 if ((space_info->bytes_used + space_info->bytes_reserved) >= thresh) in need_do_async_reclaim()
811 if (!btrfs_calc_reclaim_metadata_size(fs_info, space_info)) in need_do_async_reclaim()
819 struct btrfs_space_info *space_info, in steal_from_global_rsv() argument
825 if (global_rsv->space_info != space_info) in steal_from_global_rsv()
835 remove_ticket(space_info, ticket); in steal_from_global_rsv()
838 space_info->tickets_id++; in steal_from_global_rsv()
862 struct btrfs_space_info *space_info) in maybe_fail_all_tickets() argument
865 u64 tickets_id = space_info->tickets_id; in maybe_fail_all_tickets()
870 __btrfs_dump_space_info(fs_info, space_info); in maybe_fail_all_tickets()
873 while (!list_empty(&space_info->tickets) && in maybe_fail_all_tickets()
874 tickets_id == space_info->tickets_id) { in maybe_fail_all_tickets()
875 ticket = list_first_entry(&space_info->tickets, in maybe_fail_all_tickets()
879 steal_from_global_rsv(fs_info, space_info, ticket)) in maybe_fail_all_tickets()
901 remove_ticket(space_info, ticket); in maybe_fail_all_tickets()
911 btrfs_try_granting_tickets(fs_info, space_info); in maybe_fail_all_tickets()
913 return (tickets_id != space_info->tickets_id); in maybe_fail_all_tickets()
924 struct btrfs_space_info *space_info; in btrfs_async_reclaim_metadata_space() local
931 space_info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); in btrfs_async_reclaim_metadata_space()
933 spin_lock(&space_info->lock); in btrfs_async_reclaim_metadata_space()
934 to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info); in btrfs_async_reclaim_metadata_space()
936 space_info->flush = 0; in btrfs_async_reclaim_metadata_space()
937 spin_unlock(&space_info->lock); in btrfs_async_reclaim_metadata_space()
940 last_tickets_id = space_info->tickets_id; in btrfs_async_reclaim_metadata_space()
941 spin_unlock(&space_info->lock); in btrfs_async_reclaim_metadata_space()
945 flush_space(fs_info, space_info, to_reclaim, flush_state); in btrfs_async_reclaim_metadata_space()
946 spin_lock(&space_info->lock); in btrfs_async_reclaim_metadata_space()
947 if (list_empty(&space_info->tickets)) { in btrfs_async_reclaim_metadata_space()
948 space_info->flush = 0; in btrfs_async_reclaim_metadata_space()
949 spin_unlock(&space_info->lock); in btrfs_async_reclaim_metadata_space()
953 space_info); in btrfs_async_reclaim_metadata_space()
954 if (last_tickets_id == space_info->tickets_id) { in btrfs_async_reclaim_metadata_space()
957 last_tickets_id = space_info->tickets_id; in btrfs_async_reclaim_metadata_space()
979 if (maybe_fail_all_tickets(fs_info, space_info)) { in btrfs_async_reclaim_metadata_space()
983 space_info->flush = 0; in btrfs_async_reclaim_metadata_space()
989 spin_unlock(&space_info->lock); in btrfs_async_reclaim_metadata_space()
1056 struct btrfs_space_info *space_info; in btrfs_async_reclaim_data_space() local
1061 space_info = fs_info->data_sinfo; in btrfs_async_reclaim_data_space()
1063 spin_lock(&space_info->lock); in btrfs_async_reclaim_data_space()
1064 if (list_empty(&space_info->tickets)) { in btrfs_async_reclaim_data_space()
1065 space_info->flush = 0; in btrfs_async_reclaim_data_space()
1066 spin_unlock(&space_info->lock); in btrfs_async_reclaim_data_space()
1069 last_tickets_id = space_info->tickets_id; in btrfs_async_reclaim_data_space()
1070 spin_unlock(&space_info->lock); in btrfs_async_reclaim_data_space()
1072 while (!space_info->full) { in btrfs_async_reclaim_data_space()
1073 flush_space(fs_info, space_info, U64_MAX, ALLOC_CHUNK_FORCE); in btrfs_async_reclaim_data_space()
1074 spin_lock(&space_info->lock); in btrfs_async_reclaim_data_space()
1075 if (list_empty(&space_info->tickets)) { in btrfs_async_reclaim_data_space()
1076 space_info->flush = 0; in btrfs_async_reclaim_data_space()
1077 spin_unlock(&space_info->lock); in btrfs_async_reclaim_data_space()
1080 last_tickets_id = space_info->tickets_id; in btrfs_async_reclaim_data_space()
1081 spin_unlock(&space_info->lock); in btrfs_async_reclaim_data_space()
1085 flush_space(fs_info, space_info, U64_MAX, in btrfs_async_reclaim_data_space()
1087 spin_lock(&space_info->lock); in btrfs_async_reclaim_data_space()
1088 if (list_empty(&space_info->tickets)) { in btrfs_async_reclaim_data_space()
1089 space_info->flush = 0; in btrfs_async_reclaim_data_space()
1090 spin_unlock(&space_info->lock); in btrfs_async_reclaim_data_space()
1094 if (last_tickets_id == space_info->tickets_id) { in btrfs_async_reclaim_data_space()
1097 last_tickets_id = space_info->tickets_id; in btrfs_async_reclaim_data_space()
1102 if (space_info->full) { in btrfs_async_reclaim_data_space()
1103 if (maybe_fail_all_tickets(fs_info, space_info)) in btrfs_async_reclaim_data_space()
1106 space_info->flush = 0; in btrfs_async_reclaim_data_space()
1111 spin_unlock(&space_info->lock); in btrfs_async_reclaim_data_space()
1139 struct btrfs_space_info *space_info, in priority_reclaim_metadata_space() argument
1147 spin_lock(&space_info->lock); in priority_reclaim_metadata_space()
1148 to_reclaim = btrfs_calc_reclaim_metadata_size(fs_info, space_info); in priority_reclaim_metadata_space()
1150 spin_unlock(&space_info->lock); in priority_reclaim_metadata_space()
1153 spin_unlock(&space_info->lock); in priority_reclaim_metadata_space()
1157 flush_space(fs_info, space_info, to_reclaim, states[flush_state]); in priority_reclaim_metadata_space()
1159 spin_lock(&space_info->lock); in priority_reclaim_metadata_space()
1161 spin_unlock(&space_info->lock); in priority_reclaim_metadata_space()
1164 spin_unlock(&space_info->lock); in priority_reclaim_metadata_space()
1169 struct btrfs_space_info *space_info, in priority_reclaim_data_space() argument
1172 while (!space_info->full) { in priority_reclaim_data_space()
1173 flush_space(fs_info, space_info, U64_MAX, ALLOC_CHUNK_FORCE); in priority_reclaim_data_space()
1174 spin_lock(&space_info->lock); in priority_reclaim_data_space()
1176 spin_unlock(&space_info->lock); in priority_reclaim_data_space()
1179 spin_unlock(&space_info->lock); in priority_reclaim_data_space()
1184 struct btrfs_space_info *space_info, in wait_reserve_ticket() argument
1191 spin_lock(&space_info->lock); in wait_reserve_ticket()
1203 remove_ticket(space_info, ticket); in wait_reserve_ticket()
1207 spin_unlock(&space_info->lock); in wait_reserve_ticket()
1212 spin_lock(&space_info->lock); in wait_reserve_ticket()
1214 spin_unlock(&space_info->lock); in wait_reserve_ticket()
1228 struct btrfs_space_info *space_info, in handle_reserve_ticket() argument
1238 wait_reserve_ticket(fs_info, space_info, ticket); in handle_reserve_ticket()
1241 priority_reclaim_metadata_space(fs_info, space_info, ticket, in handle_reserve_ticket()
1246 priority_reclaim_metadata_space(fs_info, space_info, ticket, in handle_reserve_ticket()
1251 priority_reclaim_data_space(fs_info, space_info, ticket); in handle_reserve_ticket()
1258 spin_lock(&space_info->lock); in handle_reserve_ticket()
1269 remove_ticket(space_info, ticket); in handle_reserve_ticket()
1270 btrfs_try_granting_tickets(fs_info, space_info); in handle_reserve_ticket()
1276 spin_unlock(&space_info->lock); in handle_reserve_ticket()
1313 struct btrfs_space_info *space_info, u64 orig_bytes, in __reserve_bytes() argument
1330 spin_lock(&space_info->lock); in __reserve_bytes()
1332 used = btrfs_space_info_used(space_info, true); in __reserve_bytes()
1340 pending_tickets = !list_empty(&space_info->tickets) || in __reserve_bytes()
1341 !list_empty(&space_info->priority_tickets); in __reserve_bytes()
1343 pending_tickets = !list_empty(&space_info->priority_tickets); in __reserve_bytes()
1350 ((used + orig_bytes <= space_info->total_bytes) || in __reserve_bytes()
1351 btrfs_can_overcommit(fs_info, space_info, orig_bytes, flush))) { in __reserve_bytes()
1352 btrfs_space_info_update_bytes_may_use(fs_info, space_info, in __reserve_bytes()
1367 space_info->reclaim_size += ticket.bytes; in __reserve_bytes()
1373 list_add_tail(&ticket.list, &space_info->tickets); in __reserve_bytes()
1374 if (!space_info->flush) { in __reserve_bytes()
1375 space_info->flush = 1; in __reserve_bytes()
1377 space_info->flags, in __reserve_bytes()
1384 &space_info->priority_tickets); in __reserve_bytes()
1386 } else if (!ret && space_info->flags & BTRFS_BLOCK_GROUP_METADATA) { in __reserve_bytes()
1394 need_do_async_reclaim(fs_info, space_info, used) && in __reserve_bytes()
1396 trace_btrfs_trigger_flush(fs_info, space_info->flags, in __reserve_bytes()
1402 spin_unlock(&space_info->lock); in __reserve_bytes()
1406 return handle_reserve_ticket(fs_info, space_info, &ticket, flush); in __reserve_bytes()
1432 ret = __reserve_bytes(fs_info, block_rsv->space_info, orig_bytes, flush); in btrfs_reserve_metadata_bytes()
1441 block_rsv->space_info->flags, in btrfs_reserve_metadata_bytes()
1445 btrfs_dump_space_info(fs_info, block_rsv->space_info, in btrfs_reserve_metadata_bytes()