]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/direct-io.c
Merge tag 'drm-vc4-fixes-2017-01-23' of https://github.com/anholt/linux into drm...
[karo-tx-linux.git] / fs / direct-io.c
index 835e23a4ee4b44b1c2d5a38b76fa50c1cf4b1b83..c87bae4376b848f4204c06016eeb223f675dc7db 100644 (file)
@@ -554,7 +554,7 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
  * filesystems that don't need it and also allows us to create the workqueue
  * late enough so the we can include s_id in the name of the workqueue.
  */
-static int sb_init_dio_done_wq(struct super_block *sb)
+int sb_init_dio_done_wq(struct super_block *sb)
 {
        struct workqueue_struct *old;
        struct workqueue_struct *wq = alloc_workqueue("dio/%s",
@@ -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
@@ -924,6 +906,7 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
                        struct buffer_head *map_bh)
 {
        const unsigned blkbits = sdio->blkbits;
+       const unsigned i_blkbits = blkbits + sdio->blkfactor;
        int ret = 0;
 
        while (sdio->block_in_file < sdio->final_block_in_request) {
@@ -960,11 +943,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 >> i_blkbits);
+                               }
 
                                if (!sdio->blkfactor)
                                        goto do_holes;