diff options
author | Ross Zwisler <ross.zwisler@linux.intel.com> | 2016-02-26 18:19:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-02-27 13:28:52 -0500 |
commit | 7f6d5b529b7dfe2fca30cbf4bc81e16575090025 (patch) | |
tree | 3dce0ed231dadcd470db83c1762a701004c1616b /fs | |
parent | 20a90f58997245749c2bdfaea9e51f785ec90d0b (diff) |
dax: move writeback calls into the filesystems
Previously calls to dax_writeback_mapping_range() for all DAX filesystems
(ext2, ext4 & xfs) were centralized in filemap_write_and_wait_range().
dax_writeback_mapping_range() needs a struct block_device, and it used
to get that from inode->i_sb->s_bdev. This is correct for normal inodes
mounted on ext2, ext4 and XFS filesystems, but is incorrect for DAX raw
block devices and for XFS real-time files.
Instead, call dax_writeback_mapping_range() directly from the filesystem
->writepages function so that it can supply us with a valid block
device. This also fixes DAX code to properly flush caches in response
to sync(2).
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@ftp.linux.org.uk>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/block_dev.c | 13 | ||||
-rw-r--r-- | fs/dax.c | 12 | ||||
-rw-r--r-- | fs/ext2/inode.c | 8 | ||||
-rw-r--r-- | fs/ext4/inode.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_aops.c | 4 |
5 files changed, 35 insertions, 6 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 31c6d1090f11..826b164a4b5b 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1697,13 +1697,24 @@ static int blkdev_releasepage(struct page *page, gfp_t wait) | |||
1697 | return try_to_free_buffers(page); | 1697 | return try_to_free_buffers(page); |
1698 | } | 1698 | } |
1699 | 1699 | ||
1700 | static int blkdev_writepages(struct address_space *mapping, | ||
1701 | struct writeback_control *wbc) | ||
1702 | { | ||
1703 | if (dax_mapping(mapping)) { | ||
1704 | struct block_device *bdev = I_BDEV(mapping->host); | ||
1705 | |||
1706 | return dax_writeback_mapping_range(mapping, bdev, wbc); | ||
1707 | } | ||
1708 | return generic_writepages(mapping, wbc); | ||
1709 | } | ||
1710 | |||
1700 | static const struct address_space_operations def_blk_aops = { | 1711 | static const struct address_space_operations def_blk_aops = { |
1701 | .readpage = blkdev_readpage, | 1712 | .readpage = blkdev_readpage, |
1702 | .readpages = blkdev_readpages, | 1713 | .readpages = blkdev_readpages, |
1703 | .writepage = blkdev_writepage, | 1714 | .writepage = blkdev_writepage, |
1704 | .write_begin = blkdev_write_begin, | 1715 | .write_begin = blkdev_write_begin, |
1705 | .write_end = blkdev_write_end, | 1716 | .write_end = blkdev_write_end, |
1706 | .writepages = generic_writepages, | 1717 | .writepages = blkdev_writepages, |
1707 | .releasepage = blkdev_releasepage, | 1718 | .releasepage = blkdev_releasepage, |
1708 | .direct_IO = blkdev_direct_IO, | 1719 | .direct_IO = blkdev_direct_IO, |
1709 | .is_dirty_writeback = buffer_check_dirty_writeback, | 1720 | .is_dirty_writeback = buffer_check_dirty_writeback, |
@@ -484,11 +484,10 @@ static int dax_writeback_one(struct block_device *bdev, | |||
484 | * end]. This is required by data integrity operations to ensure file data is | 484 | * end]. This is required by data integrity operations to ensure file data is |
485 | * on persistent storage prior to completion of the operation. | 485 | * on persistent storage prior to completion of the operation. |
486 | */ | 486 | */ |
487 | int dax_writeback_mapping_range(struct address_space *mapping, loff_t start, | 487 | int dax_writeback_mapping_range(struct address_space *mapping, |
488 | loff_t end) | 488 | struct block_device *bdev, struct writeback_control *wbc) |
489 | { | 489 | { |
490 | struct inode *inode = mapping->host; | 490 | struct inode *inode = mapping->host; |
491 | struct block_device *bdev = inode->i_sb->s_bdev; | ||
492 | pgoff_t start_index, end_index, pmd_index; | 491 | pgoff_t start_index, end_index, pmd_index; |
493 | pgoff_t indices[PAGEVEC_SIZE]; | 492 | pgoff_t indices[PAGEVEC_SIZE]; |
494 | struct pagevec pvec; | 493 | struct pagevec pvec; |
@@ -499,8 +498,11 @@ int dax_writeback_mapping_range(struct address_space *mapping, loff_t start, | |||
499 | if (WARN_ON_ONCE(inode->i_blkbits != PAGE_SHIFT)) | 498 | if (WARN_ON_ONCE(inode->i_blkbits != PAGE_SHIFT)) |
500 | return -EIO; | 499 | return -EIO; |
501 | 500 | ||
502 | start_index = start >> PAGE_CACHE_SHIFT; | 501 | if (!mapping->nrexceptional || wbc->sync_mode != WB_SYNC_ALL) |
503 | end_index = end >> PAGE_CACHE_SHIFT; | 502 | return 0; |
503 | |||
504 | start_index = wbc->range_start >> PAGE_CACHE_SHIFT; | ||
505 | end_index = wbc->range_end >> PAGE_CACHE_SHIFT; | ||
504 | pmd_index = DAX_PMD_INDEX(start_index); | 506 | pmd_index = DAX_PMD_INDEX(start_index); |
505 | 507 | ||
506 | rcu_read_lock(); | 508 | rcu_read_lock(); |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 4467cbd75f24..6bd58e6ff038 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -876,6 +876,14 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset) | |||
876 | static int | 876 | static int |
877 | ext2_writepages(struct address_space *mapping, struct writeback_control *wbc) | 877 | ext2_writepages(struct address_space *mapping, struct writeback_control *wbc) |
878 | { | 878 | { |
879 | #ifdef CONFIG_FS_DAX | ||
880 | if (dax_mapping(mapping)) { | ||
881 | return dax_writeback_mapping_range(mapping, | ||
882 | mapping->host->i_sb->s_bdev, | ||
883 | wbc); | ||
884 | } | ||
885 | #endif | ||
886 | |||
879 | return mpage_writepages(mapping, wbc, ext2_get_block); | 887 | return mpage_writepages(mapping, wbc, ext2_get_block); |
880 | } | 888 | } |
881 | 889 | ||
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5708e689e63d..aee960b1af34 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -2478,6 +2478,10 @@ static int ext4_writepages(struct address_space *mapping, | |||
2478 | 2478 | ||
2479 | trace_ext4_writepages(inode, wbc); | 2479 | trace_ext4_writepages(inode, wbc); |
2480 | 2480 | ||
2481 | if (dax_mapping(mapping)) | ||
2482 | return dax_writeback_mapping_range(mapping, inode->i_sb->s_bdev, | ||
2483 | wbc); | ||
2484 | |||
2481 | /* | 2485 | /* |
2482 | * No pages to write? This is mainly a kludge to avoid starting | 2486 | * No pages to write? This is mainly a kludge to avoid starting |
2483 | * a transaction for special inodes like journal inode on last iput() | 2487 | * a transaction for special inodes like journal inode on last iput() |
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index fc20518e2398..a9ebabfe7587 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -1208,6 +1208,10 @@ xfs_vm_writepages( | |||
1208 | struct writeback_control *wbc) | 1208 | struct writeback_control *wbc) |
1209 | { | 1209 | { |
1210 | xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); | 1210 | xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); |
1211 | if (dax_mapping(mapping)) | ||
1212 | return dax_writeback_mapping_range(mapping, | ||
1213 | xfs_find_bdev_for_inode(mapping->host), wbc); | ||
1214 | |||
1211 | return generic_writepages(mapping, wbc); | 1215 | return generic_writepages(mapping, wbc); |
1212 | } | 1216 | } |
1213 | 1217 | ||