Commit 960a3166 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by David Sterba

btrfs: zoned: allow preallocation for relocation inodes

Now that we use a dedicated block group and regular writes for data
relocation, we can preallocate the space needed for a relocated inode,
just like we do in regular mode.

Essentially this reverts commit 32430c61 ("btrfs: zoned: enable
relocation on a zoned filesystem") as it is not needed anymore.
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 2adada88
...@@ -2853,31 +2853,6 @@ static noinline_for_stack int prealloc_file_extent_cluster( ...@@ -2853,31 +2853,6 @@ static noinline_for_stack int prealloc_file_extent_cluster(
if (ret) if (ret)
return ret; return ret;
/*
* On a zoned filesystem, we cannot preallocate the file region.
* Instead, we dirty and fiemap_write the region.
*/
if (btrfs_is_zoned(inode->root->fs_info)) {
struct btrfs_root *root = inode->root;
struct btrfs_trans_handle *trans;
end = cluster->end - offset + 1;
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans))
return PTR_ERR(trans);
inode->vfs_inode.i_ctime = current_time(&inode->vfs_inode);
i_size_write(&inode->vfs_inode, end);
ret = btrfs_update_inode(trans, root, inode);
if (ret) {
btrfs_abort_transaction(trans, ret);
btrfs_end_transaction(trans);
return ret;
}
return btrfs_end_transaction(trans);
}
btrfs_inode_lock(&inode->vfs_inode, 0); btrfs_inode_lock(&inode->vfs_inode, 0);
for (nr = 0; nr < cluster->nr; nr++) { for (nr = 0; nr < cluster->nr; nr++) {
start = cluster->boundary[nr] - offset; start = cluster->boundary[nr] - offset;
...@@ -3085,7 +3060,6 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, ...@@ -3085,7 +3060,6 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
static int relocate_file_extent_cluster(struct inode *inode, static int relocate_file_extent_cluster(struct inode *inode,
struct file_extent_cluster *cluster) struct file_extent_cluster *cluster)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
u64 offset = BTRFS_I(inode)->index_cnt; u64 offset = BTRFS_I(inode)->index_cnt;
unsigned long index; unsigned long index;
unsigned long last_index; unsigned long last_index;
...@@ -3115,8 +3089,6 @@ static int relocate_file_extent_cluster(struct inode *inode, ...@@ -3115,8 +3089,6 @@ static int relocate_file_extent_cluster(struct inode *inode,
for (index = (cluster->start - offset) >> PAGE_SHIFT; for (index = (cluster->start - offset) >> PAGE_SHIFT;
index <= last_index && !ret; index++) index <= last_index && !ret; index++)
ret = relocate_one_page(inode, ra, cluster, &cluster_nr, index); ret = relocate_one_page(inode, ra, cluster, &cluster_nr, index);
if (btrfs_is_zoned(fs_info) && !ret)
ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
if (ret == 0) if (ret == 0)
WARN_ON(cluster_nr != cluster->nr); WARN_ON(cluster_nr != cluster->nr);
out: out:
...@@ -3771,12 +3743,8 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans, ...@@ -3771,12 +3743,8 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
struct btrfs_path *path; struct btrfs_path *path;
struct btrfs_inode_item *item; struct btrfs_inode_item *item;
struct extent_buffer *leaf; struct extent_buffer *leaf;
u64 flags = BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC;
int ret; int ret;
if (btrfs_is_zoned(trans->fs_info))
flags &= ~BTRFS_INODE_PREALLOC;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) if (!path)
return -ENOMEM; return -ENOMEM;
...@@ -3791,7 +3759,8 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans, ...@@ -3791,7 +3759,8 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
btrfs_set_inode_generation(leaf, item, 1); btrfs_set_inode_generation(leaf, item, 1);
btrfs_set_inode_size(leaf, item, 0); btrfs_set_inode_size(leaf, item, 0);
btrfs_set_inode_mode(leaf, item, S_IFREG | 0600); btrfs_set_inode_mode(leaf, item, S_IFREG | 0600);
btrfs_set_inode_flags(leaf, item, flags); btrfs_set_inode_flags(leaf, item, BTRFS_INODE_NOCOMPRESS |
BTRFS_INODE_PREALLOC);
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment