aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 6c588ec84d1c..0c542ec92d5b 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -122,13 +122,19 @@ 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
125static void nfs_direct_dirty_pages(struct page **pages, unsigned int npages) 125static void nfs_direct_dirty_pages(struct page **pages, unsigned int pgbase, size_t count)
126{ 126{
127 unsigned int npages;
127 unsigned int i; 128 unsigned int i;
129
130 if (count == 0)
131 return;
132 pages += (pgbase >> PAGE_SHIFT);
133 npages = (count + (pgbase & ~PAGE_MASK) + PAGE_SIZE - 1) >> PAGE_SHIFT;
128 for (i = 0; i < npages; i++) { 134 for (i = 0; i < npages; i++) {
129 struct page *page = pages[i]; 135 struct page *page = pages[i];
130 if (!PageCompound(page)) 136 if (!PageCompound(page))
131 set_page_dirty_lock(page); 137 set_page_dirty(page);
132 } 138 }
133} 139}
134 140
@@ -224,17 +230,18 @@ static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
224 if (nfs_readpage_result(task, data) != 0) 230 if (nfs_readpage_result(task, data) != 0)
225 return; 231 return;
226 232
227 nfs_direct_dirty_pages(data->pagevec, data->npages);
228 nfs_direct_release_pages(data->pagevec, data->npages);
229
230 spin_lock(&dreq->lock); 233 spin_lock(&dreq->lock);
231 234 if (unlikely(task->tk_status < 0)) {
232 if (likely(task->tk_status >= 0))
233 dreq->count += data->res.count;
234 else
235 dreq->error = task->tk_status; 235 dreq->error = task->tk_status;
236 236 spin_unlock(&dreq->lock);
237 spin_unlock(&dreq->lock); 237 } else {
238 dreq->count += data->res.count;
239 spin_unlock(&dreq->lock);
240 nfs_direct_dirty_pages(data->pagevec,
241 data->args.pgbase,
242 data->res.count);
243 }
244 nfs_direct_release_pages(data->pagevec, data->npages);
238 245
239 if (put_dreq(dreq)) 246 if (put_dreq(dreq))
240 nfs_direct_complete(dreq); 247 nfs_direct_complete(dreq);