diff options
| -rw-r--r-- | mm/filemap.c | 11 | ||||
| -rw-r--r-- | mm/truncate.c | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 54e968650855..876bc595d0f8 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
| @@ -2129,13 +2129,20 @@ generic_file_direct_write(struct kiocb *iocb, const struct iovec *iov, | |||
| 2129 | * After a write we want buffered reads to be sure to go to disk to get | 2129 | * After a write we want buffered reads to be sure to go to disk to get |
| 2130 | * the new data. We invalidate clean cached page from the region we're | 2130 | * the new data. We invalidate clean cached page from the region we're |
| 2131 | * about to write. We do this *before* the write so that we can return | 2131 | * about to write. We do this *before* the write so that we can return |
| 2132 | * -EIO without clobbering -EIOCBQUEUED from ->direct_IO(). | 2132 | * without clobbering -EIOCBQUEUED from ->direct_IO(). |
| 2133 | */ | 2133 | */ |
| 2134 | if (mapping->nrpages) { | 2134 | if (mapping->nrpages) { |
| 2135 | written = invalidate_inode_pages2_range(mapping, | 2135 | written = invalidate_inode_pages2_range(mapping, |
| 2136 | pos >> PAGE_CACHE_SHIFT, end); | 2136 | pos >> PAGE_CACHE_SHIFT, end); |
| 2137 | if (written) | 2137 | /* |
| 2138 | * If a page can not be invalidated, return 0 to fall back | ||
| 2139 | * to buffered write. | ||
| 2140 | */ | ||
| 2141 | if (written) { | ||
| 2142 | if (written == -EBUSY) | ||
| 2143 | return 0; | ||
| 2138 | goto out; | 2144 | goto out; |
| 2145 | } | ||
| 2139 | } | 2146 | } |
| 2140 | 2147 | ||
| 2141 | written = mapping->a_ops->direct_IO(WRITE, iocb, iov, pos, *nr_segs); | 2148 | written = mapping->a_ops->direct_IO(WRITE, iocb, iov, pos, *nr_segs); |
diff --git a/mm/truncate.c b/mm/truncate.c index 250505091d37..6650c1d878b4 100644 --- a/mm/truncate.c +++ b/mm/truncate.c | |||
| @@ -380,7 +380,7 @@ static int do_launder_page(struct address_space *mapping, struct page *page) | |||
| 380 | * Any pages which are found to be mapped into pagetables are unmapped prior to | 380 | * Any pages which are found to be mapped into pagetables are unmapped prior to |
| 381 | * invalidation. | 381 | * invalidation. |
| 382 | * | 382 | * |
| 383 | * Returns -EIO if any pages could not be invalidated. | 383 | * Returns -EBUSY if any pages could not be invalidated. |
| 384 | */ | 384 | */ |
| 385 | int invalidate_inode_pages2_range(struct address_space *mapping, | 385 | int invalidate_inode_pages2_range(struct address_space *mapping, |
| 386 | pgoff_t start, pgoff_t end) | 386 | pgoff_t start, pgoff_t end) |
| @@ -440,7 +440,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping, | |||
| 440 | ret2 = do_launder_page(mapping, page); | 440 | ret2 = do_launder_page(mapping, page); |
| 441 | if (ret2 == 0) { | 441 | if (ret2 == 0) { |
| 442 | if (!invalidate_complete_page2(mapping, page)) | 442 | if (!invalidate_complete_page2(mapping, page)) |
| 443 | ret2 = -EIO; | 443 | ret2 = -EBUSY; |
| 444 | } | 444 | } |
| 445 | if (ret2 < 0) | 445 | if (ret2 < 0) |
| 446 | ret = ret2; | 446 | ret = ret2; |
