diff options
-rw-r--r-- | fs/nfs/direct.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 345aa5c0f382..6c588ec84d1c 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -122,9 +122,9 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_ | |||
122 | return -EINVAL; | 122 | return -EINVAL; |
123 | } | 123 | } |
124 | 124 | ||
125 | static void nfs_direct_dirty_pages(struct page **pages, int npages) | 125 | static void nfs_direct_dirty_pages(struct page **pages, unsigned int npages) |
126 | { | 126 | { |
127 | int i; | 127 | unsigned int i; |
128 | for (i = 0; i < npages; i++) { | 128 | for (i = 0; i < npages; i++) { |
129 | struct page *page = pages[i]; | 129 | struct page *page = pages[i]; |
130 | if (!PageCompound(page)) | 130 | if (!PageCompound(page)) |
@@ -132,9 +132,9 @@ static void nfs_direct_dirty_pages(struct page **pages, int npages) | |||
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | static void nfs_direct_release_pages(struct page **pages, int npages) | 135 | static void nfs_direct_release_pages(struct page **pages, unsigned int npages) |
136 | { | 136 | { |
137 | int i; | 137 | unsigned int i; |
138 | for (i = 0; i < npages; i++) | 138 | for (i = 0; i < npages; i++) |
139 | page_cache_release(pages[i]); | 139 | page_cache_release(pages[i]); |
140 | } | 140 | } |
@@ -279,9 +279,12 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo | |||
279 | result = get_user_pages(current, current->mm, user_addr, | 279 | result = get_user_pages(current, current->mm, user_addr, |
280 | data->npages, 1, 0, data->pagevec, NULL); | 280 | data->npages, 1, 0, data->pagevec, NULL); |
281 | up_read(¤t->mm->mmap_sem); | 281 | up_read(¤t->mm->mmap_sem); |
282 | if (unlikely(result < data->npages)) { | 282 | if (result < 0) { |
283 | if (result > 0) | 283 | nfs_readdata_release(data); |
284 | nfs_direct_release_pages(data->pagevec, result); | 284 | break; |
285 | } | ||
286 | if ((unsigned)result < data->npages) { | ||
287 | nfs_direct_release_pages(data->pagevec, result); | ||
285 | nfs_readdata_release(data); | 288 | nfs_readdata_release(data); |
286 | break; | 289 | break; |
287 | } | 290 | } |
@@ -610,9 +613,12 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l | |||
610 | result = get_user_pages(current, current->mm, user_addr, | 613 | result = get_user_pages(current, current->mm, user_addr, |
611 | data->npages, 0, 0, data->pagevec, NULL); | 614 | data->npages, 0, 0, data->pagevec, NULL); |
612 | up_read(¤t->mm->mmap_sem); | 615 | up_read(¤t->mm->mmap_sem); |
613 | if (unlikely(result < data->npages)) { | 616 | if (result < 0) { |
614 | if (result > 0) | 617 | nfs_writedata_release(data); |
615 | nfs_direct_release_pages(data->pagevec, result); | 618 | break; |
619 | } | ||
620 | if ((unsigned)result < data->npages) { | ||
621 | nfs_direct_release_pages(data->pagevec, result); | ||
616 | nfs_writedata_release(data); | 622 | nfs_writedata_release(data); |
617 | break; | 623 | break; |
618 | } | 624 | } |