Btrfs: Shrink delay allocated space in a synchronized way
PATCH v2 3/12 Btrfs: Shrink delay allocated space in a synchronized way
Shrink delay allocated space in a synchronized manner is more controllable than flushing all delay allocated space in an async thread.
Signed-off-by Yan Zheng <[email protected]>
---
fs/btrfs/ctree.h +1 -5
@@ -699,10 +699,6 @@ struct btrfs_space_info {struct list_head list; -/* for controlling how we free up space for allocations */ -wait_queue_head_t flush_wait; -int flushing; -/* for block groups in our same type */ struct list_head block_groups[BTRFS_NR_RAID_TYPES ];spinlock_t lock;
@@ -927,7 +923,6 @@ struct btrfs_fs_info {struct btrfs_workers endio_meta_write_workers;struct btrfs_workers endio_write_workers;struct btrfs_workers submit_workers; -struct btrfs_workers enospc_workers;/* * fixup workers take dirty pages that didn't properly go through * the cow mechanism and make them safe to write. It happens
@@ -2311,6 +2306,7 @@ int btrfs_truncate_inode_items(struct bt u32 min_type);int btrfs_start_delalloc_inodes (struct btrfs_root *root,int delay_iput); +int btrfs_start_one_delalloc_inode (struct btrfs_root *root,int delay_iput);int btrfs_set_extent_delalloc (struct inode *inode,u64 start,u64 end,struct extent_state **cached_state); int btrfs_writepages(struct address_space *mapping,
fs/btrfs/disk-io.c +0 -6
@@ -1768,9 +1768,6 @@ struct btrfs_root *open_ctree(struct supmin_t (u64, fs_devices->num_devices, fs_info->thread_pool_size), &fs_info->generic_worker); -btrfs_init_workers (&fs_info->enospc_workers,"enospc" , - fs_info->thread_pool_size, - &fs_info->generic_worker);/* a higher idle thresh on the submit workers makes it much more * likely that bios will be send down in a sane order to the
@@ -1818,7 +1815,6 @@ struct btrfs_root *open_ctree(struct supbtrfs_start_workers (&fs_info->endio_meta_workers,1 );btrfs_start_workers (&fs_info->endio_meta_write_workers,1 );btrfs_start_workers (&fs_info->endio_write_workers,1 ); -btrfs_start_workers (&fs_info->enospc_workers,1 ); fs_info->bdi.ra_pages *=btrfs_super_num_devices (disk_super); fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages,
@@ -2049,7 +2045,6 @@ fail_sb_buffer:btrfs_stop_workers (&fs_info->endio_meta_write_workers);btrfs_stop_workers (&fs_info->endio_write_workers);btrfs_stop_workers (&fs_info->submit_workers); -btrfs_stop_workers (&fs_info->enospc_workers); fail_iput:invalidate_inode_pages2 (fs_info->btree_inode->i_mapping);iput (fs_info->btree_inode);
@@ -2482,7 +2477,6 @@ int close_ctree(struct btrfs_root *root)btrfs_stop_workers (&fs_info->endio_meta_write_workers);btrfs_stop_workers (&fs_info->endio_write_workers);btrfs_stop_workers (&fs_info->submit_workers); -btrfs_stop_workers (&fs_info->enospc_workers);btrfs_close_devices (fs_info->fs_devices);btrfs_mapping_tree_free (&fs_info->mapping_tree);
fs/btrfs/extent-tree.c +55 -110
213 lines not on this page · raw message
fs/btrfs/inode.c +32 -0
@@ -5610,6 +5610,38 @@ int btrfs_start_delalloc_inodes(struct breturn 0 ; } +int btrfs_start_one_delalloc_inode (struct btrfs_root *root,int delay_iput) +{ +struct btrfs_inode *binode; +struct inode *inode =NULL ; + +spin_lock (&root->fs_info->delalloc_lock); +while (!list_empty (&root->fs_info->delalloc_inodes)) { + binode =list_entry (root->fs_info->delalloc_inodes.next, + struct btrfs_inode, delalloc_inodes); + inode =igrab (&binode->vfs_inode); +if (inode) { +list_move_tail (&binode->delalloc_inodes, + &root->fs_info->delalloc_inodes); +break ; + } + +list_del_init (&binode->delalloc_inodes); +cond_resched_lock (&root->fs_info->delalloc_lock); + } +spin_unlock (&root->fs_info->delalloc_lock); + +if (inode) { +write_inode_now (inode,0 ); +if (delay_iput) +btrfs_add_delayed_iput (inode); +else +iput (inode); +return 1 ; + } +return 0 ; +} +static int btrfs_symlink (struct inode *dir,struct dentry *dentry,const char *symname) {