aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-11-04 13:08:12 -0400
committerJens Axboe <axboe@fb.com>2016-11-04 16:34:47 -0400
commitf734c89cc96e9b6f903865cd2656d9d8a7e160e7 (patch)
tree9c233c6e9a202f9566f3b901e6289ac7c34abf15
parent29f3ad7d8380364c86556eedf4eedd3b3d4921dc (diff)
direct-io: Use clean_bdev_aliases() instead of handmade iteration
Use new provided function instead of an iteration through all allocated blocks. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--fs/direct-io.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/fs/direct-io.c b/fs/direct-io.c
index a5138c564019..4ea57edf3e54 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -843,24 +843,6 @@ out:
843} 843}
844 844
845/* 845/*
846 * Clean any dirty buffers in the blockdev mapping which alias newly-created
847 * file blocks. Only called for S_ISREG files - blockdevs do not set
848 * buffer_new
849 */
850static void clean_blockdev_aliases(struct dio *dio, struct buffer_head *map_bh)
851{
852 unsigned i;
853 unsigned nblocks;
854
855 nblocks = map_bh->b_size >> dio->inode->i_blkbits;
856
857 for (i = 0; i < nblocks; i++) {
858 unmap_underlying_metadata(map_bh->b_bdev,
859 map_bh->b_blocknr + i);
860 }
861}
862
863/*
864 * If we are not writing the entire block and get_block() allocated 846 * If we are not writing the entire block and get_block() allocated
865 * the block for us, we need to fill-in the unused portion of the 847 * the block for us, we need to fill-in the unused portion of the
866 * block with zeros. This happens only if user-buffer, fileoffset or 848 * block with zeros. This happens only if user-buffer, fileoffset or
@@ -960,11 +942,15 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
960 goto do_holes; 942 goto do_holes;
961 943
962 sdio->blocks_available = 944 sdio->blocks_available =
963 map_bh->b_size >> sdio->blkbits; 945 map_bh->b_size >> blkbits;
964 sdio->next_block_for_io = 946 sdio->next_block_for_io =
965 map_bh->b_blocknr << sdio->blkfactor; 947 map_bh->b_blocknr << sdio->blkfactor;
966 if (buffer_new(map_bh)) 948 if (buffer_new(map_bh)) {
967 clean_blockdev_aliases(dio, map_bh); 949 clean_bdev_aliases(
950 map_bh->b_bdev,
951 map_bh->b_blocknr,
952 map_bh->b_size >> blkbits);
953 }
968 954
969 if (!sdio->blkfactor) 955 if (!sdio->blkfactor)
970 goto do_holes; 956 goto do_holes;