diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 5c74b68935ac..df343d1e6345 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/backing-dev.h> | 28 | #include <linux/backing-dev.h> |
29 | #include <linux/pagevec.h> | 29 | #include <linux/pagevec.h> |
30 | #include <linux/blkdev.h> | 30 | #include <linux/blkdev.h> |
31 | #include <linux/backing-dev.h> | ||
32 | #include <linux/security.h> | 31 | #include <linux/security.h> |
33 | #include <linux/syscalls.h> | 32 | #include <linux/syscalls.h> |
34 | #include <linux/cpuset.h> | 33 | #include <linux/cpuset.h> |
@@ -1743,21 +1742,27 @@ size_t iov_iter_copy_from_user(struct page *page, | |||
1743 | } | 1742 | } |
1744 | EXPORT_SYMBOL(iov_iter_copy_from_user); | 1743 | EXPORT_SYMBOL(iov_iter_copy_from_user); |
1745 | 1744 | ||
1746 | static void __iov_iter_advance_iov(struct iov_iter *i, size_t bytes) | 1745 | void iov_iter_advance(struct iov_iter *i, size_t bytes) |
1747 | { | 1746 | { |
1747 | BUG_ON(i->count < bytes); | ||
1748 | |||
1748 | if (likely(i->nr_segs == 1)) { | 1749 | if (likely(i->nr_segs == 1)) { |
1749 | i->iov_offset += bytes; | 1750 | i->iov_offset += bytes; |
1751 | i->count -= bytes; | ||
1750 | } else { | 1752 | } else { |
1751 | const struct iovec *iov = i->iov; | 1753 | const struct iovec *iov = i->iov; |
1752 | size_t base = i->iov_offset; | 1754 | size_t base = i->iov_offset; |
1753 | 1755 | ||
1754 | /* | 1756 | /* |
1755 | * The !iov->iov_len check ensures we skip over unlikely | 1757 | * The !iov->iov_len check ensures we skip over unlikely |
1756 | * zero-length segments. | 1758 | * zero-length segments (without overruning the iovec). |
1757 | */ | 1759 | */ |
1758 | while (bytes || !iov->iov_len) { | 1760 | while (bytes || unlikely(!iov->iov_len && i->count)) { |
1759 | int copy = min(bytes, iov->iov_len - base); | 1761 | int copy; |
1760 | 1762 | ||
1763 | copy = min(bytes, iov->iov_len - base); | ||
1764 | BUG_ON(!i->count || i->count < copy); | ||
1765 | i->count -= copy; | ||
1761 | bytes -= copy; | 1766 | bytes -= copy; |
1762 | base += copy; | 1767 | base += copy; |
1763 | if (iov->iov_len == base) { | 1768 | if (iov->iov_len == base) { |
@@ -1769,14 +1774,6 @@ static void __iov_iter_advance_iov(struct iov_iter *i, size_t bytes) | |||
1769 | i->iov_offset = base; | 1774 | i->iov_offset = base; |
1770 | } | 1775 | } |
1771 | } | 1776 | } |
1772 | |||
1773 | void iov_iter_advance(struct iov_iter *i, size_t bytes) | ||
1774 | { | ||
1775 | BUG_ON(i->count < bytes); | ||
1776 | |||
1777 | __iov_iter_advance_iov(i, bytes); | ||
1778 | i->count -= bytes; | ||
1779 | } | ||
1780 | EXPORT_SYMBOL(iov_iter_advance); | 1777 | EXPORT_SYMBOL(iov_iter_advance); |
1781 | 1778 | ||
1782 | /* | 1779 | /* |