diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-12-17 20:14:04 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:58 -0400 |
commit | c59f8951d48c5eb000926935f3ab063d8181d1ee (patch) | |
tree | ddf1e3ecb8a03fc30add98ee263c23eb6d382621 /fs/btrfs/inode.c | |
parent | d10c5f31c79c6a703974ae29d0a05781b828fe30 (diff) |
Btrfs: Add mount option to enforce a max extent size
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 91f3fc43e2a9..686dd03f34f2 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -78,6 +78,7 @@ static int cow_file_range(struct inode *inode, u64 start, u64 end) | |||
78 | struct btrfs_trans_handle *trans; | 78 | struct btrfs_trans_handle *trans; |
79 | u64 alloc_hint = 0; | 79 | u64 alloc_hint = 0; |
80 | u64 num_bytes; | 80 | u64 num_bytes; |
81 | u64 cur_alloc_size; | ||
81 | u64 blocksize = root->sectorsize; | 82 | u64 blocksize = root->sectorsize; |
82 | struct btrfs_key ins; | 83 | struct btrfs_key ins; |
83 | int ret; | 84 | int ret; |
@@ -94,17 +95,24 @@ static int cow_file_range(struct inode *inode, u64 start, u64 end) | |||
94 | if (alloc_hint == EXTENT_MAP_INLINE) | 95 | if (alloc_hint == EXTENT_MAP_INLINE) |
95 | goto out; | 96 | goto out; |
96 | 97 | ||
97 | ret = btrfs_alloc_extent(trans, root, num_bytes, | 98 | while(num_bytes > 0) { |
98 | root->root_key.objectid, trans->transid, | 99 | cur_alloc_size = min(num_bytes, root->fs_info->max_extent); |
99 | inode->i_ino, start, 0, | 100 | ret = btrfs_alloc_extent(trans, root, cur_alloc_size, |
100 | alloc_hint, (u64)-1, &ins, 1); | 101 | root->root_key.objectid, |
101 | if (ret) { | 102 | trans->transid, |
102 | WARN_ON(1); | 103 | inode->i_ino, start, 0, |
103 | goto out; | 104 | alloc_hint, (u64)-1, &ins, 1); |
105 | if (ret) { | ||
106 | WARN_ON(1); | ||
107 | goto out; | ||
108 | } | ||
109 | ret = btrfs_insert_file_extent(trans, root, inode->i_ino, | ||
110 | start, ins.objectid, ins.offset, | ||
111 | ins.offset); | ||
112 | num_bytes -= cur_alloc_size; | ||
113 | alloc_hint = ins.objectid + ins.offset; | ||
114 | start += cur_alloc_size; | ||
104 | } | 115 | } |
105 | ret = btrfs_insert_file_extent(trans, root, inode->i_ino, | ||
106 | start, ins.objectid, ins.offset, | ||
107 | ins.offset); | ||
108 | out: | 116 | out: |
109 | btrfs_end_transaction(trans, root); | 117 | btrfs_end_transaction(trans, root); |
110 | return ret; | 118 | return ret; |