Commit 749e146e authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

NFS: Fix handful of compiler warnings in direct.c

This patch fixes a couple of signage issues that were causing an Oops
when running the LTP diotest4 test. get_user_pages() returns a signed
error, hence we need to be careful when comparing with the unsigned
number of pages from data->npages.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 7fe7f848
...@@ -122,9 +122,9 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_ ...@@ -122,9 +122,9 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_
return -EINVAL; return -EINVAL;
} }
static void nfs_direct_dirty_pages(struct page **pages, int npages) static void nfs_direct_dirty_pages(struct page **pages, unsigned int npages)
{ {
int i; unsigned int i;
for (i = 0; i < npages; i++) { for (i = 0; i < npages; i++) {
struct page *page = pages[i]; struct page *page = pages[i];
if (!PageCompound(page)) if (!PageCompound(page))
...@@ -132,9 +132,9 @@ static void nfs_direct_dirty_pages(struct page **pages, int npages) ...@@ -132,9 +132,9 @@ static void nfs_direct_dirty_pages(struct page **pages, int npages)
} }
} }
static void nfs_direct_release_pages(struct page **pages, int npages) static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
{ {
int i; unsigned int i;
for (i = 0; i < npages; i++) for (i = 0; i < npages; i++)
page_cache_release(pages[i]); page_cache_release(pages[i]);
} }
...@@ -279,9 +279,12 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo ...@@ -279,9 +279,12 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo
result = get_user_pages(current, current->mm, user_addr, result = get_user_pages(current, current->mm, user_addr,
data->npages, 1, 0, data->pagevec, NULL); data->npages, 1, 0, data->pagevec, NULL);
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
if (unlikely(result < data->npages)) { if (result < 0) {
if (result > 0) nfs_readdata_release(data);
nfs_direct_release_pages(data->pagevec, result); break;
}
if ((unsigned)result < data->npages) {
nfs_direct_release_pages(data->pagevec, result);
nfs_readdata_release(data); nfs_readdata_release(data);
break; break;
} }
...@@ -610,9 +613,12 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l ...@@ -610,9 +613,12 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l
result = get_user_pages(current, current->mm, user_addr, result = get_user_pages(current, current->mm, user_addr,
data->npages, 0, 0, data->pagevec, NULL); data->npages, 0, 0, data->pagevec, NULL);
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
if (unlikely(result < data->npages)) { if (result < 0) {
if (result > 0) nfs_writedata_release(data);
nfs_direct_release_pages(data->pagevec, result); break;
}
if ((unsigned)result < data->npages) {
nfs_direct_release_pages(data->pagevec, result);
nfs_writedata_release(data); nfs_writedata_release(data);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment