direct-io: Use clean_bdev_aliases() instead of handmade iteration
authorJan Kara <jack@suse.cz>
Fri, 4 Nov 2016 17:08:12 +0000 (18:08 +0100)
committerJens Axboe <axboe@fb.com>
Fri, 4 Nov 2016 20:34:47 +0000 (14:34 -0600)
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>
fs/direct-io.c

index a5138c564019a4ca863b0540f7503f0a55ecd27e..4ea57edf3e54c62ba33cd5884e8c72c0920d15d5 100644 (file)
@@ -842,24 +842,6 @@ out:
        return ret;
 }
 
-/*
- * Clean any dirty buffers in the blockdev mapping which alias newly-created
- * file blocks.  Only called for S_ISREG files - blockdevs do not set
- * buffer_new
- */
-static void clean_blockdev_aliases(struct dio *dio, struct buffer_head *map_bh)
-{
-       unsigned i;
-       unsigned nblocks;
-
-       nblocks = map_bh->b_size >> dio->inode->i_blkbits;
-
-       for (i = 0; i < nblocks; i++) {
-               unmap_underlying_metadata(map_bh->b_bdev,
-                                         map_bh->b_blocknr + i);
-       }
-}
-
 /*
  * If we are not writing the entire block and get_block() allocated
  * the block for us, we need to fill-in the unused portion of the
@@ -960,11 +942,15 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
                                        goto do_holes;
 
                                sdio->blocks_available =
-                                               map_bh->b_size >> sdio->blkbits;
+                                               map_bh->b_size >> blkbits;
                                sdio->next_block_for_io =
                                        map_bh->b_blocknr << sdio->blkfactor;
-                               if (buffer_new(map_bh))
-                                       clean_blockdev_aliases(dio, map_bh);
+                               if (buffer_new(map_bh)) {
+                                       clean_bdev_aliases(
+                                               map_bh->b_bdev,
+                                               map_bh->b_blocknr,
+                                               map_bh->b_size >> blkbits);
+                               }
 
                                if (!sdio->blkfactor)
                                        goto do_holes;