free space accounting redo
Subsystems (2)
PATCH v2 1/1 free space accounting redo
Hello,
This is basically the same patch as I sent before, just takes a kzalloc outside of a spin_lock to get rid of a possible hang situation. Thanks,
Josef
Makefile +1 -1
@@ -7,7 +7,7 @@ btrfs-y := super.o ctree.o extent-tree.o transaction.o bit-radix.o inode.o file.o tree-defrag.o \ extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \ extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \ - ref-cache.o export.o tree-log.o acl.o + ref-cache.o export.o tree-log.o acl.o free-space-cache.o else # Normal Makefile
ctree.c +1 -2
@@ -2725,9 +2725,8 @@ int btrfs_insert_empty_items(struct btrf total_size = total_data + (nr *sizeof (struct btrfs_item )); ret =btrfs_search_slot (trans, root, cpu_key, path, total_size,1 ); -if (ret ==0 ) { +if (ret ==0 )return -EEXIST ; - }if (ret <0 ) goto out;
ctree.h +42 -4
78 lines not on this page · raw message
disk-io.c +3 -4
@@ -1410,10 +1410,9 @@ struct btrfs_root *open_ctree(struct supBTRFS_I (fs_info->btree_inode)->io_tree.ops = &btree_extent_io_ops; -extent_io_tree_init (&fs_info->free_space_cache, - fs_info->btree_inode->i_mapping,GFP_NOFS ); -extent_io_tree_init (&fs_info->block_group_cache, - fs_info->btree_inode->i_mapping,GFP_NOFS ); +spin_lock_init (&fs_info->block_group_cache_lock); + fs_info->block_group_cache_tree.rb_node =NULL ; +extent_io_tree_init (&fs_info->pinned_extents, fs_info->btree_inode->i_mapping,GFP_NOFS ); extent_io_tree_init(&fs_info->pending_del,
extent-tree.c +449 -418
1,305 lines not on this page · raw message
extent_io.c +4 -0
@@ -2634,6 +2634,7 @@ struct extent_buffer *alloc_extent_buffeif (eb) {atomic_inc (&eb->refs);spin_unlock (&tree->buffer_lock); +mark_page_accessed (eb->first_page);return eb; }spin_unlock (&tree->buffer_lock);
@@ -2712,6 +2713,9 @@ struct extent_buffer *find_extent_bufferif (eb)atomic_inc (&eb->refs);spin_unlock (&tree->buffer_lock); + +if (eb) +mark_page_accessed (eb->first_page);return eb; }
free-space-cache.c new file +410 -0
410 lines not on this page · raw message
inode.c +1 -2
@@ -141,7 +141,7 @@ static int cow_file_range(struct inode *while (num_bytes >0 ) { cur_alloc_size =min (num_bytes, root->fs_info->max_extent); ret =btrfs_reserve_extent (trans, root, cur_alloc_size, - root->sectorsize,0 ,0 , + root->sectorsize,0 , alloc_hint, (u64)-1 , &ins,1 );if (ret) {WARN_ON (1 );
@@ -558,7 +558,6 @@ static int btrfs_finish_ordered_io(struc trans->transid, inode->i_ino, ordered_extent->file_offset, &ins);BUG_ON (ret); -mutex_lock (&BTRFS_I (inode)->extent_mutex); ret = btrfs_drop_extents(trans, root, inode,
volumes.c +8 -3
@@ -64,8 +64,8 @@ static void lock_chunks(struct btrfs_roostatic void unlock_chunks (struct btrfs_root *root) { +mutex_unlock (&root->fs_info->chunk_mutex);mutex_unlock (&root->fs_info->alloc_mutex); -mutex_unlock (&root->fs_info->chunk_mutex); }int btrfs_cleanup_fs_uuids (void )
@@ -1668,8 +1668,13 @@ again:else min_free = calc_size; -/* we add 1MB because we never use the first 1MB of the device */ - min_free +=1024 *1024 ; +/* +* we add 1MB because we never use the first 1MB of the device, unless +* we've looped, then we are likely allocating the maximum amount of +* space left already +*/ +if (!looped) + min_free +=1024 *1024 ;/* build a private list of devices we will allocate from */ while (index < num_stripes) {