apparmor: fix undefined reference to `aa_g_hash_policy'
[platform/kernel/linux-exynos.git] / fs / direct-io.c
index 7c3ce73..aeae8c0 100644 (file)
@@ -246,6 +246,9 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
                if ((dio->op == REQ_OP_READ) &&
                    ((offset + transferred) > dio->i_size))
                        transferred = dio->i_size - offset;
+               /* ignore EFAULT if some IO has been done */
+               if (unlikely(ret == -EFAULT) && transferred)
+                       ret = 0;
        }
 
        if (ret == 0)
@@ -454,7 +457,7 @@ static struct bio *dio_await_one(struct dio *dio)
                dio->waiter = current;
                spin_unlock_irqrestore(&dio->bio_lock, flags);
                if (!(dio->iocb->ki_flags & IOCB_HIPRI) ||
-                   !blk_poll(bdev_get_queue(dio->bio_bdev), dio->bio_cookie))
+                   !blk_mq_poll(bdev_get_queue(dio->bio_bdev), dio->bio_cookie))
                        io_schedule();
                /* wake up sets us TASK_RUNNING */
                spin_lock_irqsave(&dio->bio_lock, flags);
@@ -551,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",
@@ -840,24 +843,6 @@ out:
 }
 
 /*
- * 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
  * block with zeros. This happens only if user-buffer, fileoffset or
@@ -957,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;
@@ -1206,7 +1195,7 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
        dio->inode = inode;
        if (iov_iter_rw(iter) == WRITE) {
                dio->op = REQ_OP_WRITE;
-               dio->op_flags = WRITE_ODIRECT;
+               dio->op_flags = REQ_SYNC | REQ_IDLE;
        } else {
                dio->op = REQ_OP_READ;
        }