fs_info->closing = 0;
fs_info->total_pinned = 0;
fs_info->last_alloc = 0;
+ fs_info->last_data_alloc = 0;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info);
int ret;
int slot = 0;
u64 last_byte = 0;
+ u64 *last_ptr = NULL;
u64 orig_search_start = search_start;
int start_found;
struct extent_buffer *l;
/* for SSD, cluster allocations together as much as possible */
if (btrfs_test_opt(root, SSD)) {
- if (!data) {
- if (root->fs_info->last_alloc)
- hint_byte = root->fs_info->last_alloc;
- else {
- hint_byte = hint_byte &
- ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1);
- empty_size += 16 * 1024 * 1024;
- }
+ if (data)
+ last_ptr = &root->fs_info->last_data_alloc;
+ else
+ last_ptr = &root->fs_info->last_alloc;
+ if (*last_ptr) {
+ hint_byte = *last_ptr;
+ }
+ else {
+ hint_byte = hint_byte &
+ ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1);
+ empty_size += 16 * 1024 * 1024;
}
}
search_start = find_search_start(root, &block_group, search_start,
total_needed, data);
- if (!data && btrfs_test_opt(root, SSD) && info->last_alloc &&
- search_start != info->last_alloc) {
+ if (btrfs_test_opt(root, SSD) && *last_ptr &&
+ search_start != *last_ptr) {
info->last_alloc = 0;
if (!empty_size) {
empty_size += 16 * 1024 * 1024;
}
ins->offset = num_bytes;
btrfs_free_path(path);
+ if (btrfs_test_opt(root, SSD))
+ *last_ptr = ins->objectid + ins->offset;
return 0;
new_group:
error:
btrfs_release_path(root, path);
btrfs_free_path(path);
- if (btrfs_test_opt(root, SSD) && !ret && !data)
- info->last_alloc = ins->objectid + ins->offset;
return ret;
}
/*
root->fs_info->generation++;
root->fs_info->running_transaction = cur_trans;
root->fs_info->last_alloc = 0;
+ root->fs_info->last_data_alloc = 0;
cur_trans->num_writers = 1;
cur_trans->num_joined = 0;
cur_trans->transid = root->fs_info->generation;