Commit 50743398 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba
Browse files

btrfs: make btrfs_truncate_inode_items take btrfs_inode

parent 90dffd0c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3072,7 +3072,7 @@ int btrfs_truncate_block(struct inode *inode, loff_t from, loff_t len,
			int front);
int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
			       struct btrfs_root *root,
			       struct inode *inode, u64 new_size,
			       struct btrfs_inode *inode, u64 new_size,
			       u32 min_type);

int btrfs_start_delalloc_snapshot(struct btrfs_root *root);
+1 −1
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
	 * We skip the throttling logic for free space cache inodes, so we don't
	 * need to check for -EAGAIN.
	 */
	ret = btrfs_truncate_inode_items(trans, root, inode,
	ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
					 0, BTRFS_EXTENT_DATA_KEY);
	if (ret)
		goto fail;
+23 −20
Original line number Diff line number Diff line
@@ -4299,7 +4299,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 */
int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
			       struct btrfs_root *root,
			       struct inode *inode,
			       struct btrfs_inode *inode,
			       u64 new_size, u32 min_type)
{
	struct btrfs_fs_info *fs_info = root->fs_info;
@@ -4320,7 +4320,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
	int pending_del_slot = 0;
	int extent_type = -1;
	int ret;
	u64 ino = btrfs_ino(BTRFS_I(inode));
	u64 ino = btrfs_ino(inode);
	u64 bytes_deleted = 0;
	bool be_nice = false;
	bool should_throttle = false;
@@ -4334,7 +4334,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
	 * off from time to time.  This means all inodes in subvolume roots,
	 * reloc roots, and data reloc roots.
	 */
	if (!btrfs_is_free_space_inode(BTRFS_I(inode)) &&
	if (!btrfs_is_free_space_inode(inode) &&
	    test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
		be_nice = true;

@@ -4344,7 +4344,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
	path->reada = READA_BACK;

	if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
		lock_extent_bits(&BTRFS_I(inode)->io_tree, lock_start, (u64)-1,
		lock_extent_bits(&inode->io_tree, lock_start, (u64)-1,
				 &cached_state);

		/*
@@ -4352,7 +4352,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
		 * new size is not block aligned since we will be keeping the
		 * last block of the extent just the way it is.
		 */
		btrfs_drop_extent_cache(BTRFS_I(inode), ALIGN(new_size,
		btrfs_drop_extent_cache(inode, ALIGN(new_size,
					fs_info->sectorsize),
					(u64)-1, 0);
	}
@@ -4363,8 +4363,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
	 * it is used to drop the logged items. So we shouldn't kill the delayed
	 * items.
	 */
	if (min_type == 0 && root == BTRFS_I(inode)->root)
		btrfs_kill_delayed_inode_items(BTRFS_I(inode));
	if (min_type == 0 && root == inode->root)
		btrfs_kill_delayed_inode_items(inode);

	key.objectid = ino;
	key.offset = (u64)-1;
@@ -4420,14 +4420,13 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
				    btrfs_file_extent_num_bytes(leaf, fi);

				trace_btrfs_truncate_show_fi_regular(
					BTRFS_I(inode), leaf, fi,
					found_key.offset);
					inode, leaf, fi, found_key.offset);
			} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
				item_end += btrfs_file_extent_ram_bytes(leaf,
									fi);

				trace_btrfs_truncate_show_fi_inline(
					BTRFS_I(inode), leaf, fi, path->slots[0],
					inode, leaf, fi, path->slots[0],
					found_key.offset);
			}
			item_end--;
@@ -4466,7 +4465,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
				if (test_bit(BTRFS_ROOT_SHAREABLE,
					     &root->state) &&
				    extent_start != 0)
					inode_sub_bytes(inode, num_dec);
					inode_sub_bytes(&inode->vfs_inode,
							num_dec);
				btrfs_mark_buffer_dirty(leaf);
			} else {
				extent_num_bytes =
@@ -4481,7 +4481,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
					found_extent = 1;
					if (test_bit(BTRFS_ROOT_SHAREABLE,
						     &root->state))
						inode_sub_bytes(inode, num_dec);
						inode_sub_bytes(&inode->vfs_inode,
								num_dec);
				}
			}
			clear_len = num_dec;
@@ -4516,7 +4517,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
			}

			if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
				inode_sub_bytes(inode, item_end + 1 - new_size);
				inode_sub_bytes(&inode->vfs_inode,
						item_end + 1 - new_size);
		}
delete:
		/*
@@ -4524,8 +4526,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
		 * multiple fsyncs, and in this case we don't want to clear the
		 * file extent range because it's just the log.
		 */
		if (root == BTRFS_I(inode)->root) {
			ret = btrfs_inode_clear_file_extent_range(BTRFS_I(inode),
		if (root == inode->root) {
			ret = btrfs_inode_clear_file_extent_range(inode,
						  clear_start, clear_len);
			if (ret) {
				btrfs_abort_transaction(trans, ret);
@@ -4633,9 +4635,9 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
		ASSERT(last_size >= new_size);
		if (!ret && last_size > new_size)
			last_size = new_size;
		btrfs_inode_safe_disk_i_size_write(BTRFS_I(inode), last_size);
		unlock_extent_cached(&BTRFS_I(inode)->io_tree, lock_start,
				     (u64)-1, &cached_state);
		btrfs_inode_safe_disk_i_size_write(inode, last_size);
		unlock_extent_cached(&inode->io_tree, lock_start, (u64)-1,
				     &cached_state);
	}

	btrfs_free_path(path);
@@ -5268,7 +5270,8 @@ void btrfs_evict_inode(struct inode *inode)

		trans->block_rsv = rsv;

		ret = btrfs_truncate_inode_items(trans, root, inode, 0, 0);
		ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
						 0, 0);
		trans->block_rsv = &fs_info->trans_block_rsv;
		btrfs_end_transaction(trans);
		btrfs_btree_balance_dirty(fs_info);
@@ -8512,7 +8515,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
	trans->block_rsv = rsv;

	while (1) {
		ret = btrfs_truncate_inode_items(trans, root, inode,
		ret = btrfs_truncate_inode_items(trans, root, BTRFS_I(inode),
						 inode->i_size,
						 BTRFS_EXTENT_DATA_KEY);
		trans->block_rsv = &fs_info->trans_block_rsv;
+2 −3
Original line number Diff line number Diff line
@@ -4378,8 +4378,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans,
			do {
				ret = btrfs_truncate_inode_items(trans,
							 root->log_root,
							 &inode->vfs_inode,
							 truncate_offset,
							 inode, truncate_offset,
							 BTRFS_EXTENT_DATA_KEY);
			} while (ret == -EAGAIN);
			if (ret)
@@ -5306,7 +5305,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
					  &inode->runtime_flags);
				while(1) {
					ret = btrfs_truncate_inode_items(trans,
						log, &inode->vfs_inode, 0, 0);
						log, inode, 0, 0);
					if (ret != -EAGAIN)
						break;
				}