Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6ece707 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable: (25 commits)
  btrfs: fix uninitialized variable warning
  btrfs: add helper for fs_info->closing
  Btrfs: add mount -o inode_cache
  btrfs: scrub: add explicit plugging
  btrfs: use btrfs_ino to access inode number
  Btrfs: don't save the inode cache if we are deleting this root
  btrfs: false BUG_ON when degraded
  Btrfs: don't save the inode cache in non-FS roots
  Btrfs: make sure we don't overflow the free space cache crc page
  Btrfs: fix uninit variable in the delayed inode code
  btrfs: scrub: don't reuse bios and pages
  Btrfs: leave spinning on lookup and map the leaf
  Btrfs: check for duplicate entries in the free space cache
  Btrfs: don't try to allocate from a block group that doesn't have enough space
  Btrfs: don't always do readahead
  Btrfs: try not to sleep as much when doing slow caching
  Btrfs: kill BTRFS_I(inode)->block_group
  Btrfs: don't look at the extent buffer level 3 times in a row
  Btrfs: map the node block when looking for readahead targets
  Btrfs: set range_start to the right start in count_range_bits
  ...
parents 23c79d31 aa0467d8
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -121,9 +121,6 @@ struct btrfs_inode {
	 */
	u64 index_cnt;

	/* the start of block group preferred for allocations. */
	u64 block_group;

	/* the fsync log has some corner cases that mean we have to check
	 * directories to see if any unlinks have been done before
	 * the directory was logged.  See tree-log.c for all the
+21 −7
Original line number Diff line number Diff line
@@ -43,8 +43,6 @@ struct btrfs_path *btrfs_alloc_path(void)
{
	struct btrfs_path *path;
	path = kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS);
	if (path)
		path->reada = 1;
	return path;
}

@@ -1224,6 +1222,7 @@ static void reada_for_search(struct btrfs_root *root,
	u64 search;
	u64 target;
	u64 nread = 0;
	u64 gen;
	int direction = path->reada;
	struct extent_buffer *eb;
	u32 nr;
@@ -1251,6 +1250,15 @@ static void reada_for_search(struct btrfs_root *root,
	nritems = btrfs_header_nritems(node);
	nr = slot;
	while (1) {
		if (!node->map_token) {
			unsigned long offset = btrfs_node_key_ptr_offset(nr);
			map_private_extent_buffer(node, offset,
						  sizeof(struct btrfs_key_ptr),
						  &node->map_token,
						  &node->kaddr,
						  &node->map_start,
						  &node->map_len, KM_USER1);
		}
		if (direction < 0) {
			if (nr == 0)
				break;
@@ -1268,14 +1276,23 @@ static void reada_for_search(struct btrfs_root *root,
		search = btrfs_node_blockptr(node, nr);
		if ((search <= target && target - search <= 65536) ||
		    (search > target && search - target <= 65536)) {
			readahead_tree_block(root, search, blocksize,
				     btrfs_node_ptr_generation(node, nr));
			gen = btrfs_node_ptr_generation(node, nr);
			if (node->map_token) {
				unmap_extent_buffer(node, node->map_token,
						    KM_USER1);
				node->map_token = NULL;
			}
			readahead_tree_block(root, search, blocksize, gen);
			nread += blocksize;
		}
		nscan++;
		if ((nread > 65536 || nscan > 32))
			break;
	}
	if (node->map_token) {
		unmap_extent_buffer(node, node->map_token, KM_USER1);
		node->map_token = NULL;
	}
}

/*
@@ -1648,9 +1665,6 @@ again:
		}
cow_done:
		BUG_ON(!cow && ins_len);
		if (level != btrfs_header_level(b))
			WARN_ON(1);
		level = btrfs_header_level(b);

		p->nodes[level] = b;
		if (!p->skip_locking)
+17 −5
Original line number Diff line number Diff line
@@ -930,7 +930,6 @@ struct btrfs_fs_info {
	 * is required instead of the faster short fsync log commits
	 */
	u64 last_trans_log_full_commit;
	u64 open_ioctl_trans;
	unsigned long mount_opt:20;
	unsigned long compress_type:4;
	u64 max_inline;
@@ -947,7 +946,6 @@ struct btrfs_fs_info {
	struct super_block *sb;
	struct inode *btree_inode;
	struct backing_dev_info bdi;
	struct mutex trans_mutex;
	struct mutex tree_log_mutex;
	struct mutex transaction_kthread_mutex;
	struct mutex cleaner_mutex;
@@ -968,6 +966,7 @@ struct btrfs_fs_info {
	struct rw_semaphore subvol_sem;
	struct srcu_struct subvol_srcu;

	spinlock_t trans_lock;
	struct list_head trans_list;
	struct list_head hashers;
	struct list_head dead_roots;
@@ -980,6 +979,7 @@ struct btrfs_fs_info {
	atomic_t async_submit_draining;
	atomic_t nr_async_bios;
	atomic_t async_delalloc_pages;
	atomic_t open_ioctl_trans;

	/*
	 * this is used by the balancing code to wait for all the pending
@@ -1044,6 +1044,7 @@ struct btrfs_fs_info {
	int closing;
	int log_root_recovering;
	int enospc_unlink;
	int trans_no_join;

	u64 total_pinned;

@@ -1065,7 +1066,6 @@ struct btrfs_fs_info {
	struct reloc_control *reloc_ctl;

	spinlock_t delalloc_lock;
	spinlock_t new_trans_lock;
	u64 delalloc_bytes;

	/* data_alloc_cluster is only used in ssd mode */
@@ -1340,6 +1340,7 @@ struct btrfs_ioctl_defrag_range_args {
#define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)
#define BTRFS_MOUNT_ENOSPC_DEBUG	 (1 << 15)
#define BTRFS_MOUNT_AUTO_DEFRAG		(1 << 16)
#define BTRFS_MOUNT_INODE_MAP_CACHE	(1 << 17)

#define btrfs_clear_opt(o, opt)		((o) &= ~BTRFS_MOUNT_##opt)
#define btrfs_set_opt(o, opt)		((o) |= BTRFS_MOUNT_##opt)
@@ -2238,6 +2239,9 @@ int btrfs_block_rsv_migrate(struct btrfs_block_rsv *src_rsv,
void btrfs_block_rsv_release(struct btrfs_root *root,
			     struct btrfs_block_rsv *block_rsv,
			     u64 num_bytes);
int btrfs_truncate_reserve_metadata(struct btrfs_trans_handle *trans,
				    struct btrfs_root *root,
				    struct btrfs_block_rsv *rsv);
int btrfs_set_block_group_ro(struct btrfs_root *root,
			     struct btrfs_block_group_cache *cache);
int btrfs_set_block_group_rw(struct btrfs_root *root,
@@ -2350,6 +2354,15 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
			struct btrfs_root *root,
			struct extent_buffer *node,
			struct extent_buffer *parent);
static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
{
	/*
	 * Get synced with close_ctree()
	 */
	smp_mb();
	return fs_info->closing;
}

/* root-item.c */
int btrfs_find_root_ref(struct btrfs_root *tree_root,
			struct btrfs_path *path,
@@ -2512,8 +2525,7 @@ int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
int btrfs_writepages(struct address_space *mapping,
		     struct writeback_control *wbc);
int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
			     struct btrfs_root *new_root,
			     u64 new_dirid, u64 alloc_hint);
			     struct btrfs_root *new_root, u64 new_dirid);
int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
			 size_t size, struct bio *bio, unsigned long bio_flags);

+4 −4
Original line number Diff line number Diff line
@@ -678,6 +678,7 @@ static int btrfs_batch_insert_items(struct btrfs_trans_handle *trans,
	INIT_LIST_HEAD(&head);

	next = item;
	nitems = 0;

	/*
	 * count the number of the continuous items that we can insert in batch
@@ -1129,7 +1130,7 @@ static void btrfs_async_run_delayed_node_done(struct btrfs_work *work)
	delayed_node = async_node->delayed_node;
	root = delayed_node->root;

	trans = btrfs_join_transaction(root, 0);
	trans = btrfs_join_transaction(root);
	if (IS_ERR(trans))
		goto free_path;

@@ -1572,8 +1573,7 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
	btrfs_set_stack_inode_transid(inode_item, trans->transid);
	btrfs_set_stack_inode_rdev(inode_item, inode->i_rdev);
	btrfs_set_stack_inode_flags(inode_item, BTRFS_I(inode)->flags);
	btrfs_set_stack_inode_block_group(inode_item,
					  BTRFS_I(inode)->block_group);
	btrfs_set_stack_inode_block_group(inode_item, 0);

	btrfs_set_stack_timespec_sec(btrfs_inode_atime(inode_item),
				     inode->i_atime.tv_sec);
@@ -1595,7 +1595,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
			       struct btrfs_root *root, struct inode *inode)
{
	struct btrfs_delayed_node *delayed_node;
	int ret;
	int ret = 0;

	delayed_node = btrfs_get_or_create_delayed_node(inode);
	if (IS_ERR(delayed_node))
+18 −18
Original line number Diff line number Diff line
@@ -1505,24 +1505,24 @@ static int transaction_kthread(void *arg)
		vfs_check_frozen(root->fs_info->sb, SB_FREEZE_WRITE);
		mutex_lock(&root->fs_info->transaction_kthread_mutex);

		spin_lock(&root->fs_info->new_trans_lock);
		spin_lock(&root->fs_info->trans_lock);
		cur = root->fs_info->running_transaction;
		if (!cur) {
			spin_unlock(&root->fs_info->new_trans_lock);
			spin_unlock(&root->fs_info->trans_lock);
			goto sleep;
		}

		now = get_seconds();
		if (!cur->blocked &&
		    (now < cur->start_time || now - cur->start_time < 30)) {
			spin_unlock(&root->fs_info->new_trans_lock);
			spin_unlock(&root->fs_info->trans_lock);
			delay = HZ * 5;
			goto sleep;
		}
		transid = cur->transid;
		spin_unlock(&root->fs_info->new_trans_lock);
		spin_unlock(&root->fs_info->trans_lock);

		trans = btrfs_join_transaction(root, 1);
		trans = btrfs_join_transaction(root);
		BUG_ON(IS_ERR(trans));
		if (transid == trans->transid) {
			ret = btrfs_commit_transaction(trans, root);
@@ -1613,7 +1613,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
	INIT_LIST_HEAD(&fs_info->ordered_operations);
	INIT_LIST_HEAD(&fs_info->caching_block_groups);
	spin_lock_init(&fs_info->delalloc_lock);
	spin_lock_init(&fs_info->new_trans_lock);
	spin_lock_init(&fs_info->trans_lock);
	spin_lock_init(&fs_info->ref_cache_lock);
	spin_lock_init(&fs_info->fs_roots_radix_lock);
	spin_lock_init(&fs_info->delayed_iput_lock);
@@ -1645,6 +1645,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
	fs_info->max_inline = 8192 * 1024;
	fs_info->metadata_ratio = 0;
	fs_info->defrag_inodes = RB_ROOT;
	fs_info->trans_no_join = 0;

	fs_info->thread_pool_size = min_t(unsigned long,
					  num_online_cpus() + 2, 8);
@@ -1709,7 +1710,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
	fs_info->do_barriers = 1;


	mutex_init(&fs_info->trans_mutex);
	mutex_init(&fs_info->ordered_operations_mutex);
	mutex_init(&fs_info->tree_log_mutex);
	mutex_init(&fs_info->chunk_mutex);
@@ -2479,13 +2479,13 @@ int btrfs_commit_super(struct btrfs_root *root)
	down_write(&root->fs_info->cleanup_work_sem);
	up_write(&root->fs_info->cleanup_work_sem);

	trans = btrfs_join_transaction(root, 1);
	trans = btrfs_join_transaction(root);
	if (IS_ERR(trans))
		return PTR_ERR(trans);
	ret = btrfs_commit_transaction(trans, root);
	BUG_ON(ret);
	/* run commit again to drop the original snapshot */
	trans = btrfs_join_transaction(root, 1);
	trans = btrfs_join_transaction(root);
	if (IS_ERR(trans))
		return PTR_ERR(trans);
	btrfs_commit_transaction(trans, root);
@@ -3024,10 +3024,13 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root)

	WARN_ON(1);

	mutex_lock(&root->fs_info->trans_mutex);
	mutex_lock(&root->fs_info->transaction_kthread_mutex);

	spin_lock(&root->fs_info->trans_lock);
	list_splice_init(&root->fs_info->trans_list, &list);
	root->fs_info->trans_no_join = 1;
	spin_unlock(&root->fs_info->trans_lock);

	while (!list_empty(&list)) {
		t = list_entry(list.next, struct btrfs_transaction, list);
		if (!t)
@@ -3052,23 +3055,18 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root)
		t->blocked = 0;
		if (waitqueue_active(&root->fs_info->transaction_wait))
			wake_up(&root->fs_info->transaction_wait);
		mutex_unlock(&root->fs_info->trans_mutex);

		mutex_lock(&root->fs_info->trans_mutex);
		t->commit_done = 1;
		if (waitqueue_active(&t->commit_wait))
			wake_up(&t->commit_wait);
		mutex_unlock(&root->fs_info->trans_mutex);

		mutex_lock(&root->fs_info->trans_mutex);

		btrfs_destroy_pending_snapshots(t);

		btrfs_destroy_delalloc_inodes(root);

		spin_lock(&root->fs_info->new_trans_lock);
		spin_lock(&root->fs_info->trans_lock);
		root->fs_info->running_transaction = NULL;
		spin_unlock(&root->fs_info->new_trans_lock);
		spin_unlock(&root->fs_info->trans_lock);

		btrfs_destroy_marked_extents(root, &t->dirty_pages,
					     EXTENT_DIRTY);
@@ -3082,8 +3080,10 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root)
		kmem_cache_free(btrfs_transaction_cachep, t);
	}

	spin_lock(&root->fs_info->trans_lock);
	root->fs_info->trans_no_join = 0;
	spin_unlock(&root->fs_info->trans_lock);
	mutex_unlock(&root->fs_info->transaction_kthread_mutex);
	mutex_unlock(&root->fs_info->trans_mutex);

	return 0;
}
Loading