|
10 | 10 | #include <linux/backing-dev.h> |
11 | 11 | #include <linux/uio.h> |
12 | 12 | #include <linux/task_io_accounting_ops.h> |
| 13 | +#include "trace.h" |
13 | 14 |
|
14 | 15 | #include "../internal.h" |
15 | 16 |
|
@@ -401,6 +402,9 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length, |
401 | 402 | * can be mapped into multiple disjoint IOs and only a subset of the IOs issued |
402 | 403 | * may be pure data writes. In that case, we still need to do a full data sync |
403 | 404 | * completion. |
| 405 | + * |
| 406 | + * Returns -ENOTBLK In case of a page invalidation invalidation failure for |
| 407 | + * writes. The callers needs to fall back to buffered I/O in this case. |
404 | 408 | */ |
405 | 409 | ssize_t |
406 | 410 | iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, |
@@ -478,13 +482,15 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, |
478 | 482 | if (iov_iter_rw(iter) == WRITE) { |
479 | 483 | /* |
480 | 484 | * Try to invalidate cache pages for the range we are writing. |
481 | | - * If this invalidation fails, tough, the write will still work, |
482 | | - * but racing two incompatible write paths is a pretty crazy |
483 | | - * thing to do, so we don't support it 100%. |
| 485 | + * If this invalidation fails, let the caller fall back to |
| 486 | + * buffered I/O. |
484 | 487 | */ |
485 | 488 | if (invalidate_inode_pages2_range(mapping, pos >> PAGE_SHIFT, |
486 | | - end >> PAGE_SHIFT)) |
487 | | - dio_warn_stale_pagecache(iocb->ki_filp); |
| 489 | + end >> PAGE_SHIFT)) { |
| 490 | + trace_iomap_dio_invalidate_fail(inode, pos, count); |
| 491 | + ret = -ENOTBLK; |
| 492 | + goto out_free_dio; |
| 493 | + } |
488 | 494 |
|
489 | 495 | if (!wait_for_completion && !inode->i_sb->s_dio_done_wq) { |
490 | 496 | ret = sb_init_dio_done_wq(inode->i_sb); |
|
0 commit comments