aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/dax.c32
-rw-r--r--fs/ext2/inode.c8
-rw-r--r--fs/xfs/xfs_bmap_util.c15
-rw-r--r--include/linux/dax.h1
4 files changed, 8 insertions, 48 deletions
diff --git a/fs/dax.c b/fs/dax.c
index d602410d8e52..0abbbb62981e 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -87,38 +87,6 @@ struct page *read_dax_sector(struct block_device *bdev, sector_t n)
87 return page; 87 return page;
88} 88}
89 89
90/*
91 * dax_clear_sectors() is called from within transaction context from XFS,
92 * and hence this means the stack from this point must follow GFP_NOFS
93 * semantics for all operations.
94 */
95int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size)
96{
97 struct blk_dax_ctl dax = {
98 .sector = _sector,
99 .size = _size,
100 };
101
102 might_sleep();
103 do {
104 long count, sz;
105
106 count = dax_map_atomic(bdev, &dax);
107 if (count < 0)
108 return count;
109 sz = min_t(long, count, SZ_128K);
110 clear_pmem(dax.addr, sz);
111 dax.size -= sz;
112 dax.sector += sz / 512;
113 dax_unmap_atomic(bdev, &dax);
114 cond_resched();
115 } while (dax.size);
116
117 wmb_pmem();
118 return 0;
119}
120EXPORT_SYMBOL_GPL(dax_clear_sectors);
121
122static bool buffer_written(struct buffer_head *bh) 90static bool buffer_written(struct buffer_head *bh)
123{ 91{
124 return buffer_mapped(bh) && !buffer_unwritten(bh); 92 return buffer_mapped(bh) && !buffer_unwritten(bh);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 9a14af3b1a69..17cbd6b696f2 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -26,6 +26,7 @@
26#include <linux/highuid.h> 26#include <linux/highuid.h>
27#include <linux/pagemap.h> 27#include <linux/pagemap.h>
28#include <linux/dax.h> 28#include <linux/dax.h>
29#include <linux/blkdev.h>
29#include <linux/quotaops.h> 30#include <linux/quotaops.h>
30#include <linux/writeback.h> 31#include <linux/writeback.h>
31#include <linux/buffer_head.h> 32#include <linux/buffer_head.h>
@@ -737,10 +738,9 @@ static int ext2_get_blocks(struct inode *inode,
737 * so that it's not found by another thread before it's 738 * so that it's not found by another thread before it's
738 * initialised 739 * initialised
739 */ 740 */
740 err = dax_clear_sectors(inode->i_sb->s_bdev, 741 err = sb_issue_zeroout(inode->i_sb,
741 le32_to_cpu(chain[depth-1].key) << 742 le32_to_cpu(chain[depth-1].key), count,
742 (inode->i_blkbits - 9), 743 GFP_NOFS);
743 count << inode->i_blkbits);
744 if (err) { 744 if (err) {
745 mutex_unlock(&ei->truncate_mutex); 745 mutex_unlock(&ei->truncate_mutex);
746 goto cleanup; 746 goto cleanup;
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 3b6309865c65..930ac6a17ce3 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -72,18 +72,11 @@ xfs_zero_extent(
72 struct xfs_mount *mp = ip->i_mount; 72 struct xfs_mount *mp = ip->i_mount;
73 xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb); 73 xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb);
74 sector_t block = XFS_BB_TO_FSBT(mp, sector); 74 sector_t block = XFS_BB_TO_FSBT(mp, sector);
75 ssize_t size = XFS_FSB_TO_B(mp, count_fsb);
76
77 if (IS_DAX(VFS_I(ip)))
78 return dax_clear_sectors(xfs_find_bdev_for_inode(VFS_I(ip)),
79 sector, size);
80
81 /*
82 * let the block layer decide on the fastest method of
83 * implementing the zeroing.
84 */
85 return sb_issue_zeroout(mp->m_super, block, count_fsb, GFP_NOFS);
86 75
76 return blkdev_issue_zeroout(xfs_find_bdev_for_inode(VFS_I(ip)),
77 block << (mp->m_super->s_blocksize_bits - 9),
78 count_fsb << (mp->m_super->s_blocksize_bits - 9),
79 GFP_NOFS, true);
87} 80}
88 81
89/* 82/*
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 7c45ac7ea1d1..7f853ffaa987 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -7,7 +7,6 @@
7 7
8ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t, 8ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t,
9 get_block_t, dio_iodone_t, int flags); 9 get_block_t, dio_iodone_t, int flags);
10int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size);
11int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t); 10int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t);
12int dax_truncate_page(struct inode *, loff_t from, get_block_t); 11int dax_truncate_page(struct inode *, loff_t from, get_block_t);
13int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t); 12int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t);