diff options
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r-- | fs/btrfs/file.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 5908521922fb..0e3a13a45653 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -44,10 +44,10 @@ | |||
44 | /* simple helper to fault in pages and copy. This should go away | 44 | /* simple helper to fault in pages and copy. This should go away |
45 | * and be replaced with calls into generic code. | 45 | * and be replaced with calls into generic code. |
46 | */ | 46 | */ |
47 | static int noinline btrfs_copy_from_user(loff_t pos, int num_pages, | 47 | static noinline int btrfs_copy_from_user(loff_t pos, int num_pages, |
48 | int write_bytes, | 48 | int write_bytes, |
49 | struct page **prepared_pages, | 49 | struct page **prepared_pages, |
50 | const char __user * buf) | 50 | const char __user *buf) |
51 | { | 51 | { |
52 | long page_fault = 0; | 52 | long page_fault = 0; |
53 | int i; | 53 | int i; |
@@ -78,7 +78,7 @@ static int noinline btrfs_copy_from_user(loff_t pos, int num_pages, | |||
78 | /* | 78 | /* |
79 | * unlocks pages after btrfs_file_write is done with them | 79 | * unlocks pages after btrfs_file_write is done with them |
80 | */ | 80 | */ |
81 | static void noinline btrfs_drop_pages(struct page **pages, size_t num_pages) | 81 | static noinline void btrfs_drop_pages(struct page **pages, size_t num_pages) |
82 | { | 82 | { |
83 | size_t i; | 83 | size_t i; |
84 | for (i = 0; i < num_pages; i++) { | 84 | for (i = 0; i < num_pages; i++) { |
@@ -103,7 +103,7 @@ static void noinline btrfs_drop_pages(struct page **pages, size_t num_pages) | |||
103 | * this also makes the decision about creating an inline extent vs | 103 | * this also makes the decision about creating an inline extent vs |
104 | * doing real data extents, marking pages dirty and delalloc as required. | 104 | * doing real data extents, marking pages dirty and delalloc as required. |
105 | */ | 105 | */ |
106 | static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans, | 106 | static noinline int dirty_and_release_pages(struct btrfs_trans_handle *trans, |
107 | struct btrfs_root *root, | 107 | struct btrfs_root *root, |
108 | struct file *file, | 108 | struct file *file, |
109 | struct page **pages, | 109 | struct page **pages, |
@@ -137,9 +137,6 @@ static int noinline dirty_and_release_pages(struct btrfs_trans_handle *trans, | |||
137 | btrfs_set_trans_block_group(trans, inode); | 137 | btrfs_set_trans_block_group(trans, inode); |
138 | hint_byte = 0; | 138 | hint_byte = 0; |
139 | 139 | ||
140 | if ((end_of_last_block & 4095) == 0) { | ||
141 | printk("strange end of last %Lu %zu %Lu\n", start_pos, write_bytes, end_of_last_block); | ||
142 | } | ||
143 | set_extent_uptodate(io_tree, start_pos, end_of_last_block, GFP_NOFS); | 140 | set_extent_uptodate(io_tree, start_pos, end_of_last_block, GFP_NOFS); |
144 | 141 | ||
145 | /* check for reserved extents on each page, we don't want | 142 | /* check for reserved extents on each page, we don't want |
@@ -185,7 +182,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | |||
185 | len = (u64)-1; | 182 | len = (u64)-1; |
186 | testend = 0; | 183 | testend = 0; |
187 | } | 184 | } |
188 | while(1) { | 185 | while (1) { |
189 | if (!split) | 186 | if (!split) |
190 | split = alloc_extent_map(GFP_NOFS); | 187 | split = alloc_extent_map(GFP_NOFS); |
191 | if (!split2) | 188 | if (!split2) |
@@ -295,7 +292,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) | |||
295 | path = btrfs_alloc_path(); | 292 | path = btrfs_alloc_path(); |
296 | ret = btrfs_lookup_file_extent(NULL, root, path, inode->i_ino, | 293 | ret = btrfs_lookup_file_extent(NULL, root, path, inode->i_ino, |
297 | last_offset, 0); | 294 | last_offset, 0); |
298 | while(1) { | 295 | while (1) { |
299 | nritems = btrfs_header_nritems(path->nodes[0]); | 296 | nritems = btrfs_header_nritems(path->nodes[0]); |
300 | if (path->slots[0] >= nritems) { | 297 | if (path->slots[0] >= nritems) { |
301 | ret = btrfs_next_leaf(root, path); | 298 | ret = btrfs_next_leaf(root, path); |
@@ -314,8 +311,10 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) | |||
314 | if (found_key.offset < last_offset) { | 311 | if (found_key.offset < last_offset) { |
315 | WARN_ON(1); | 312 | WARN_ON(1); |
316 | btrfs_print_leaf(root, leaf); | 313 | btrfs_print_leaf(root, leaf); |
317 | printk("inode %lu found offset %Lu expected %Lu\n", | 314 | printk(KERN_ERR "inode %lu found offset %llu " |
318 | inode->i_ino, found_key.offset, last_offset); | 315 | "expected %llu\n", inode->i_ino, |
316 | (unsigned long long)found_key.offset, | ||
317 | (unsigned long long)last_offset); | ||
319 | err = 1; | 318 | err = 1; |
320 | goto out; | 319 | goto out; |
321 | } | 320 | } |
@@ -331,7 +330,7 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) | |||
331 | extent_end = found_key.offset + | 330 | extent_end = found_key.offset + |
332 | btrfs_file_extent_inline_len(leaf, extent); | 331 | btrfs_file_extent_inline_len(leaf, extent); |
333 | extent_end = (extent_end + root->sectorsize - 1) & | 332 | extent_end = (extent_end + root->sectorsize - 1) & |
334 | ~((u64)root->sectorsize -1 ); | 333 | ~((u64)root->sectorsize - 1); |
335 | } | 334 | } |
336 | last_offset = extent_end; | 335 | last_offset = extent_end; |
337 | path->slots[0]++; | 336 | path->slots[0]++; |
@@ -339,8 +338,9 @@ int btrfs_check_file(struct btrfs_root *root, struct inode *inode) | |||
339 | if (0 && last_offset < inode->i_size) { | 338 | if (0 && last_offset < inode->i_size) { |
340 | WARN_ON(1); | 339 | WARN_ON(1); |
341 | btrfs_print_leaf(root, leaf); | 340 | btrfs_print_leaf(root, leaf); |
342 | printk("inode %lu found offset %Lu size %Lu\n", inode->i_ino, | 341 | printk(KERN_ERR "inode %lu found offset %llu size %llu\n", |
343 | last_offset, inode->i_size); | 342 | inode->i_ino, (unsigned long long)last_offset, |
343 | (unsigned long long)inode->i_size); | ||
344 | err = 1; | 344 | err = 1; |
345 | 345 | ||
346 | } | 346 | } |
@@ -362,7 +362,7 @@ out: | |||
362 | * inline_limit is used to tell this code which offsets in the file to keep | 362 | * inline_limit is used to tell this code which offsets in the file to keep |
363 | * if they contain inline extents. | 363 | * if they contain inline extents. |
364 | */ | 364 | */ |
365 | int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans, | 365 | noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, |
366 | struct btrfs_root *root, struct inode *inode, | 366 | struct btrfs_root *root, struct inode *inode, |
367 | u64 start, u64 end, u64 inline_limit, u64 *hint_byte) | 367 | u64 start, u64 end, u64 inline_limit, u64 *hint_byte) |
368 | { | 368 | { |
@@ -398,7 +398,7 @@ int noinline btrfs_drop_extents(struct btrfs_trans_handle *trans, | |||
398 | path = btrfs_alloc_path(); | 398 | path = btrfs_alloc_path(); |
399 | if (!path) | 399 | if (!path) |
400 | return -ENOMEM; | 400 | return -ENOMEM; |
401 | while(1) { | 401 | while (1) { |
402 | recow = 0; | 402 | recow = 0; |
403 | btrfs_release_path(root, path); | 403 | btrfs_release_path(root, path); |
404 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 404 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, |
@@ -649,16 +649,15 @@ next_slot: | |||
649 | if (disk_bytenr != 0) { | 649 | if (disk_bytenr != 0) { |
650 | ret = btrfs_update_extent_ref(trans, root, | 650 | ret = btrfs_update_extent_ref(trans, root, |
651 | disk_bytenr, orig_parent, | 651 | disk_bytenr, orig_parent, |
652 | leaf->start, | 652 | leaf->start, |
653 | root->root_key.objectid, | 653 | root->root_key.objectid, |
654 | trans->transid, ins.objectid); | 654 | trans->transid, ins.objectid); |
655 | 655 | ||
656 | BUG_ON(ret); | 656 | BUG_ON(ret); |
657 | } | 657 | } |
658 | btrfs_release_path(root, path); | 658 | btrfs_release_path(root, path); |
659 | if (disk_bytenr != 0) { | 659 | if (disk_bytenr != 0) |
660 | inode_add_bytes(inode, extent_end - end); | 660 | inode_add_bytes(inode, extent_end - end); |
661 | } | ||
662 | } | 661 | } |
663 | 662 | ||
664 | if (found_extent && !keep) { | 663 | if (found_extent && !keep) { |
@@ -944,7 +943,7 @@ done: | |||
944 | * waits for data=ordered extents to finish before allowing the pages to be | 943 | * waits for data=ordered extents to finish before allowing the pages to be |
945 | * modified. | 944 | * modified. |
946 | */ | 945 | */ |
947 | static int noinline prepare_pages(struct btrfs_root *root, struct file *file, | 946 | static noinline int prepare_pages(struct btrfs_root *root, struct file *file, |
948 | struct page **pages, size_t num_pages, | 947 | struct page **pages, size_t num_pages, |
949 | loff_t pos, unsigned long first_index, | 948 | loff_t pos, unsigned long first_index, |
950 | unsigned long last_index, size_t write_bytes) | 949 | unsigned long last_index, size_t write_bytes) |
@@ -979,7 +978,8 @@ again: | |||
979 | struct btrfs_ordered_extent *ordered; | 978 | struct btrfs_ordered_extent *ordered; |
980 | lock_extent(&BTRFS_I(inode)->io_tree, | 979 | lock_extent(&BTRFS_I(inode)->io_tree, |
981 | start_pos, last_pos - 1, GFP_NOFS); | 980 | start_pos, last_pos - 1, GFP_NOFS); |
982 | ordered = btrfs_lookup_first_ordered_extent(inode, last_pos -1); | 981 | ordered = btrfs_lookup_first_ordered_extent(inode, |
982 | last_pos - 1); | ||
983 | if (ordered && | 983 | if (ordered && |
984 | ordered->file_offset + ordered->len > start_pos && | 984 | ordered->file_offset + ordered->len > start_pos && |
985 | ordered->file_offset < last_pos) { | 985 | ordered->file_offset < last_pos) { |
@@ -1085,7 +1085,7 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf, | |||
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | while(count > 0) { | 1088 | while (count > 0) { |
1089 | size_t offset = pos & (PAGE_CACHE_SIZE - 1); | 1089 | size_t offset = pos & (PAGE_CACHE_SIZE - 1); |
1090 | size_t write_bytes = min(count, nrptrs * | 1090 | size_t write_bytes = min(count, nrptrs * |
1091 | (size_t)PAGE_CACHE_SIZE - | 1091 | (size_t)PAGE_CACHE_SIZE - |
@@ -1178,7 +1178,7 @@ out_nolock: | |||
1178 | return num_written ? num_written : err; | 1178 | return num_written ? num_written : err; |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | int btrfs_release_file(struct inode * inode, struct file * filp) | 1181 | int btrfs_release_file(struct inode *inode, struct file *filp) |
1182 | { | 1182 | { |
1183 | if (filp->private_data) | 1183 | if (filp->private_data) |
1184 | btrfs_ioctl_trans_end(filp); | 1184 | btrfs_ioctl_trans_end(filp); |
@@ -1237,9 +1237,8 @@ int btrfs_sync_file(struct file *file, struct dentry *dentry, int datasync) | |||
1237 | } | 1237 | } |
1238 | 1238 | ||
1239 | ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); | 1239 | ret = btrfs_log_dentry_safe(trans, root, file->f_dentry); |
1240 | if (ret < 0) { | 1240 | if (ret < 0) |
1241 | goto out; | 1241 | goto out; |
1242 | } | ||
1243 | 1242 | ||
1244 | /* we've logged all the items and now have a consistent | 1243 | /* we've logged all the items and now have a consistent |
1245 | * version of the file in the log. It is possible that | 1244 | * version of the file in the log. It is possible that |