aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/disk-io.c14
-rw-r--r--fs/btrfs/extent-tree.c3
-rw-r--r--fs/btrfs/file.c7
-rw-r--r--fs/btrfs/inode.c29
-rw-r--r--fs/btrfs/ordered-data.c94
-rw-r--r--fs/btrfs/ordered-data.h4
-rw-r--r--fs/btrfs/super.c4
-rw-r--r--fs/btrfs/tree-log.c2
-rw-r--r--fs/btrfs/volumes.c4
9 files changed, 36 insertions, 125 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 69dce50aabd2..af0435f79fa6 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -773,7 +773,7 @@ static void btree_invalidatepage(struct page *page, unsigned long offset)
773 } 773 }
774} 774}
775 775
776static struct address_space_operations btree_aops = { 776static const struct address_space_operations btree_aops = {
777 .readpage = btree_readpage, 777 .readpage = btree_readpage,
778 .writepage = btree_writepage, 778 .writepage = btree_writepage,
779 .writepages = btree_writepages, 779 .writepages = btree_writepages,
@@ -822,16 +822,14 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
822 822
823int btrfs_write_tree_block(struct extent_buffer *buf) 823int btrfs_write_tree_block(struct extent_buffer *buf)
824{ 824{
825 return btrfs_fdatawrite_range(buf->first_page->mapping, buf->start, 825 return filemap_fdatawrite_range(buf->first_page->mapping, buf->start,
826 buf->start + buf->len - 1, WB_SYNC_ALL); 826 buf->start + buf->len - 1);
827} 827}
828 828
829int btrfs_wait_tree_block_writeback(struct extent_buffer *buf) 829int btrfs_wait_tree_block_writeback(struct extent_buffer *buf)
830{ 830{
831 return btrfs_wait_on_page_writeback_range(buf->first_page->mapping, 831 return filemap_fdatawait_range(buf->first_page->mapping,
832 buf->start >> PAGE_CACHE_SHIFT, 832 buf->start, buf->start + buf->len - 1);
833 (buf->start + buf->len - 1) >>
834 PAGE_CACHE_SHIFT);
835} 833}
836 834
837struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, 835struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
@@ -1373,6 +1371,7 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
1373{ 1371{
1374 int err; 1372 int err;
1375 1373
1374 bdi->name = "btrfs";
1376 bdi->capabilities = BDI_CAP_MAP_COPY; 1375 bdi->capabilities = BDI_CAP_MAP_COPY;
1377 err = bdi_init(bdi); 1376 err = bdi_init(bdi);
1378 if (err) 1377 if (err)
@@ -1641,6 +1640,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1641 1640
1642 sb->s_blocksize = 4096; 1641 sb->s_blocksize = 4096;
1643 sb->s_blocksize_bits = blksize_bits(4096); 1642 sb->s_blocksize_bits = blksize_bits(4096);
1643 sb->s_bdi = &fs_info->bdi;
1644 1644
1645 fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID; 1645 fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID;
1646 fs_info->btree_inode->i_nlink = 1; 1646 fs_info->btree_inode->i_nlink = 1;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d119c0388af1..359a754c782c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1572,7 +1572,8 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
1572static void btrfs_issue_discard(struct block_device *bdev, 1572static void btrfs_issue_discard(struct block_device *bdev,
1573 u64 start, u64 len) 1573 u64 start, u64 len)
1574{ 1574{
1575 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL); 1575 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL,
1576 DISCARD_FL_BARRIER);
1576} 1577}
1577#endif 1578#endif
1578 1579
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f155179877a6..ca784a7fbeba 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1022,9 +1022,8 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
1022 } 1022 }
1023 1023
1024 if (will_write) { 1024 if (will_write) {
1025 btrfs_fdatawrite_range(inode->i_mapping, pos, 1025 filemap_fdatawrite_range(inode->i_mapping, pos,
1026 pos + write_bytes - 1, 1026 pos + write_bytes - 1);
1027 WB_SYNC_ALL);
1028 } else { 1027 } else {
1029 balance_dirty_pages_ratelimited_nr(inode->i_mapping, 1028 balance_dirty_pages_ratelimited_nr(inode->i_mapping,
1030 num_pages); 1029 num_pages);
@@ -1202,7 +1201,7 @@ out:
1202 return ret > 0 ? EIO : ret; 1201 return ret > 0 ? EIO : ret;
1203} 1202}
1204 1203
1205static struct vm_operations_struct btrfs_file_vm_ops = { 1204static const struct vm_operations_struct btrfs_file_vm_ops = {
1206 .fault = filemap_fault, 1205 .fault = filemap_fault,
1207 .page_mkwrite = btrfs_page_mkwrite, 1206 .page_mkwrite = btrfs_page_mkwrite,
1208}; 1207};
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3a6f953337b5..f4001112df78 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -55,13 +55,13 @@ struct btrfs_iget_args {
55 struct btrfs_root *root; 55 struct btrfs_root *root;
56}; 56};
57 57
58static struct inode_operations btrfs_dir_inode_operations; 58static const struct inode_operations btrfs_dir_inode_operations;
59static struct inode_operations btrfs_symlink_inode_operations; 59static const struct inode_operations btrfs_symlink_inode_operations;
60static struct inode_operations btrfs_dir_ro_inode_operations; 60static const struct inode_operations btrfs_dir_ro_inode_operations;
61static struct inode_operations btrfs_special_inode_operations; 61static const struct inode_operations btrfs_special_inode_operations;
62static struct inode_operations btrfs_file_inode_operations; 62static const struct inode_operations btrfs_file_inode_operations;
63static struct address_space_operations btrfs_aops; 63static const struct address_space_operations btrfs_aops;
64static struct address_space_operations btrfs_symlink_aops; 64static const struct address_space_operations btrfs_symlink_aops;
65static struct file_operations btrfs_dir_file_operations; 65static struct file_operations btrfs_dir_file_operations;
66static struct extent_io_ops btrfs_extent_io_ops; 66static struct extent_io_ops btrfs_extent_io_ops;
67 67
@@ -5692,7 +5692,7 @@ static int btrfs_permission(struct inode *inode, int mask)
5692 return generic_permission(inode, mask, btrfs_check_acl); 5692 return generic_permission(inode, mask, btrfs_check_acl);
5693} 5693}
5694 5694
5695static struct inode_operations btrfs_dir_inode_operations = { 5695static const struct inode_operations btrfs_dir_inode_operations = {
5696 .getattr = btrfs_getattr, 5696 .getattr = btrfs_getattr,
5697 .lookup = btrfs_lookup, 5697 .lookup = btrfs_lookup,
5698 .create = btrfs_create, 5698 .create = btrfs_create,
@@ -5710,7 +5710,7 @@ static struct inode_operations btrfs_dir_inode_operations = {
5710 .removexattr = btrfs_removexattr, 5710 .removexattr = btrfs_removexattr,
5711 .permission = btrfs_permission, 5711 .permission = btrfs_permission,
5712}; 5712};
5713static struct inode_operations btrfs_dir_ro_inode_operations = { 5713static const struct inode_operations btrfs_dir_ro_inode_operations = {
5714 .lookup = btrfs_lookup, 5714 .lookup = btrfs_lookup,
5715 .permission = btrfs_permission, 5715 .permission = btrfs_permission,
5716}; 5716};
@@ -5753,7 +5753,7 @@ static struct extent_io_ops btrfs_extent_io_ops = {
5753 * 5753 *
5754 * For now we're avoiding this by dropping bmap. 5754 * For now we're avoiding this by dropping bmap.
5755 */ 5755 */
5756static struct address_space_operations btrfs_aops = { 5756static const struct address_space_operations btrfs_aops = {
5757 .readpage = btrfs_readpage, 5757 .readpage = btrfs_readpage,
5758 .writepage = btrfs_writepage, 5758 .writepage = btrfs_writepage,
5759 .writepages = btrfs_writepages, 5759 .writepages = btrfs_writepages,
@@ -5763,16 +5763,17 @@ static struct address_space_operations btrfs_aops = {
5763 .invalidatepage = btrfs_invalidatepage, 5763 .invalidatepage = btrfs_invalidatepage,
5764 .releasepage = btrfs_releasepage, 5764 .releasepage = btrfs_releasepage,
5765 .set_page_dirty = btrfs_set_page_dirty, 5765 .set_page_dirty = btrfs_set_page_dirty,
5766 .error_remove_page = generic_error_remove_page,
5766}; 5767};
5767 5768
5768static struct address_space_operations btrfs_symlink_aops = { 5769static const struct address_space_operations btrfs_symlink_aops = {
5769 .readpage = btrfs_readpage, 5770 .readpage = btrfs_readpage,
5770 .writepage = btrfs_writepage, 5771 .writepage = btrfs_writepage,
5771 .invalidatepage = btrfs_invalidatepage, 5772 .invalidatepage = btrfs_invalidatepage,
5772 .releasepage = btrfs_releasepage, 5773 .releasepage = btrfs_releasepage,
5773}; 5774};
5774 5775
5775static struct inode_operations btrfs_file_inode_operations = { 5776static const struct inode_operations btrfs_file_inode_operations = {
5776 .truncate = btrfs_truncate, 5777 .truncate = btrfs_truncate,
5777 .getattr = btrfs_getattr, 5778 .getattr = btrfs_getattr,
5778 .setattr = btrfs_setattr, 5779 .setattr = btrfs_setattr,
@@ -5784,7 +5785,7 @@ static struct inode_operations btrfs_file_inode_operations = {
5784 .fallocate = btrfs_fallocate, 5785 .fallocate = btrfs_fallocate,
5785 .fiemap = btrfs_fiemap, 5786 .fiemap = btrfs_fiemap,
5786}; 5787};
5787static struct inode_operations btrfs_special_inode_operations = { 5788static const struct inode_operations btrfs_special_inode_operations = {
5788 .getattr = btrfs_getattr, 5789 .getattr = btrfs_getattr,
5789 .setattr = btrfs_setattr, 5790 .setattr = btrfs_setattr,
5790 .permission = btrfs_permission, 5791 .permission = btrfs_permission,
@@ -5793,7 +5794,7 @@ static struct inode_operations btrfs_special_inode_operations = {
5793 .listxattr = btrfs_listxattr, 5794 .listxattr = btrfs_listxattr,
5794 .removexattr = btrfs_removexattr, 5795 .removexattr = btrfs_removexattr,
5795}; 5796};
5796static struct inode_operations btrfs_symlink_inode_operations = { 5797static const struct inode_operations btrfs_symlink_inode_operations = {
5797 .readlink = generic_readlink, 5798 .readlink = generic_readlink,
5798 .follow_link = page_follow_link_light, 5799 .follow_link = page_follow_link_light,
5799 .put_link = page_put_link, 5800 .put_link = page_put_link,
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 4a9c8c4cec25..897fba835f89 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -458,7 +458,7 @@ void btrfs_start_ordered_extent(struct inode *inode,
458 * start IO on any dirty ones so the wait doesn't stall waiting 458 * start IO on any dirty ones so the wait doesn't stall waiting
459 * for pdflush to find them 459 * for pdflush to find them
460 */ 460 */
461 btrfs_fdatawrite_range(inode->i_mapping, start, end, WB_SYNC_ALL); 461 filemap_fdatawrite_range(inode->i_mapping, start, end);
462 if (wait) { 462 if (wait) {
463 wait_event(entry->wait, test_bit(BTRFS_ORDERED_COMPLETE, 463 wait_event(entry->wait, test_bit(BTRFS_ORDERED_COMPLETE,
464 &entry->flags)); 464 &entry->flags));
@@ -488,17 +488,15 @@ again:
488 /* start IO across the range first to instantiate any delalloc 488 /* start IO across the range first to instantiate any delalloc
489 * extents 489 * extents
490 */ 490 */
491 btrfs_fdatawrite_range(inode->i_mapping, start, orig_end, WB_SYNC_ALL); 491 filemap_fdatawrite_range(inode->i_mapping, start, orig_end);
492 492
493 /* The compression code will leave pages locked but return from 493 /* The compression code will leave pages locked but return from
494 * writepage without setting the page writeback. Starting again 494 * writepage without setting the page writeback. Starting again
495 * with WB_SYNC_ALL will end up waiting for the IO to actually start. 495 * with WB_SYNC_ALL will end up waiting for the IO to actually start.
496 */ 496 */
497 btrfs_fdatawrite_range(inode->i_mapping, start, orig_end, WB_SYNC_ALL); 497 filemap_fdatawrite_range(inode->i_mapping, start, orig_end);
498 498
499 btrfs_wait_on_page_writeback_range(inode->i_mapping, 499 filemap_fdatawait_range(inode->i_mapping, start, orig_end);
500 start >> PAGE_CACHE_SHIFT,
501 orig_end >> PAGE_CACHE_SHIFT);
502 500
503 end = orig_end; 501 end = orig_end;
504 found = 0; 502 found = 0;
@@ -716,90 +714,6 @@ out:
716} 714}
717 715
718 716
719/**
720 * taken from mm/filemap.c because it isn't exported
721 *
722 * __filemap_fdatawrite_range - start writeback on mapping dirty pages in range
723 * @mapping: address space structure to write
724 * @start: offset in bytes where the range starts
725 * @end: offset in bytes where the range ends (inclusive)
726 * @sync_mode: enable synchronous operation
727 *
728 * Start writeback against all of a mapping's dirty pages that lie
729 * within the byte offsets <start, end> inclusive.
730 *
731 * If sync_mode is WB_SYNC_ALL then this is a "data integrity" operation, as
732 * opposed to a regular memory cleansing writeback. The difference between
733 * these two operations is that if a dirty page/buffer is encountered, it must
734 * be waited upon, and not just skipped over.
735 */
736int btrfs_fdatawrite_range(struct address_space *mapping, loff_t start,
737 loff_t end, int sync_mode)
738{
739 struct writeback_control wbc = {
740 .sync_mode = sync_mode,
741 .nr_to_write = mapping->nrpages * 2,
742 .range_start = start,
743 .range_end = end,
744 .for_writepages = 1,
745 };
746 return btrfs_writepages(mapping, &wbc);
747}
748
749/**
750 * taken from mm/filemap.c because it isn't exported
751 *
752 * wait_on_page_writeback_range - wait for writeback to complete
753 * @mapping: target address_space
754 * @start: beginning page index
755 * @end: ending page index
756 *
757 * Wait for writeback to complete against pages indexed by start->end
758 * inclusive
759 */
760int btrfs_wait_on_page_writeback_range(struct address_space *mapping,
761 pgoff_t start, pgoff_t end)
762{
763 struct pagevec pvec;
764 int nr_pages;
765 int ret = 0;
766 pgoff_t index;
767
768 if (end < start)
769 return 0;
770
771 pagevec_init(&pvec, 0);
772 index = start;
773 while ((index <= end) &&
774 (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
775 PAGECACHE_TAG_WRITEBACK,
776 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1)) != 0) {
777 unsigned i;
778
779 for (i = 0; i < nr_pages; i++) {
780 struct page *page = pvec.pages[i];
781
782 /* until radix tree lookup accepts end_index */
783 if (page->index > end)
784 continue;
785
786 wait_on_page_writeback(page);
787 if (PageError(page))
788 ret = -EIO;
789 }
790 pagevec_release(&pvec);
791 cond_resched();
792 }
793
794 /* Check for outstanding write errors */
795 if (test_and_clear_bit(AS_ENOSPC, &mapping->flags))
796 ret = -ENOSPC;
797 if (test_and_clear_bit(AS_EIO, &mapping->flags))
798 ret = -EIO;
799
800 return ret;
801}
802
803/* 717/*
804 * add a given inode to the list of inodes that must be fully on 718 * add a given inode to the list of inodes that must be fully on
805 * disk before a transaction commit finishes. 719 * disk before a transaction commit finishes.
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 993a7ea45c70..f82e87488ca8 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -153,10 +153,6 @@ btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset);
153int btrfs_ordered_update_i_size(struct inode *inode, 153int btrfs_ordered_update_i_size(struct inode *inode,
154 struct btrfs_ordered_extent *ordered); 154 struct btrfs_ordered_extent *ordered);
155int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum); 155int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum);
156int btrfs_wait_on_page_writeback_range(struct address_space *mapping,
157 pgoff_t start, pgoff_t end);
158int btrfs_fdatawrite_range(struct address_space *mapping, loff_t start,
159 loff_t end, int sync_mode);
160int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only); 156int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only);
161int btrfs_run_ordered_operations(struct btrfs_root *root, int wait); 157int btrfs_run_ordered_operations(struct btrfs_root *root, int wait);
162int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, 158int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index e0a64328080c..9de9b2236419 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -51,7 +51,7 @@
51#include "export.h" 51#include "export.h"
52#include "compression.h" 52#include "compression.h"
53 53
54static struct super_operations btrfs_super_ops; 54static const struct super_operations btrfs_super_ops;
55 55
56static void btrfs_put_super(struct super_block *sb) 56static void btrfs_put_super(struct super_block *sb)
57{ 57{
@@ -677,7 +677,7 @@ static int btrfs_unfreeze(struct super_block *sb)
677 return 0; 677 return 0;
678} 678}
679 679
680static struct super_operations btrfs_super_ops = { 680static const struct super_operations btrfs_super_ops = {
681 .drop_inode = btrfs_drop_inode, 681 .drop_inode = btrfs_drop_inode,
682 .delete_inode = btrfs_delete_inode, 682 .delete_inode = btrfs_delete_inode,
683 .put_super = btrfs_put_super, 683 .put_super = btrfs_put_super,
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 4d7d9abef42f..7827841b55cb 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2605,7 +2605,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
2605 extent); 2605 extent);
2606 cs = btrfs_file_extent_offset(src, extent); 2606 cs = btrfs_file_extent_offset(src, extent);
2607 cl = btrfs_file_extent_num_bytes(src, 2607 cl = btrfs_file_extent_num_bytes(src,
2608 extent);; 2608 extent);
2609 if (btrfs_file_extent_compression(src, 2609 if (btrfs_file_extent_compression(src,
2610 extent)) { 2610 extent)) {
2611 cs = 0; 2611 cs = 0;
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 20cbd2eebd97..7eda483d7b5a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -260,7 +260,7 @@ loop_lock:
260 num_run++; 260 num_run++;
261 batch_run++; 261 batch_run++;
262 262
263 if (bio_sync(cur)) 263 if (bio_rw_flagged(cur, BIO_RW_SYNCIO))
264 num_sync_run++; 264 num_sync_run++;
265 265
266 if (need_resched()) { 266 if (need_resched()) {
@@ -2944,7 +2944,7 @@ static noinline int schedule_bio(struct btrfs_root *root,
2944 bio->bi_rw |= rw; 2944 bio->bi_rw |= rw;
2945 2945
2946 spin_lock(&device->io_lock); 2946 spin_lock(&device->io_lock);
2947 if (bio_sync(bio)) 2947 if (bio_rw_flagged(bio, BIO_RW_SYNCIO))
2948 pending_bios = &device->pending_sync_bios; 2948 pending_bios = &device->pending_sync_bios;
2949 else 2949 else
2950 pending_bios = &device->pending_bios; 2950 pending_bios = &device->pending_bios;