diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/llite/rw26.c')
-rw-r--r-- | drivers/staging/lustre/lustre/llite/rw26.c | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 711fda93a58d..7a5db67bc680 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -92,9 +92,9 @@ static void ll_invalidatepage(struct page *vmpage, unsigned int offset, if (!IS_ERR(env)) { inode = vmpage->mapping->host; obj = ll_i2info(inode)->lli_clob; - if (obj != NULL) { + if (obj) { page = cl_vmpage_page(vmpage, obj); - if (page != NULL) { + if (page) { lu_ref_add(&page->cp_reference, "delete", vmpage); cl_page_delete(env, page); @@ -109,12 +109,7 @@ static void ll_invalidatepage(struct page *vmpage, unsigned int offset, } } -#ifdef HAVE_RELEASEPAGE_WITH_INT -#define RELEASEPAGE_ARG_TYPE int -#else -#define RELEASEPAGE_ARG_TYPE gfp_t -#endif -static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask) +static int ll_releasepage(struct page *vmpage, gfp_t gfp_mask) { struct cl_env_nest nest; struct lu_env *env; @@ -128,11 +123,11 @@ static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask) return 0; mapping = vmpage->mapping; - if (mapping == NULL) + if (!mapping) return 1; obj = ll_i2info(mapping->host)->lli_clob; - if (obj == NULL) + if (!obj) return 1; /* 1 for page allocator, 1 for cl_page and 1 for page cache */ @@ -145,12 +140,13 @@ static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask) /* If we can't allocate an env we won't call cl_page_put() * later on which further means it's impossible to drop * page refcount by cl_page, so ask kernel to not free - * this page. */ + * this page. + */ return 0; page = cl_vmpage_page(vmpage, obj); - result = page == NULL; - if (page != NULL) { + result = !page; + if (page) { if (!cl_page_in_use(page)) { result = 1; cl_page_delete(env, page); @@ -212,7 +208,8 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr, } /* ll_free_user_pages - tear down page struct array - * @pages: array of page struct pointers underlying target buffer */ + * @pages: array of page struct pointers underlying target buffer + */ static void ll_free_user_pages(struct page **pages, int npages, int do_dirty) { int i; @@ -246,7 +243,7 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, cl_2queue_init(queue); for (i = 0; i < page_count; i++) { if (pv->ldp_offsets) - file_offset = pv->ldp_offsets[i]; + file_offset = pv->ldp_offsets[i]; LASSERT(!(file_offset & (page_size - 1))); clp = cl_page_find(env, obj, cl_index(obj, file_offset), @@ -266,7 +263,8 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, do_io = true; /* check the page type: if the page is a host page, then do - * write directly */ + * write directly + */ if (clp->cp_type == CPT_CACHEABLE) { struct page *vmpage = cl_page_vmpage(env, clp); struct page *src_page; @@ -284,14 +282,16 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, kunmap_atomic(src); /* make sure page will be added to the transfer by - * cl_io_submit()->...->vvp_page_prep_write(). */ + * cl_io_submit()->...->vvp_page_prep_write(). + */ if (rw == WRITE) set_page_dirty(vmpage); if (rw == READ) { /* do not issue the page for read, since it * may reread a ra page which has NOT uptodate - * bit set. */ + * bit set. + */ cl_page_disown(env, io, clp); do_io = false; } @@ -339,29 +339,25 @@ static ssize_t ll_direct_IO_26_seg(const struct lu_env *env, struct cl_io *io, size_t size, loff_t file_offset, struct page **pages, int page_count) { - struct ll_dio_pages pvec = { .ldp_pages = pages, - .ldp_nr = page_count, - .ldp_size = size, - .ldp_offsets = NULL, - .ldp_start_offset = file_offset - }; - - return ll_direct_rw_pages(env, io, rw, inode, &pvec); + struct ll_dio_pages pvec = { + .ldp_pages = pages, + .ldp_nr = page_count, + .ldp_size = size, + .ldp_offsets = NULL, + .ldp_start_offset = file_offset + }; + + return ll_direct_rw_pages(env, io, rw, inode, &pvec); } -#ifdef KMALLOC_MAX_SIZE -#define MAX_MALLOC KMALLOC_MAX_SIZE -#else -#define MAX_MALLOC (128 * 1024) -#endif - /* This is the maximum size of a single O_DIRECT request, based on the * kmalloc limit. We need to fit all of the brw_page structs, each one * representing PAGE_SIZE worth of user data, into a single buffer, and * then truncate this to be a full-sized RPC. For 4kB PAGE_SIZE this is - * up to 22MB for 128kB kmalloc and up to 682MB for 4MB kmalloc. */ -#define MAX_DIO_SIZE ((MAX_MALLOC / sizeof(struct brw_page) * PAGE_CACHE_SIZE) & \ - ~(DT_MAX_BRW_SIZE - 1)) + * up to 22MB for 128kB kmalloc and up to 682MB for 4MB kmalloc. + */ +#define MAX_DIO_SIZE ((KMALLOC_MAX_SIZE / sizeof(struct brw_page) * \ + PAGE_CACHE_SIZE) & ~(DT_MAX_BRW_SIZE - 1)) static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter, loff_t file_offset) { @@ -396,7 +392,7 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter, env = cl_env_get(&refcheck); LASSERT(!IS_ERR(env)); io = ccc_env_io(env)->cui_cl.cis_io; - LASSERT(io != NULL); + LASSERT(io); /* 0. Need locking between buffered and direct access. and race with * size changing by concurrent truncates and writes. @@ -433,7 +429,8 @@ static ssize_t ll_direct_IO_26(struct kiocb *iocb, struct iov_iter *iter, * for the request, shrink it to a smaller * PAGE_SIZE multiple and try again. * We should always be able to kmalloc for a - * page worth of page pointers = 4MB on i386. */ + * page worth of page pointers = 4MB on i386. + */ if (result == -ENOMEM && size > (PAGE_CACHE_SIZE / sizeof(*pages)) * PAGE_CACHE_SIZE) { @@ -461,7 +458,7 @@ out: struct lov_stripe_md *lsm; lsm = ccc_inode_lsm_get(inode); - LASSERT(lsm != NULL); + LASSERT(lsm); lov_stripe_lock(lsm); obd_adjust_kms(ll_i2dtexp(inode), lsm, file_offset, 0); lov_stripe_unlock(lsm); @@ -474,8 +471,8 @@ out: } static int ll_write_begin(struct file *file, struct address_space *mapping, - loff_t pos, unsigned len, unsigned flags, - struct page **pagep, void **fsdata) + loff_t pos, unsigned len, unsigned flags, + struct page **pagep, void **fsdata) { pgoff_t index = pos >> PAGE_CACHE_SHIFT; struct page *page; @@ -512,8 +509,8 @@ static int ll_write_end(struct file *file, struct address_space *mapping, #ifdef CONFIG_MIGRATION static int ll_migratepage(struct address_space *mapping, - struct page *newpage, struct page *page, - enum migrate_mode mode + struct page *newpage, struct page *page, + enum migrate_mode mode ) { /* Always fail page migration until we have a proper implementation */ |