@@ -122,7 +122,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 objectid,
struct btrfs_inode_item *inode,
u64 file_pos, u64 disk_bytenr,
- u64 *ret_num_bytes)
+ u64 *ret_num_bytes, u64 flags)
{
int ret;
struct btrfs_fs_info *info = root->fs_info;
@@ -229,7 +229,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans,
leaf = path->nodes[0];
fi = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item);
btrfs_set_file_extent_generation(leaf, fi, trans->transid);
- btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG);
+ btrfs_set_file_extent_type(leaf, fi, flags);
btrfs_set_file_extent_disk_bytenr(leaf, fi, extent_bytenr);
btrfs_set_file_extent_disk_num_bytes(leaf, fi, extent_num_bytes);
btrfs_set_file_extent_offset(leaf, fi, extent_offset);
@@ -265,7 +265,7 @@ int btrfs_record_file_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 objectid,
struct btrfs_inode_item *inode,
u64 file_pos, u64 disk_bytenr,
- u64 num_bytes)
+ u64 num_bytes, u64 flags)
{
u64 cur_disk_bytenr = disk_bytenr;
u64 cur_file_pos = file_pos;
@@ -276,7 +276,7 @@ int btrfs_record_file_extent(struct btrfs_trans_handle *trans,
ret = __btrfs_record_file_extent(trans, root, objectid,
inode, cur_file_pos,
cur_disk_bytenr,
- &cur_num_bytes);
+ &cur_num_bytes, flags);
if (ret < 0)
break;
cur_disk_bytenr += cur_num_bytes;
@@ -31,6 +31,6 @@ int btrfs_record_file_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 objectid,
struct btrfs_inode_item *inode,
u64 file_pos, u64 disk_bytenr,
- u64 num_bytes);
+ u64 num_bytes, u64 flags);
#endif
@@ -337,7 +337,7 @@ static int create_image_file_range(struct btrfs_trans_handle *trans,
return -EINVAL;
}
ret = btrfs_record_file_extent(trans, root, ino, inode, bytenr,
- disk_bytenr, len);
+ disk_bytenr, len, BTRFS_FILE_EXTENT_REG);
if (ret < 0)
return ret;
@@ -426,7 +426,8 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans,
/* Now handle extent item and file extent things */
ret = btrfs_record_file_extent(trans, root, ino, inode, cur_off,
- key.objectid, key.offset);
+ key.objectid, key.offset,
+ BTRFS_FILE_EXTENT_REG);
if (ret < 0)
break;
/* Finally, insert csum items */
@@ -438,7 +439,7 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans,
hole_len = cur_off - hole_start;
if (hole_len) {
ret = btrfs_record_file_extent(trans, root, ino, inode,
- hole_start, 0, hole_len);
+ hole_start, 0, hole_len, BTRFS_FILE_EXTENT_REG);
if (ret < 0)
break;
}
@@ -455,7 +456,8 @@ static int migrate_one_reserved_range(struct btrfs_trans_handle *trans,
*/
if (range_end(range) - hole_start > 0)
ret = btrfs_record_file_extent(trans, root, ino, inode,
- hole_start, 0, range_end(range) - hole_start);
+ hole_start, 0, range_end(range) - hole_start,
+ BTRFS_FILE_EXTENT_REG);
return ret;
}
@@ -262,7 +262,7 @@ int record_file_blocks(struct blk_iterate_data *data,
if (old_disk_bytenr == 0)
return btrfs_record_file_extent(data->trans, root,
data->objectid, data->inode, file_pos, 0,
- num_bytes);
+ num_bytes, BTRFS_FILE_EXTENT_REG);
/*
* Search real disk bytenr from convert root
@@ -316,7 +316,8 @@ int record_file_blocks(struct blk_iterate_data *data,
old_disk_bytenr + num_bytes) - cur_off;
ret = btrfs_record_file_extent(data->trans, data->root,
data->objectid, data->inode, file_pos,
- real_disk_bytenr, cur_len);
+ real_disk_bytenr, cur_len,
+ BTRFS_FILE_EXTENT_REG);
if (ret < 0)
break;
cur_off += cur_len;
@@ -365,7 +365,7 @@ static int convert_direct(struct btrfs_trans_handle *trans,
return ret;
return btrfs_record_file_extent(trans, root, objectid, inode, offset,
- key.objectid, sectorsize);
+ key.objectid, sectorsize, BTRFS_FILE_EXTENT_REG);
}
static int reiserfs_convert_tail(struct btrfs_trans_handle *trans,
@@ -411,7 +411,8 @@ again:
if (bytes_read) {
ret = btrfs_record_file_extent(trans, root, objectid,
- btrfs_inode, file_pos, first_block, cur_bytes);
+ btrfs_inode, file_pos, first_block, cur_bytes,
+ false);
if (ret)
goto end;
This preparatory patch adds an argument '%prealloc' to the function __btrfs_record_file_extent(), to be used in the following patches. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- v2: pass btrfs_record_file_extent() actual flags instead of has_prealloc boolean. common/extent-tree-utils.c | 8 ++++---- common/extent-tree-utils.h | 2 +- convert/main.c | 10 ++++++---- convert/source-fs.c | 5 +++-- convert/source-reiserfs.c | 2 +- mkfs/rootdir.c | 3 ++- 6 files changed, 17 insertions(+), 13 deletions(-)