Loading fs/btrfs/ctree.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -427,6 +427,7 @@ struct btrfs_space_info { struct list_head ro_bgs; struct list_head ro_bgs; struct list_head priority_tickets; struct list_head priority_tickets; struct list_head tickets; struct list_head tickets; u64 tickets_id; struct rw_semaphore groups_sem; struct rw_semaphore groups_sem; /* for block groups in our same type */ /* for block groups in our same type */ Loading fs/btrfs/extent-tree.c +15 −8 Original line number Original line Diff line number Diff line Loading @@ -4966,12 +4966,12 @@ static void wake_all_tickets(struct list_head *head) */ */ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) static void btrfs_async_reclaim_metadata_space(struct work_struct *work) { { struct reserve_ticket *last_ticket = NULL; struct btrfs_fs_info *fs_info; struct btrfs_fs_info *fs_info; struct btrfs_space_info *space_info; struct btrfs_space_info *space_info; u64 to_reclaim; u64 to_reclaim; int flush_state; int flush_state; int commit_cycles = 0; int commit_cycles = 0; u64 last_tickets_id; fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); Loading @@ -4984,8 +4984,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) spin_unlock(&space_info->lock); spin_unlock(&space_info->lock); return; return; } } last_ticket = list_first_entry(&space_info->tickets, last_tickets_id = space_info->tickets_id; struct reserve_ticket, list); spin_unlock(&space_info->lock); spin_unlock(&space_info->lock); flush_state = FLUSH_DELAYED_ITEMS_NR; flush_state = FLUSH_DELAYED_ITEMS_NR; Loading @@ -5005,10 +5004,10 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) space_info); space_info); ticket = list_first_entry(&space_info->tickets, ticket = list_first_entry(&space_info->tickets, struct reserve_ticket, list); struct reserve_ticket, list); if (last_ticket == ticket) { if (last_tickets_id == space_info->tickets_id) { flush_state++; flush_state++; } else { } else { last_ticket = ticket; last_tickets_id = space_info->tickets_id; flush_state = FLUSH_DELAYED_ITEMS_NR; flush_state = FLUSH_DELAYED_ITEMS_NR; if (commit_cycles) if (commit_cycles) commit_cycles--; commit_cycles--; Loading Loading @@ -5384,6 +5383,7 @@ static void space_info_add_old_bytes(struct btrfs_fs_info *fs_info, list_del_init(&ticket->list); list_del_init(&ticket->list); num_bytes -= ticket->bytes; num_bytes -= ticket->bytes; ticket->bytes = 0; ticket->bytes = 0; space_info->tickets_id++; wake_up(&ticket->wait); wake_up(&ticket->wait); } else { } else { ticket->bytes -= num_bytes; ticket->bytes -= num_bytes; Loading Loading @@ -5426,6 +5426,7 @@ static void space_info_add_new_bytes(struct btrfs_fs_info *fs_info, num_bytes -= ticket->bytes; num_bytes -= ticket->bytes; space_info->bytes_may_use += ticket->bytes; space_info->bytes_may_use += ticket->bytes; ticket->bytes = 0; ticket->bytes = 0; space_info->tickets_id++; wake_up(&ticket->wait); wake_up(&ticket->wait); } else { } else { trace_btrfs_space_reservation(fs_info, "space_info", trace_btrfs_space_reservation(fs_info, "space_info", Loading Loading @@ -8216,6 +8217,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, { { int ret; int ret; struct btrfs_block_group_cache *block_group; struct btrfs_block_group_cache *block_group; struct btrfs_space_info *space_info; /* /* * Mixed block groups will exclude before processing the log so we only * Mixed block groups will exclude before processing the log so we only Loading @@ -8231,9 +8233,14 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, if (!block_group) if (!block_group) return -EINVAL; return -EINVAL; ret = btrfs_add_reserved_bytes(block_group, ins->offset, space_info = block_group->space_info; ins->offset, 0); spin_lock(&space_info->lock); BUG_ON(ret); /* logic error */ spin_lock(&block_group->lock); space_info->bytes_reserved += ins->offset; block_group->reserved += ins->offset; spin_unlock(&block_group->lock); spin_unlock(&space_info->lock); ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, 0, owner, offset, ins, 1); 0, owner, offset, ins, 1); btrfs_put_block_group(block_group); btrfs_put_block_group(block_group); Loading Loading
fs/btrfs/ctree.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -427,6 +427,7 @@ struct btrfs_space_info { struct list_head ro_bgs; struct list_head ro_bgs; struct list_head priority_tickets; struct list_head priority_tickets; struct list_head tickets; struct list_head tickets; u64 tickets_id; struct rw_semaphore groups_sem; struct rw_semaphore groups_sem; /* for block groups in our same type */ /* for block groups in our same type */ Loading
fs/btrfs/extent-tree.c +15 −8 Original line number Original line Diff line number Diff line Loading @@ -4966,12 +4966,12 @@ static void wake_all_tickets(struct list_head *head) */ */ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) static void btrfs_async_reclaim_metadata_space(struct work_struct *work) { { struct reserve_ticket *last_ticket = NULL; struct btrfs_fs_info *fs_info; struct btrfs_fs_info *fs_info; struct btrfs_space_info *space_info; struct btrfs_space_info *space_info; u64 to_reclaim; u64 to_reclaim; int flush_state; int flush_state; int commit_cycles = 0; int commit_cycles = 0; u64 last_tickets_id; fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); fs_info = container_of(work, struct btrfs_fs_info, async_reclaim_work); space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_METADATA); Loading @@ -4984,8 +4984,7 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) spin_unlock(&space_info->lock); spin_unlock(&space_info->lock); return; return; } } last_ticket = list_first_entry(&space_info->tickets, last_tickets_id = space_info->tickets_id; struct reserve_ticket, list); spin_unlock(&space_info->lock); spin_unlock(&space_info->lock); flush_state = FLUSH_DELAYED_ITEMS_NR; flush_state = FLUSH_DELAYED_ITEMS_NR; Loading @@ -5005,10 +5004,10 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) space_info); space_info); ticket = list_first_entry(&space_info->tickets, ticket = list_first_entry(&space_info->tickets, struct reserve_ticket, list); struct reserve_ticket, list); if (last_ticket == ticket) { if (last_tickets_id == space_info->tickets_id) { flush_state++; flush_state++; } else { } else { last_ticket = ticket; last_tickets_id = space_info->tickets_id; flush_state = FLUSH_DELAYED_ITEMS_NR; flush_state = FLUSH_DELAYED_ITEMS_NR; if (commit_cycles) if (commit_cycles) commit_cycles--; commit_cycles--; Loading Loading @@ -5384,6 +5383,7 @@ static void space_info_add_old_bytes(struct btrfs_fs_info *fs_info, list_del_init(&ticket->list); list_del_init(&ticket->list); num_bytes -= ticket->bytes; num_bytes -= ticket->bytes; ticket->bytes = 0; ticket->bytes = 0; space_info->tickets_id++; wake_up(&ticket->wait); wake_up(&ticket->wait); } else { } else { ticket->bytes -= num_bytes; ticket->bytes -= num_bytes; Loading Loading @@ -5426,6 +5426,7 @@ static void space_info_add_new_bytes(struct btrfs_fs_info *fs_info, num_bytes -= ticket->bytes; num_bytes -= ticket->bytes; space_info->bytes_may_use += ticket->bytes; space_info->bytes_may_use += ticket->bytes; ticket->bytes = 0; ticket->bytes = 0; space_info->tickets_id++; wake_up(&ticket->wait); wake_up(&ticket->wait); } else { } else { trace_btrfs_space_reservation(fs_info, "space_info", trace_btrfs_space_reservation(fs_info, "space_info", Loading Loading @@ -8216,6 +8217,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, { { int ret; int ret; struct btrfs_block_group_cache *block_group; struct btrfs_block_group_cache *block_group; struct btrfs_space_info *space_info; /* /* * Mixed block groups will exclude before processing the log so we only * Mixed block groups will exclude before processing the log so we only Loading @@ -8231,9 +8233,14 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, if (!block_group) if (!block_group) return -EINVAL; return -EINVAL; ret = btrfs_add_reserved_bytes(block_group, ins->offset, space_info = block_group->space_info; ins->offset, 0); spin_lock(&space_info->lock); BUG_ON(ret); /* logic error */ spin_lock(&block_group->lock); space_info->bytes_reserved += ins->offset; block_group->reserved += ins->offset; spin_unlock(&block_group->lock); spin_unlock(&space_info->lock); ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, 0, owner, offset, ins, 1); 0, owner, offset, ins, 1); btrfs_put_block_group(block_group); btrfs_put_block_group(block_group); Loading