diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 3277f3b23524..c4fe97f5ace0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -2020,6 +2020,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i | |||
2020 | if (unlikely(*pos + *count > inode->i_sb->s_maxbytes)) | 2020 | if (unlikely(*pos + *count > inode->i_sb->s_maxbytes)) |
2021 | *count = inode->i_sb->s_maxbytes - *pos; | 2021 | *count = inode->i_sb->s_maxbytes - *pos; |
2022 | } else { | 2022 | } else { |
2023 | #ifdef CONFIG_BLOCK | ||
2023 | loff_t isize; | 2024 | loff_t isize; |
2024 | if (bdev_read_only(I_BDEV(inode))) | 2025 | if (bdev_read_only(I_BDEV(inode))) |
2025 | return -EPERM; | 2026 | return -EPERM; |
@@ -2031,6 +2032,9 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i | |||
2031 | 2032 | ||
2032 | if (*pos + *count > isize) | 2033 | if (*pos + *count > isize) |
2033 | *count = isize - *pos; | 2034 | *count = isize - *pos; |
2035 | #else | ||
2036 | return -EPERM; | ||
2037 | #endif | ||
2034 | } | 2038 | } |
2035 | return 0; | 2039 | return 0; |
2036 | } | 2040 | } |
@@ -2491,3 +2495,33 @@ generic_file_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, | |||
2491 | } | 2495 | } |
2492 | return retval; | 2496 | return retval; |
2493 | } | 2497 | } |
2498 | |||
2499 | /** | ||
2500 | * try_to_release_page() - release old fs-specific metadata on a page | ||
2501 | * | ||
2502 | * @page: the page which the kernel is trying to free | ||
2503 | * @gfp_mask: memory allocation flags (and I/O mode) | ||
2504 | * | ||
2505 | * The address_space is to try to release any data against the page | ||
2506 | * (presumably at page->private). If the release was successful, return `1'. | ||
2507 | * Otherwise return zero. | ||
2508 | * | ||
2509 | * The @gfp_mask argument specifies whether I/O may be performed to release | ||
2510 | * this page (__GFP_IO), and whether the call may block (__GFP_WAIT). | ||
2511 | * | ||
2512 | * NOTE: @gfp_mask may go away, and this function may become non-blocking. | ||
2513 | */ | ||
2514 | int try_to_release_page(struct page *page, gfp_t gfp_mask) | ||
2515 | { | ||
2516 | struct address_space * const mapping = page->mapping; | ||
2517 | |||
2518 | BUG_ON(!PageLocked(page)); | ||
2519 | if (PageWriteback(page)) | ||
2520 | return 0; | ||
2521 | |||
2522 | if (mapping && mapping->a_ops->releasepage) | ||
2523 | return mapping->a_ops->releasepage(page, gfp_mask); | ||
2524 | return try_to_free_buffers(page); | ||
2525 | } | ||
2526 | |||
2527 | EXPORT_SYMBOL(try_to_release_page); | ||