~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to fs/nfs/pagelist.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
204
204
                        TASK_UNINTERRUPTIBLE);
205
205
}
206
206
 
 
207
bool nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, struct nfs_page *prev, struct nfs_page *req)
 
208
{
 
209
        /*
 
210
         * FIXME: ideally we should be able to coalesce all requests
 
211
         * that are not block boundary aligned, but currently this
 
212
         * is problematic for the case of bsize < PAGE_CACHE_SIZE,
 
213
         * since nfs_flush_multi and nfs_pagein_multi assume you
 
214
         * can have only one struct nfs_page.
 
215
         */
 
216
        if (desc->pg_bsize < PAGE_SIZE)
 
217
                return 0;
 
218
 
 
219
        return desc->pg_count + req->wb_bytes <= desc->pg_bsize;
 
220
}
 
221
EXPORT_SYMBOL_GPL(nfs_generic_pg_test);
 
222
 
207
223
/**
208
224
 * nfs_pageio_init - initialise a page io descriptor
209
225
 * @desc: pointer to descriptor
229
245
        desc->pg_ioflags = io_flags;
230
246
        desc->pg_error = 0;
231
247
        desc->pg_lseg = NULL;
 
248
        desc->pg_test = nfs_generic_pg_test;
 
249
        pnfs_pageio_init(desc, inode);
232
250
}
233
251
 
234
252
/**
242
260
 *
243
261
 * Return 'true' if this is the case, else return 'false'.
244
262
 */
245
 
static int nfs_can_coalesce_requests(struct nfs_page *prev,
246
 
                                     struct nfs_page *req,
247
 
                                     struct nfs_pageio_descriptor *pgio)
 
263
static bool nfs_can_coalesce_requests(struct nfs_page *prev,
 
264
                                      struct nfs_page *req,
 
265
                                      struct nfs_pageio_descriptor *pgio)
248
266
{
249
267
        if (req->wb_context->cred != prev->wb_context->cred)
250
 
                return 0;
 
268
                return false;
251
269
        if (req->wb_lock_context->lockowner != prev->wb_lock_context->lockowner)
252
 
                return 0;
 
270
                return false;
253
271
        if (req->wb_context->state != prev->wb_context->state)
254
 
                return 0;
 
272
                return false;
255
273
        if (req->wb_index != (prev->wb_index + 1))
256
 
                return 0;
 
274
                return false;
257
275
        if (req->wb_pgbase != 0)
258
 
                return 0;
 
276
                return false;
259
277
        if (prev->wb_pgbase + prev->wb_bytes != PAGE_CACHE_SIZE)
260
 
                return 0;
261
 
        /*
262
 
         * Non-whole file layouts need to check that req is inside of
263
 
         * pgio->pg_lseg.
264
 
         */
265
 
        if (pgio->pg_test && !pgio->pg_test(pgio, prev, req))
266
 
                return 0;
267
 
        return 1;
 
278
                return false;
 
279
        return pgio->pg_test(pgio, prev, req);
268
280
}
269
281
 
270
282
/**
278
290
static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
279
291
                                     struct nfs_page *req)
280
292
{
281
 
        size_t newlen = req->wb_bytes;
282
 
 
283
293
        if (desc->pg_count != 0) {
284
294
                struct nfs_page *prev;
285
295
 
286
 
                /*
287
 
                 * FIXME: ideally we should be able to coalesce all requests
288
 
                 * that are not block boundary aligned, but currently this
289
 
                 * is problematic for the case of bsize < PAGE_CACHE_SIZE,
290
 
                 * since nfs_flush_multi and nfs_pagein_multi assume you
291
 
                 * can have only one struct nfs_page.
292
 
                 */
293
 
                if (desc->pg_bsize < PAGE_SIZE)
294
 
                        return 0;
295
 
                newlen += desc->pg_count;
296
 
                if (newlen > desc->pg_bsize)
297
 
                        return 0;
298
296
                prev = nfs_list_entry(desc->pg_list.prev);
299
297
                if (!nfs_can_coalesce_requests(prev, req, desc))
300
298
                        return 0;
301
 
        } else
 
299
        } else {
302
300
                desc->pg_base = req->wb_pgbase;
 
301
        }
303
302
        nfs_list_remove_request(req);
304
303
        nfs_list_add_request(req, &desc->pg_list);
305
 
        desc->pg_count = newlen;
 
304
        desc->pg_count += req->wb_bytes;
306
305
        return 1;
307
306
}
308
307