diff options
-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 | ||||
-rw-r--r-- | include/linux/dax.h | 6 | ||||
-rw-r--r-- | mm/filemap.c | 12 |
7 files changed, 43 insertions, 16 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 | ||
diff --git a/include/linux/dax.h b/include/linux/dax.h index 7b6bcedb980f..636dd59ab505 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h | |||
@@ -52,6 +52,8 @@ static inline bool dax_mapping(struct address_space *mapping) | |||
52 | { | 52 | { |
53 | return mapping->host && IS_DAX(mapping->host); | 53 | return mapping->host && IS_DAX(mapping->host); |
54 | } | 54 | } |
55 | int dax_writeback_mapping_range(struct address_space *mapping, loff_t start, | 55 | |
56 | loff_t end); | 56 | struct writeback_control; |
57 | int dax_writeback_mapping_range(struct address_space *mapping, | ||
58 | struct block_device *bdev, struct writeback_control *wbc); | ||
57 | #endif | 59 | #endif |
diff --git a/mm/filemap.c b/mm/filemap.c index 23edccecadb0..3461d97ecb30 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -446,7 +446,8 @@ int filemap_write_and_wait(struct address_space *mapping) | |||
446 | { | 446 | { |
447 | int err = 0; | 447 | int err = 0; |
448 | 448 | ||
449 | if (mapping->nrpages) { | 449 | if ((!dax_mapping(mapping) && mapping->nrpages) || |
450 | (dax_mapping(mapping) && mapping->nrexceptional)) { | ||
450 | err = filemap_fdatawrite(mapping); | 451 | err = filemap_fdatawrite(mapping); |
451 | /* | 452 | /* |
452 | * Even if the above returned error, the pages may be | 453 | * Even if the above returned error, the pages may be |
@@ -482,13 +483,8 @@ int filemap_write_and_wait_range(struct address_space *mapping, | |||
482 | { | 483 | { |
483 | int err = 0; | 484 | int err = 0; |
484 | 485 | ||
485 | if (dax_mapping(mapping) && mapping->nrexceptional) { | 486 | if ((!dax_mapping(mapping) && mapping->nrpages) || |
486 | err = dax_writeback_mapping_range(mapping, lstart, lend); | 487 | (dax_mapping(mapping) && mapping->nrexceptional)) { |
487 | if (err) | ||
488 | return err; | ||
489 | } | ||
490 | |||
491 | if (mapping->nrpages) { | ||
492 | err = __filemap_fdatawrite_range(mapping, lstart, lend, | 488 | err = __filemap_fdatawrite_range(mapping, lstart, lend, |
493 | WB_SYNC_ALL); | 489 | WB_SYNC_ALL); |
494 | /* See comment of filemap_write_and_wait() */ | 490 | /* See comment of filemap_write_and_wait() */ |