Skip to content

Commit 3dc2916

Browse files
Matthew Wilcoxstellarhopper
authored andcommitted
dax: use sb_issue_zerout instead of calling dax_clear_sectors
dax_clear_sectors() cannot handle poisoned blocks. These must be zeroed using the BIO interface instead. Convert ext2 and XFS to use only sb_issue_zerout(). Reviewed-by: Jeff Moyer <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Matthew Wilcox <[email protected]> [vishal: Also remove the dax_clear_sectors function entirely] Signed-off-by: Vishal Verma <[email protected]>
1 parent 0a70bd4 commit 3dc2916

File tree

4 files changed

+8
-48
lines changed

4 files changed

+8
-48
lines changed

fs/dax.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -87,38 +87,6 @@ struct page *read_dax_sector(struct block_device *bdev, sector_t n)
8787
return page;
8888
}
8989

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-
*/
95-
int 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-
}
120-
EXPORT_SYMBOL_GPL(dax_clear_sectors);
121-
12290
static bool buffer_written(struct buffer_head *bh)
12391
{
12492
return buffer_mapped(bh) && !buffer_unwritten(bh);

fs/ext2/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/highuid.h>
2727
#include <linux/pagemap.h>
2828
#include <linux/dax.h>
29+
#include <linux/blkdev.h>
2930
#include <linux/quotaops.h>
3031
#include <linux/writeback.h>
3132
#include <linux/buffer_head.h>
@@ -737,10 +738,9 @@ static int ext2_get_blocks(struct inode *inode,
737738
* so that it's not found by another thread before it's
738739
* initialised
739740
*/
740-
err = dax_clear_sectors(inode->i_sb->s_bdev,
741-
le32_to_cpu(chain[depth-1].key) <<
742-
(inode->i_blkbits - 9),
743-
count << inode->i_blkbits);
741+
err = sb_issue_zeroout(inode->i_sb,
742+
le32_to_cpu(chain[depth-1].key), count,
743+
GFP_NOFS);
744744
if (err) {
745745
mutex_unlock(&ei->truncate_mutex);
746746
goto cleanup;

fs/xfs/xfs_bmap_util.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,11 @@ xfs_zero_extent(
7272
struct xfs_mount *mp = ip->i_mount;
7373
xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb);
7474
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);
8675

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);
8780
}
8881

8982
/*

include/linux/dax.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t,
99
get_block_t, dio_iodone_t, int flags);
10-
int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size);
1110
int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t);
1211
int dax_truncate_page(struct inode *, loff_t from, get_block_t);
1312
int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t);

0 commit comments

Comments
 (0)