Page cache: Replace PAGE_CACHE_xx with inline functions
Subsystems (10)
cover Page cache: Replace PAGE_CACHE_xx with inline functions
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls.
The ultimate goal is to replace all uses of PAGE_CACHE_xxx in the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices.
Patchset against 2.6.24-rc3-mm2.
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/19 Define functions for page cache handling
We use the macros PAGE_CACHE_SIZE PAGE_CACHE_SHIFT PAGE_CACHE_MASK and PAGE_CACHE_ALIGN in various places in the kernel. Many times common operations like calculating the offset or the index are coded using shifts and adds. This patch provides inline functions to get the calculations accomplished without having to explicitly shift and add constants.
All functions take an address_space pointer. The address space pointer will be used in the future to eventually support a larger buffers. Information reachable via the mapping may then determine page size.
New function Related base page constant
====================================================================
page_cache_shift(a) PAGE_CACHE_SHIFT page_cache_size(a) PAGE_CACHE_SIZE page_cache_mask(a) PAGE_CACHE_MASK page_cache_index(a, pos) Calculate page number from position page_cache_next(addr, pos) Page number of next page page_cache_offset(a, pos) Calculate offset into a page
page_cache_pos(a, index, offset)
Form position based on page number and an offset.
This provides a basis that would allow the conversion of all page cache handling in the kernel and ultimately allow the removal of the PAGE_CACHE_* constants.
--- include/linux/pagemap.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-)
include/linux/pagemap.h +54 -0
@@ -52,12 +52,66 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)* space in smaller chunks for same flexibility). * * Or rather, it _will_ be done in larger chunks. +* +* The following constants can be used if a filesystem only supports a single +* page size. */ #define PAGE_CACHE_SHIFT PAGE_SHIFT#define PAGE_CACHE_SIZE PAGE_SIZE#define PAGE_CACHE_MASK PAGE_MASK#define PAGE_CACHE_ALIGN (addr) (((addr)+PAGE_CACHE_SIZE-1)&PAGE_CACHE_MASK) +/* +* Functions that are currently setup for a fixed PAGE_SIZEd. The use of +* these will allow a variable page size pagecache in the future. +*/ +static inline int mapping_order (struct address_space *a) +{ +return 0 ; +} + +static inline int page_cache_shift (struct address_space *a) +{ +return PAGE_SHIFT ; +} + +static inline unsigned int page_cache_size (struct address_space *a) +{ +return PAGE_SIZE ; +} + +static inline loff_t page_cache_mask (struct address_space *a) +{ +return (loff_t )PAGE_MASK ; +} + +static inline unsigned int page_cache_offset (struct address_space *a, +loff_t pos) +{ +return pos & ~PAGE_MASK ; +} + +static inline pgoff_t page_cache_index (struct address_space *a, +loff_t pos) +{ +return pos >>page_cache_shift (a); +} + +/* +* Index of the page starting on or after the given position. +*/ +static inline pgoff_t page_cache_next (struct address_space *a, +loff_t pos) +{ +return page_cache_index (a, pos +page_cache_size (a) -1 ); +} + +static inline loff_t page_cache_pos (struct address_space *a, +pgoff_t index,unsigned long offset) +{ +return ((loff_t )index <<page_cache_shift (a)) + offset; +} +#define page_cache_get (page) get_page(page)#define page_cache_release (page) put_page(page)void release_pages (struct page **pages,int nr,int cold);
Signature · 9 lines
1.5.2.5 -- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 01/19] Define functions for page cache handling
include/linux/pagemap.h static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) · line 106
Quoted 7 lines · Christoph Lameter
include/linux/pagemap.h +7
-0+/* +* Index of the page starting on or after the given position. +*/ +static inline pgoff_t page_cache_next (struct address_space *a, +loff_t pos) +{ +return page_cache_index (a, pos +page_cache_size (a) -1 );
return page_cache_index(a, pos + page_cache_mask(a));
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 01/19] Define functions for page cache handling
Quoted 10 lines · David Chinner
include/linux/pagemap.h static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) · line 106
Quoted 7 lines · Christoph Lameter
include/linux/pagemap.h +7
-0+/* +* Index of the page starting on or after the given position. +*/ +static inline pgoff_t page_cache_next (struct address_space *a, +loff_t pos) +{ +return page_cache_index (a, pos +page_cache_size (a) -1 );return page_cache_index(a, pos + page_cache_mask(a));
Na that is confusing. We really want to go to one byte before the end of the page.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 01/19] Define functions for page cache handling
In reply to Christoph Lameterinclude/linux/pagemap.h static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) · line 86
Quoted 4 lines · Christoph Lameter
include/linux/pagemap.h +4
-0+static inline loff_t page_cache_mask (struct address_space *a) +{ +return (loff_t )PAGE_MASK ; +}
A tiny question: Why choose loff_t instead of 'unsigned long'?
It's not obvious because page_cache_mask() is not referenced in this patchset at all ;-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 01/19] Define functions for page cache handling
Quoted 10 lines · Fengguang Wu
include/linux/pagemap.h static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) · line 86
Quoted 4 lines · Christoph Lameter
include/linux/pagemap.h +4
-0+static inline loff_t page_cache_mask (struct address_space *a) +{ +return (loff_t )PAGE_MASK ; +}A tiny question: Why choose
loff_tinstead of 'unsigned long'?It's not obvious because
page_cache_mask()is not referenced in this patchset at all ;-)
Ok Then lets drop page_cache_mask completely.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/19 Use page_cache_xxx functions in mm/filemap.c
In reply to Christoph LameterConvert the uses of PAGE_CACHE_xxx to use page_cache_xxx instead.
--- mm/filemap.c | 91 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 45 deletions(-)
mm/filemap.c +46 -45
@@ -314,8 +314,8 @@ EXPORT_SYMBOL(add_to_page_cache_lru);int sync_page_range (struct inode *inode,struct address_space *mapping,loff_t pos,loff_t count) { -pgoff_t start = pos >>PAGE_CACHE_SHIFT ; -pgoff_t end = (pos + count -1 ) >>PAGE_CACHE_SHIFT ; +pgoff_t start =page_cache_index (mapping, pos); +pgoff_t end =page_cache_index (mapping, pos + count -1 );int ret;if (!mapping_cap_writeback_dirty (mapping) || !count)
@@ -346,8 +346,8 @@ EXPORT_SYMBOL(sync_page_range);int sync_page_range_nolock (struct inode *inode,struct address_space *mapping,loff_t pos,loff_t count) { -pgoff_t start = pos >>PAGE_CACHE_SHIFT ; -pgoff_t end = (pos + count -1 ) >>PAGE_CACHE_SHIFT ; +pgoff_t start =page_cache_index (mapping, pos); +pgoff_t end =page_cache_index (mapping, pos + count -1 );int ret;if (!mapping_cap_writeback_dirty (mapping) || !count)
@@ -376,7 +376,7 @@ int filemap_fdatawait(struct address_spareturn 0 ;return wait_on_page_writeback_range (mapping,0 , - (i_size -1 ) >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, i_size -1 )); }EXPORT_SYMBOL (filemap_fdatawait);
@@ -424,8 +424,8 @@ int filemap_write_and_wait_range(struct/* See comment of filemap_write_and_wait() */ if (err != -EIO ) {int err2 =wait_on_page_writeback_range (mapping, - lstart >>PAGE_CACHE_SHIFT , - lend >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, lstart), +page_cache_index (mapping, lend));if (!err) err = err2; }
@@ -897,11 +897,11 @@ void do_generic_mapping_read(struct addrunsigned int prev_offset;int error; - index = *ppos >>PAGE_CACHE_SHIFT ; - prev_index = ra->prev_pos >>PAGE_CACHE_SHIFT ; - prev_offset = ra->prev_pos & (PAGE_CACHE_SIZE -1 ); - last_index = (*ppos + desc->count +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; - offset = *ppos & ~PAGE_CACHE_MASK ; + index =page_cache_index (mapping, *ppos); + prev_index =page_cache_index (mapping, ra->prev_pos); + prev_offset =page_cache_offset (mapping, ra->prev_pos); + last_index =page_cache_next (mapping, *ppos + desc->count); + offset =page_cache_offset (mapping, *ppos);for (;;) {struct page *page;
@@ -938,16 +938,16 @@ page_ok:*/ isize =i_size_read (inode); - end_index = (isize -1 ) >>PAGE_CACHE_SHIFT ; + end_index =page_cache_index (mapping, isize -1 );if (unlikely (!isize || index > end_index)) {page_cache_release (page); goto out; }/* nr is the maximum number of bytes to copy from this page */ - nr =PAGE_CACHE_SIZE ; + nr =page_cache_size (mapping);if (index == end_index) { - nr = ((isize -1 ) & ~PAGE_CACHE_MASK ) +1 ; + nr =page_cache_offset (mapping, isize -1 ) +1 ;if (nr <= offset) {page_cache_release (page); goto out;
@@ -982,8 +982,8 @@ page_ok:*/ ret =actor (desc, page, offset, nr); offset += ret; - index += offset >>PAGE_CACHE_SHIFT ; - offset &= ~PAGE_CACHE_MASK ; + index +=page_cache_index (mapping, offset); + offset =page_cache_offset (mapping, offset); prev_offset = offset;page_cache_release (page);
@@ -1073,11 +1073,8 @@ no_cached_page: } out: - ra->prev_pos = prev_index; - ra->prev_pos <<=PAGE_CACHE_SHIFT ; - ra->prev_pos |= prev_offset; - - *ppos = ((loff_t )index <<PAGE_CACHE_SHIFT ) + offset; + ra->prev_pos =page_cache_pos (mapping, prev_index, prev_offset); + *ppos =page_cache_pos (mapping, index, offset);if (filp)file_accessed (filp); }
@@ -1257,8 +1254,8 @@ asmlinkage ssize_t sys_readahead(int fd,if (file) {if (file->f_mode &FMODE_READ ) {struct address_space *mapping = file->f_mapping; -pgoff_t start = offset >>PAGE_CACHE_SHIFT ; -pgoff_t end = (offset + count -1 ) >>PAGE_CACHE_SHIFT ; +pgoff_t start =page_cache_index (mapping, offset); +pgoff_t end =page_cache_index (mapping, offset + count -1 );unsigned long len = end - start +1 ; ret =do_readahead (mapping, file, start, len); }
@@ -1326,7 +1323,7 @@ int filemap_fault(struct vm_area_structint did_readaround =0 ;int ret =0 ; - size = (i_size_read (inode) +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + size =page_cache_next (mapping,i_size_read (inode));if (vmf->pgoff >= size)return VM_FAULT_SIGBUS ;
@@ -1401,7 +1398,7 @@ retry_find: goto page_not_uptodate;/* Must recheck i_size under page lock */ - size = (i_size_read (inode) +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + size =page_cache_next (mapping,i_size_read (inode));if (unlikely (vmf->pgoff >= size)) {unlock_page (page);page_cache_release (page);
@@ -1412,7 +1409,7 @@ retry_find:* Found the page and have a reference on it. */ mark_page_accessed (page); - ra->prev_pos = (loff_t )page->index <<PAGE_CACHE_SHIFT ; + ra->prev_pos =page_cache_pos (mapping, page->index,0 ); vmf->page = page;return ret |VM_FAULT_LOCKED ;
@@ -1896,8 +1893,8 @@ int pagecache_write_begin(struct file *f pagep, fsdata); }else {int ret; -pgoff_t index = pos >>PAGE_CACHE_SHIFT ; -unsigned offset = pos & (PAGE_CACHE_SIZE -1 ); +pgoff_t index =page_cache_index (mapping, pos); +unsigned offset =page_cache_offset (mapping, pos);struct inode *inode = mapping->host;struct page *page; again:
@@ -1948,7 +1945,7 @@ int pagecache_write_end(struct file *fil ret = aops->write_end (file, mapping, pos, len, copied, page, fsdata); }else { -unsigned offset = pos & (PAGE_CACHE_SIZE -1 ); +unsigned offset =page_cache_offset (mapping, pos);struct inode *inode = mapping->host;flush_dcache_page (page);
@@ -2053,10 +2050,11 @@ static ssize_t generic_perform_write_2counsigned long bytes;/* Bytes to write to page */ size_t copied;/* Bytes copied from user */ - offset = (pos & (PAGE_CACHE_SIZE -1 )); - index = pos >>PAGE_CACHE_SHIFT ; - bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset, -iov_iter_count (i)); + offset =page_cache_offset (mapping, pos); + index =page_cache_index (mapping, pos); + bytes = min_t(unsigned long, +page_cache_size (mapping) - offset, +iov_iter_count (i));/* * a non-NULL src_page indicates that we're doing the
@@ -2227,10 +2225,11 @@ static ssize_t generic_perform_write(strsize_t copied;/* Bytes copied from user */ void *fsdata; - offset = (pos & (PAGE_CACHE_SIZE -1 )); - index = pos >>PAGE_CACHE_SHIFT ; - bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset, -iov_iter_count (i)); + offset =page_cache_offset (mapping, pos); + index =page_cache_index (mapping, pos); + bytes = min_t(unsigned long, +page_cache_size (mapping) - offset, +iov_iter_count (i)); again:
@@ -2276,8 +2275,9 @@ again:* because not all segments in the iov can be copied at * once without a pagefault. */ - bytes = min_t(unsigned long, PAGE_CACHE_SIZE - offset, -iov_iter_single_seg_count (i)); + bytes = min_t(unsigned long, +page_cache_size (mapping) - offset, +iov_iter_single_seg_count (i)); goto again; }iov_iter_advance (i, copied);
@@ -2419,8 +2419,8 @@ __generic_file_aio_write_nolock(struct kif (err ==0 ) { written = written_buffered;invalidate_mapping_pages (mapping, - pos >>PAGE_CACHE_SHIFT , - endbyte >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, pos), +page_cache_index (mapping, endbyte)); }else {/* * We don't know how much we wrote, so just return
@@ -2507,7 +2507,7 @@ generic_file_direct_IO(int rw, struct ki*/ if (rw ==WRITE ) { write_len =iov_length (iov, nr_segs); - end = (offset + write_len -1 ) >>PAGE_CACHE_SHIFT ; + end =page_cache_index (mapping, offset + write_len -1 );if (mapping_mapped (mapping))unmap_mapping_range (mapping, offset, write_len,0 ); }
@@ -2524,7 +2524,7 @@ generic_file_direct_IO(int rw, struct ki*/ if (rw ==WRITE && mapping->nrpages) { retval =invalidate_inode_pages2_range (mapping, - offset >>PAGE_CACHE_SHIFT , end); +page_cache_index (mapping, offset), end);if (retval) goto out; }
@@ -2540,7 +2540,8 @@ generic_file_direct_IO(int rw, struct ki* fails, tough, the write still worked... */ if (rw ==WRITE && mapping->nrpages) { -invalidate_inode_pages2_range (mapping, offset >>PAGE_CACHE_SHIFT , end); +invalidate_inode_pages2_range (mapping, +page_cache_index (mapping, offset), end); } out:return retval;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/19 Use page_cache_xxx in mm/page-writeback.c
In reply to Christoph LameterUse page_cache_xxx in mm/page-writeback.c
--- mm/page-writeback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/page-writeback.c +3 -3
@@ -818,8 +818,8 @@ int write_cache_pages(struct address_spa index = mapping->writeback_index;/* Start from prev offset */ end =-1 ; }else { - index = wbc->range_start >>PAGE_CACHE_SHIFT ; - end = wbc->range_end >>PAGE_CACHE_SHIFT ; + index =page_cache_index (mapping, wbc->range_start); + end =page_cache_index (mapping, wbc->range_end);if (wbc->range_start ==0 && wbc->range_end ==LLONG_MAX ) range_whole =1 ; scanned =1 ;
@@ -1025,7 +1025,7 @@ int __set_page_dirty_nobuffers(struct pa__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); -task_io_account_write (PAGE_CACHE_SIZE ); +task_io_account_write (page_cache_size (mapping)); }radix_tree_tag_set (&mapping->page_tree,page_index (page),PAGECACHE_TAG_DIRTY );
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/19 Use page_cache_xxx in mm/truncate.c
In reply to Christoph LameterUse page_cache_xxx in mm/truncate.c
--- mm/truncate.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
mm/truncate.c +18 -17
@@ -46,9 +46,10 @@ void do_invalidatepage(struct page *page (*invalidatepage)(page, offset); } -static inline void truncate_partial_page (struct page *page,unsigned partial) +static inline void truncate_partial_page (struct address_space *mapping, +struct page *page,unsigned partial) { -zero_user_segment (page, partial,PAGE_CACHE_SIZE ); +zero_user_segment (page, partial,page_cache_size (mapping));if (PagePrivate (page))do_invalidatepage (page, partial); }
@@ -98,7 +99,7 @@ truncate_complete_page(struct address_spif (page->mapping != mapping)return ; -cancel_dirty_page (page,PAGE_CACHE_SIZE ); +cancel_dirty_page (page,page_cache_size (mapping));if (PagePrivate (page))do_invalidatepage (page,0 );
@@ -160,9 +161,9 @@ invalidate_complete_page(struct address_void truncate_inode_pages_range (struct address_space *mapping,loff_t lstart,loff_t lend) { -const pgoff_t start = (lstart +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; +const pgoff_t start =page_cache_next (mapping, lstart);pgoff_t end; -const unsigned partial = lstart & (PAGE_CACHE_SIZE -1 ); +const unsigned partial =page_cache_offset (mapping, lstart);struct pagevec pvec;pgoff_t next;int i;
@@ -170,8 +171,9 @@ void truncate_inode_pages_range(struct aif (mapping->nrpages ==0 )return ; -BUG_ON ((lend & (PAGE_CACHE_SIZE -1 )) != (PAGE_CACHE_SIZE -1 )); - end = (lend >>PAGE_CACHE_SHIFT ); +BUG_ON (page_cache_offset (mapping, lend) != +page_cache_size (mapping) -1 ); + end =page_cache_index (mapping, lend);pagevec_init (&pvec,0 ); next = start;
@@ -197,8 +199,8 @@ void truncate_inode_pages_range(struct a }if (page_mapped (page)) {unmap_mapping_range (mapping, - (loff_t )page_index<<PAGE_CACHE_SHIFT , -PAGE_CACHE_SIZE ,0 ); +page_cache_pos (mapping, page_index,0 ), +page_cache_size (mapping),0 ); }truncate_complete_page (mapping, page);unlock_page (page);
@@ -211,7 +213,7 @@ void truncate_inode_pages_range(struct astruct page *page =find_lock_page (mapping, start -1 );if (page) {wait_on_page_writeback (page); -truncate_partial_page (page, partial); +truncate_partial_page (mapping, page, partial);unlock_page (page);page_cache_release (page); }
@@ -239,8 +241,8 @@ void truncate_inode_pages_range(struct await_on_page_writeback (page);if (page_mapped (page)) {unmap_mapping_range (mapping, - (loff_t )page->index<<PAGE_CACHE_SHIFT , -PAGE_CACHE_SIZE ,0 ); +page_cache_pos (mapping, page->index,0 ), +page_cache_size (mapping),0 ); }if (page->index > next) next = page->index;
@@ -424,9 +426,8 @@ int invalidate_inode_pages2_range(struct* Zap the rest of the file in one hit. */ unmap_mapping_range (mapping, - (loff_t )page_index<<PAGE_CACHE_SHIFT , - (loff_t)(end - page_index +1 ) - <<PAGE_CACHE_SHIFT , +page_cache_pos (mapping, page_index,0 ), +page_cache_pos (mapping, end - page_index +1 ,0 ),0 ); did_range_unmap =1 ; }else {
@@ -434,8 +435,8 @@ int invalidate_inode_pages2_range(struct* Just zap this page */ unmap_mapping_range (mapping, - (loff_t )page_index<<PAGE_CACHE_SHIFT , -PAGE_CACHE_SIZE ,0 ); +page_cache_pos (mapping, page_index,0 ), +page_cache_size (mapping),0 ); } }BUG_ON (page_mapped (page));
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/19 Use page_cache_xxx in mm/rmap.c
In reply to Christoph LameterUse page_cache_xxx in mm/rmap.c
--- mm/rmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
mm/rmap.c +9 -4
@@ -190,9 +190,14 @@ static void page_unlock_anon_vma(structstatic inline unsigned long vma_address (struct page *page,struct vm_area_struct *vma) { -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff;unsigned long address; +if (PageAnon (page)) + pgoff = page->index; +else + pgoff = page->index <<mapping_order (page->mapping); + address = vma->vm_start + ((pgoff - vma->vm_pgoff) <<PAGE_SHIFT );if (unlikely (address < vma->vm_start || address >= vma->vm_end)) {/* page should be within @vma mapping range */
@@ -345,7 +350,7 @@ static int page_referenced_file(struct p {unsigned int mapcount;struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT );struct vm_area_struct *vma;struct prio_tree_iter iter;int referenced =0 ;
@@ -464,7 +469,7 @@ out:static int page_mkclean_file (struct address_space *mapping,struct page *page) { -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT );struct vm_area_struct *vma;struct prio_tree_iter iter;int ret =0 ;
@@ -897,7 +902,7 @@ static int try_to_unmap_anon(struct pagestatic int try_to_unmap_file (struct page *page,int migration) {struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT );struct vm_area_struct *vma;struct prio_tree_iter iter;int ret =SWAP_AGAIN ;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
Quoted 28 lines · Christoph Lameter
Use
page_cache_xxxinmm/rmap.cSigned-off-by Christoph Lameter <[email protected]>--- mm/rmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)Index:
mm/mm/rmap.c
===================================================================mm/rmap.c +6
-1@@ -190,9 +190,14 @@ static void page_unlock_anon_vma(structstatic inline unsigned long vma_address (struct page *page,struct vm_area_struct *vma) { -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff;unsigned long address; +if (PageAnon (page)) + pgoff = page->index; +else + pgoff = page->index <<mapping_order (page->mapping); + address = vma->vm_start + ((pgoff - vma->vm_pgoff) <<PAGE_SHIFT );if (unlikely (address < vma->vm_start || address >= vma->vm_end)) {/* page should be within @vma mapping range */
mm/rmap.c static int page_referenced_file(struct p · line 353
Quoted 5 lines
mm/rmap.c +1
-1@@ -345,7 +350,7 @@ static int page_referenced_file(struct p {unsigned int mapcount;struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT );
Based on the first hunk, shouldn't this be:
pgoff_t pgoff = page->index << mapping_order(mapping);
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
Quoted 8 lines · David Chinner
Review
Quoted 4 lines
(quoted diff) +1
-1unsigned int mapcount; struct address_space *mapping = page->mapping; - pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); + pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);Based on the first hunk, shouldn't this be:
pgoff_t pgoff = page->index << mapping_order(mapping);
Yes that is much simpler
rmap: simplify page_referenced_file use of page cache inlines
--- mm/rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/rmap.c +1 -1
@@ -350,7 +350,7 @@ static int page_referenced_file(struct p {unsigned int mapcount;struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT ); +pgoff_t pgoff = page->index <<mapping_order (mapping);struct vm_area_struct *vma;struct prio_tree_iter iter;int referenced =0 ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
Quoted 27 lines · Christoph Lameter
Quoted 8 lines · David Chinner
mm/rmap.c static int page_referenced_file(struct p
Quoted 4 lines
mm/rmap.c +1
-1unsigned int mapcount;struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT );Based on the first hunk, shouldn't this be:
pgoff_t pgoff = page->index << mapping_order(mapping);Yes that is much simpler
rmap: simplify
page_referenced_fileuse of page cache inlinesSigned-off-by Christoph Lameter <[email protected]>--- mm/rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
mm/mm/rmap.c
===================================================================
mm/rmap.c static int page_referenced_file(struct p · line 356
Quoted 8 lines
mm/rmap.c +1
-1@@ -350,7 +350,7 @@ static int page_referenced_file(struct p {unsigned int mapcount;struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT ); +pgoff_t pgoff = page->index <<mapping_order (mapping);struct vm_area_struct *vma;struct prio_tree_iter iter;int referenced =0 ;
And the other two occurrences of this in the first patch?
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
Quoted 1 line · David Chinner
And the other two occurrences of this in the first patch?
Ahh... Ok they are also in rmap.c:
rmap: simplify page_referenced_file use of page cache inlines
--- mm/rmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/rmap.c +3 -3
@@ -350,7 +350,7 @@ static int page_referenced_file(struct p {unsigned int mapcount;struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT ); +pgoff_t pgoff = page->index <<mapping_order (mapping);struct vm_area_struct *vma;struct prio_tree_iter iter;int referenced =0 ;
@@ -469,7 +469,7 @@ out:static int page_mkclean_file (struct address_space *mapping,struct page *page) { -pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT ); +pgoff_t pgoff = page->index <<mapping_order (mapping);struct vm_area_struct *vma;struct prio_tree_iter iter;int ret =0 ;
@@ -902,7 +902,7 @@ static int try_to_unmap_anon(struct pagestatic int try_to_unmap_file (struct page *page,int migration) {struct address_space *mapping = page->mapping; -pgoff_t pgoff = page->index << (page_cache_shift (mapping) -PAGE_SHIFT ); +pgoff_t pgoff = page->index <<mapping_order (mapping);struct vm_area_struct *vma;struct prio_tree_iter iter;int ret =SWAP_AGAIN ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 05/19] Use page_cache_xxx in mm/rmap.c
Quoted 9 lines · Christoph Lameter
Quoted 1 line · David Chinner
And the other two occurrences of this in the first patch?
Ahh... Ok they are also in
rmap.c:rmap: simplify
page_referenced_fileuse of page cache inlines
Ok.
Cheers,
dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/19 Use page_cache_xxx in mm/filemap_xip.c
In reply to Christoph LameterUse page_cache_xxx in mm/filemap_xip.c
--- mm/filemap_xip.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
mm/filemap_xip.c +14 -14
@@ -60,24 +60,24 @@ do_xip_mapping_read(struct address_spaceBUG_ON (!mapping->a_ops->get_xip_page); - index = *ppos >>PAGE_CACHE_SHIFT ; - offset = *ppos & ~PAGE_CACHE_MASK ; + index =page_cache_index (mapping, *ppos); + offset =page_cache_offset (mapping, *ppos); isize =i_size_read (inode);if (!isize) goto out; - end_index = (isize -1 ) >>PAGE_CACHE_SHIFT ; + end_index =page_cache_index (mapping, isize -1 );for (;;) {struct page *page;unsigned long nr, ret;/* nr is the maximum number of bytes to copy from this page */ - nr =PAGE_CACHE_SIZE ; + nr =page_cache_size (mapping);if (index >= end_index) {if (index > end_index) goto out; - nr = ((isize -1 ) & ~PAGE_CACHE_MASK ) +1 ; + nr =page_cache_next (mapping, size -1 ) +1 ;if (nr <= offset) { goto out; }
@@ -116,8 +116,8 @@ do_xip_mapping_read(struct address_space*/ ret =actor (desc, page, offset, nr); offset += ret; - index += offset >>PAGE_CACHE_SHIFT ; - offset &= ~PAGE_CACHE_MASK ; + index +=page_cache_index (mapping, offset); + offset =page_cache_offset (mapping, offset);if (ret == nr && desc->count)continue ;
@@ -130,7 +130,7 @@ no_xip_page: } out: - *ppos = ((loff_t ) index <<PAGE_CACHE_SHIFT ) + offset; + *ppos =page_cache_pos (mapping, index, offset);if (filp)file_accessed (filp); }
@@ -219,7 +219,7 @@ static int xip_file_fault(struct vm_area/* XXX: are VM_FAULT_ codes OK? */ - size = (i_size_read (inode) +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + size =page_cache_next (mapping,i_size_read (inode));if (vmf->pgoff >= size)return VM_FAULT_SIGBUS ;
@@ -289,9 +289,9 @@ __xip_file_write(struct file *filp, conssize_t copied;char *kaddr; - offset = (pos & (PAGE_CACHE_SIZE -1 ));/* Within page */ - index = pos >>PAGE_CACHE_SHIFT ; - bytes =PAGE_CACHE_SIZE - offset; + offset =page_cache_offset (mapping, pos);/* Within page */ + index =page_cache_index (mapping, pos); + bytes =page_cache_size (mapping) - offset;if (bytes > count) bytes = count;
@@ -402,8 +402,8 @@ EXPORT_SYMBOL_GPL(xip_file_write);int xip_truncate_page (struct address_space *mapping,loff_t from) { -pgoff_t index = from >>PAGE_CACHE_SHIFT ; -unsigned offset = from & (PAGE_CACHE_SIZE -1 ); +pgoff_t index =page_cache_index (mapping, from); +unsigned offset =page_cache_offset (mapping, from);unsigned blocksize;unsigned length;struct page *page;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 06/19] Use page_cache_xxx in mm/filemap_xip.c
Quoted 12 lines · Christoph Lameter
Use
page_cache_xxxinmm/filemap_xip.cSigned-off-by Christoph Lameter <[email protected]>--- mm/filemap_xip.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)Index:
mm/mm/filemap_xip.c
===================================================================
mm/filemap_xip.c do_xip_mapping_read(struct address_space · line 62
Quoted 4 lines
mm/filemap_xip.c +1
-1@@ -60,24 +60,24 @@ do_xip_mapping_read(struct address_space - nr = ((isize -1 ) & ~PAGE_CACHE_MASK ) +1 ; + nr =page_cache_next (mapping, size -1 ) +1 ;
page_cache_offset(mapping, isize - 1) + 1;
or: page_cache_next(mapping, isize);Cheers,
Fengguang
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 7/19 Use page_cache_xxx in mm/migrate.c
In reply to Christoph LameterUse page_cache_xxx in mm/migrate.c
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -197,7 +197,7 @@ static void remove_file_migration_ptes(sstruct vm_area_struct *vma;struct address_space *mapping =page_mapping (new);struct prio_tree_iter iter; -pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT -PAGE_SHIFT ); +pgoff_t pgoff = new->index <<mapping_order (mapping);if (!mapping)return ;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 8/19 Use page_cache_xxx in fs/libfs.c
In reply to Christoph LameterUse page_cache_xxx in fs/libfs.c
--- fs/libfs.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/libfs.c +7 -5
@@ -17,7 +17,8 @@ int simple_getattr(struct vfsmount *mnt, {struct inode *inode = dentry->d_inode;generic_fillattr (inode, stat); - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT -9 ); + stat->blocks = inode->i_mapping->nrpages << + (page_cache_shift (inode->i_mapping) -9 );return 0 ; }
@@ -341,10 +342,10 @@ int simple_prepare_write(struct file *fi unsigned from, unsigned to) {if (!PageUptodate (page)) { -if (to - from !=PAGE_CACHE_SIZE ) +if (to - from !=page_cache_size (file->f_mapping))zero_user_segments (page,0 , from, - to,PAGE_CACHE_SIZE ); + to,page_cache_size (file->f_mapping)); }return 0 ; }
@@ -372,8 +373,9 @@ int simple_write_begin(struct file *filestatic int simple_commit_write (struct file *file,struct page *page,unsigned from,unsigned to) { -struct inode *inode = page->mapping->host; -loff_t pos = ((loff_t )page->index <<PAGE_CACHE_SHIFT ) + to; +struct address_space *mapping = page->mapping; +struct inode *inode = mapping->host; +loff_t pos =page_cache_pos (mapping, page->index, to);if (!PageUptodate (page))SetPageUptodate (page);
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 9/19 Use page_cache_xxx in fs/sync
In reply to Christoph LameterUse page_cache_xxx in fs/sync.
--- fs/sync.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/sync.c +4 -4
@@ -260,8 +260,8 @@ int do_sync_mapping_range(struct address ret =0 ;if (flags &SYNC_FILE_RANGE_WAIT_BEFORE ) { ret =wait_on_page_writeback_range (mapping, - offset >>PAGE_CACHE_SHIFT , - endbyte >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, offset), +page_cache_index (mapping, endbyte));if (ret <0 ) goto out; }
@@ -275,8 +275,8 @@ int do_sync_mapping_range(struct addressif (flags &SYNC_FILE_RANGE_WAIT_AFTER ) { ret =wait_on_page_writeback_range (mapping, - offset >>PAGE_CACHE_SHIFT , - endbyte >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, offset), +page_cache_index (mapping, endbyte)); } out:return ret;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 10/19 Use page_cache_xxx in fs/buffer.c
In reply to Christoph LameterUse page_cache_xxx in fs/buffer.c.
--- fs/buffer.c | 101 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 45 deletions(-)
fs/buffer.c +56 -45
@@ -278,7 +278,7 @@ __find_get_block_slow(struct block_devicstruct page *page;int all_mapped =1 ; - index = block >> (PAGE_CACHE_SHIFT - bd_inode->i_blkbits); + index = block >> (page_cache_shift (bd_mapping) - bd_inode->i_blkbits); page =find_get_page (bd_mapping, index);if (!page) goto out;
@@ -720,7 +720,7 @@ static int __set_page_dirty(struct page__inc_zone_page_state (page,NR_FILE_DIRTY );__inc_bdi_stat (mapping->backing_dev_info,BDI_RECLAIMABLE ); -task_io_account_write (PAGE_CACHE_SIZE ); +task_io_account_write (page_cache_size (mapping)); }radix_tree_tag_set (&mapping->page_tree,page_index (page),PAGECACHE_TAG_DIRTY );
@@ -914,10 +914,11 @@ struct buffer_head *alloc_page_buffers(s {struct buffer_head *bh, *head;long offset; +unsigned int page_size =page_cache_size (page->mapping); try_again: head =NULL ; - offset =PAGE_SIZE ; + offset = page_size;while ((offset -= size) >=0 ) { bh =alloc_buffer_head (GFP_NOFS );if (!bh)
@@ -1640,6 +1641,7 @@ static int __block_write_full_page(strucstruct buffer_head *bh, *head;const unsigned blocksize =1 << inode->i_blkbits;int nr_underway =0 ; +struct address_space *mapping = inode->i_mapping;BUG_ON (!PageLocked (page));
@@ -1660,7 +1662,8 @@ static int __block_write_full_page(struc* handle that here by just cleaning them. */ - block = (sector_t )page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + block = (sector_t )page->index << + (page_cache_shift (mapping) - inode->i_blkbits); head =page_buffers (page); bh = head;
@@ -1777,7 +1780,7 @@ recover: }while ((bh = bh->b_this_page) != head);SetPageError (page);BUG_ON (PageWriteback (page)); -mapping_set_error (page->mapping, err); +mapping_set_error (mapping, err);set_page_writeback (page); do { struct buffer_head *next = bh->b_this_page;
@@ -1844,8 +1847,8 @@ static int __block_prepare_write(structstruct buffer_head *bh, *head, *wait[2 ], **wait_bh=wait;BUG_ON (!PageLocked (page)); -BUG_ON (from >PAGE_CACHE_SIZE ); -BUG_ON (to >PAGE_CACHE_SIZE ); +BUG_ON (from >page_cache_size (inode->i_mapping)); +BUG_ON (to >page_cache_size (inode->i_mapping));BUG_ON (from > to); blocksize =1 << inode->i_blkbits;
@@ -1854,7 +1857,8 @@ static int __block_prepare_write(struct head =page_buffers (page); bbits = inode->i_blkbits; - block = (sector_t )page->index << (PAGE_CACHE_SHIFT - bbits); + block = (sector_t )page->index << + (page_cache_shift (inode->i_mapping) - bbits);for (bh = head, block_start =0 ; bh != head || !block_start; block++, block_start=block_end, bh = bh->b_this_page) {
@@ -1969,8 +1973,8 @@ int block_write_begin(struct file *file,unsigned start, end;int ownpage =0 ; - index = pos >>PAGE_CACHE_SHIFT ; - start = pos & (PAGE_CACHE_SIZE -1 ); + index =page_cache_index (mapping, pos); + start =page_cache_offset (mapping, pos); end = start + len; page = *pagep;
@@ -2017,7 +2021,7 @@ int block_write_end(struct file *file, sstruct inode *inode = mapping->host;unsigned start; - start = pos & (PAGE_CACHE_SIZE -1 ); + start =page_cache_offset (mapping, pos);if (unlikely (copied < len)) {/*
@@ -2095,7 +2099,8 @@ int block_read_full_page(struct page *pacreate_empty_buffers (page, blocksize,0 ); head =page_buffers (page); - iblock = (sector_t )page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + iblock = (sector_t )page->index << + (page_cache_shift (page->mapping) - inode->i_blkbits); lblock = (i_size_read (inode)+blocksize-1 ) >> inode->i_blkbits; bh = head; nr =0 ;
@@ -2213,16 +2218,16 @@ int cont_expand_zero(struct file *file,unsigned zerofrom, offset, len;int err =0 ; - index = pos >>PAGE_CACHE_SHIFT ; - offset = pos & ~PAGE_CACHE_MASK ; + index =page_cache_index (mapping, pos); + offset =page_cache_offset (mapping, pos); -while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT )) { - zerofrom = curpos & ~PAGE_CACHE_MASK ; +while (index > (curidx =page_cache_index (mapping, (curpos = *bytes)))) { + zerofrom =page_cache_offset (mapping, curpos);if (zerofrom & (blocksize-1 )) { *bytes |= (blocksize-1 ); (*bytes)++; } - len =PAGE_CACHE_SIZE - zerofrom; + len =page_cache_size (mapping) - zerofrom; err = pagecache_write_begin(file, mapping, curpos, len, AOP_FLAG_UNINTERRUPTIBLE,
@@ -2240,7 +2245,7 @@ int cont_expand_zero(struct file *file,/* page covers the boundary, find the boundary offset */ if (index == curidx) { - zerofrom = curpos & ~PAGE_CACHE_MASK ; + zerofrom =page_cache_offset (mapping, curpos);/* if we will expand the thing last block will be filled */ if (offset <= zerofrom) { goto out;
@@ -2286,7 +2291,7 @@ int cont_write_begin(struct file *file,if (err) goto out; - zerofrom = *bytes & ~PAGE_CACHE_MASK ; + zerofrom =page_cache_offset (mapping, *bytes);if (pos+len > *bytes && zerofrom & (blocksize-1 )) { *bytes |= (blocksize-1 ); (*bytes)++;
@@ -2319,8 +2324,9 @@ int block_commit_write(struct page *pageint generic_commit_write (struct file *file,struct page *page,unsigned from,unsigned to) { -struct inode *inode = page->mapping->host; -loff_t pos = ((loff_t )page->index <<PAGE_CACHE_SHIFT ) + to; +struct address_space *mapping = page->mapping; +struct inode *inode = mapping->host; +loff_t pos =page_cache_pos (mapping, page->index, to);__block_commit_write (inode,page,from,to);/* * No need to use i_size_read() here, the i_size
@@ -2356,20 +2362,22 @@ block_page_mkwrite(struct vm_area_structunsigned long end;loff_t size;int ret = -EINVAL ; +struct address_space *mapping;lock_page (page); + mapping = page->mapping; size =i_size_read (inode); -if ((page->mapping != inode->i_mapping) || +if ((mapping != inode->i_mapping) || (page_offset (page) > size)) {/* page got truncated out from underneath us */ goto out_unlock; }/* page is wholly or partially inside EOF */ -if (((page->index +1 ) <<PAGE_CACHE_SHIFT ) > size) - end = size & ~PAGE_CACHE_MASK ; +if (page_cache_pos (mapping, page->index +1 ,0 ) > size) + end =page_cache_offset (mapping, size);else - end =PAGE_CACHE_SIZE ; + end =page_cache_size (mapping); ret =block_prepare_write (page,0 , end, get_block);if (!ret)
@@ -2437,8 +2445,8 @@ int nobh_write_begin(struct file *file,int ret =0 ;int is_mapped_to_disk =1 ; - index = pos >>PAGE_CACHE_SHIFT ; - from = pos & (PAGE_CACHE_SIZE -1 ); + index =page_cache_index (mapping, pos); + from =page_cache_offset (mapping, pos); to = from + len; page =__grab_cache_page (mapping, index);
@@ -2473,7 +2481,8 @@ int nobh_write_begin(struct file *file, goto out_release; } - block_in_file = (sector_t )page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t )page->index << + (page_cache_shift (mapping) - blkbits);/* * We loop across all blocks in the page, whether or not they are
@@ -2481,7 +2490,7 @@ int nobh_write_begin(struct file *file,* page is fully mapped-to-disk. */ for (block_start =0 , block_in_page =0 , bh = head; - block_start <PAGE_CACHE_SIZE ; + block_start <page_cache_size (mapping); block_in_page++, block_start += blocksize, bh = bh->b_this_page) {int create;
@@ -2607,9 +2616,10 @@ EXPORT_SYMBOL(nobh_write_end);int nobh_writepage (struct page *page,get_block_t *get_block,struct writeback_control *wbc) { -struct inode *const inode = page->mapping->host; +struct address_space *mapping = page->mapping; +struct inode *const inode = mapping->host;loff_t i_size =i_size_read (inode); -const pgoff_t end_index = i_size >>PAGE_CACHE_SHIFT ; +const pgoff_t end_index =page_cache_offset (mapping, i_size);unsigned offset;int ret;
@@ -2618,7 +2628,7 @@ int nobh_writepage(struct page *page, ge goto out;/* Is the page fully outside i_size? (truncate in progress) */ - offset = i_size & (PAGE_CACHE_SIZE -1 ); + offset =page_cache_offset (mapping, i_size);if (page->index >= end_index+1 || !offset) {/* * The page may have dirty, unmapped buffers. For example,
@@ -2641,7 +2651,7 @@ int nobh_writepage(struct page *page, ge* the page size, the remaining memory is zeroed when mapped, and * writes to that region are not written out to the file." */ -zero_user_segment (page, offset,PAGE_CACHE_SIZE ); +zero_user_segment (page, offset,page_cache_size (mapping)); out: ret =mpage_writepage (page, get_block, wbc);if (ret == -EAGAIN )
@@ -2653,8 +2663,8 @@ EXPORT_SYMBOL(nobh_writepage);int nobh_truncate_page (struct address_space *mapping,loff_t from,get_block_t *get_block) { -pgoff_t index = from >>PAGE_CACHE_SHIFT ; -unsigned offset = from & (PAGE_CACHE_SIZE -1 ); +pgoff_t index =page_cache_index (mapping, from); +unsigned offset =page_cache_offset (mapping, from);unsigned blocksize;sector_t iblock;unsigned length, pos;
@@ -2671,7 +2681,7 @@ int nobh_truncate_page(struct address_spreturn 0 ; length = blocksize - length; - iblock = (sector_t )index << (PAGE_CACHE_SHIFT - inode->i_blkbits); + iblock = (sector_t )index << (page_cache_shift (mapping) - inode->i_blkbits); page =grab_cache_page (mapping, index); err = -ENOMEM ;
@@ -2729,8 +2739,8 @@ EXPORT_SYMBOL(nobh_truncate_page);int block_truncate_page (struct address_space *mapping,loff_t from,get_block_t *get_block) { -pgoff_t index = from >>PAGE_CACHE_SHIFT ; -unsigned offset = from & (PAGE_CACHE_SIZE -1 ); +pgoff_t index =page_cache_index (mapping, from); +unsigned offset =page_cache_offset (mapping, from);unsigned blocksize;sector_t iblock;unsigned length, pos;
@@ -2747,8 +2757,8 @@ int block_truncate_page(struct address_sreturn 0 ; length = blocksize - length; - iblock = (sector_t )index << (PAGE_CACHE_SHIFT - inode->i_blkbits); - + iblock = (sector_t )index << + (page_cache_shift (mapping) - inode->i_blkbits); page =grab_cache_page (mapping, index); err = -ENOMEM ;if (!page)
@@ -2807,9 +2817,10 @@ out:int block_write_full_page (struct page *page,get_block_t *get_block,struct writeback_control *wbc) { -struct inode *const inode = page->mapping->host; +struct address_space *mapping = page->mapping; +struct inode *const inode = mapping->host;loff_t i_size =i_size_read (inode); -const pgoff_t end_index = i_size >>PAGE_CACHE_SHIFT ; +const pgoff_t end_index =page_cache_index (mapping, i_size);unsigned offset;/* Is the page fully inside i_size? */
@@ -2817,7 +2828,7 @@ int block_write_full_page(struct page *preturn __block_write_full_page (inode, page, get_block, wbc);/* Is the page fully outside i_size? (truncate in progress) */ - offset = i_size & (PAGE_CACHE_SIZE -1 ); + offset =page_cache_offset (mapping, i_size);if (page->index >= end_index+1 || !offset) {/* * The page may have dirty, unmapped buffers. For example,
@@ -2836,7 +2847,7 @@ int block_write_full_page(struct page *p* the page size, the remaining memory is zeroed when mapped, and * writes to that region are not written out to the file." */ -zero_user_segment (page, offset,PAGE_CACHE_SIZE ); +zero_user_segment (page, offset,page_cache_size (mapping));return __block_write_full_page (inode, page, get_block, wbc); }
@@ -3086,7 +3097,7 @@ int try_to_free_buffers(struct page *pag* dirty bit from being lost. */ if (ret) -cancel_dirty_page (page,PAGE_CACHE_SIZE ); +cancel_dirty_page (page,page_cache_size (mapping));spin_unlock (&mapping->private_lock); out:if (buffers_to_free) {
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 10/19] Use page_cache_xxx in fs/buffer.c
fs/buffer.c struct buffer_head *alloc_page_buffers(s · line 924
Quoted 13 lines · Christoph Lameter
fs/buffer.c +2
-1@@ -914,10 +914,11 @@ struct buffer_head *alloc_page_buffers(s {struct buffer_head *bh, *head;long offset; +unsigned int page_size =page_cache_size (page->mapping); try_again: head =NULL ; - offset =PAGE_SIZE ; + offset = page_size;while ((offset -= size) >=0 ) { bh =alloc_buffer_head (GFP_NOFS );if (!bh)
We don't really need a temporary variable here....
Quoted 6 lines
fs/buffer.c +0
-0lblock = (i_size_read (inode)+blocksize-1 ) >> inode->i_blkbits; bh = head; nr =0 ;@@ -2213,16 +2218,16 @@ int cont_expand_zero(struct file *file,unsigned zerofrom, offset, len;int err =0 ;
fs/buffer.c int cont_expand_zero(struct file *file, · line 2225
Quoted 10 lines
fs/buffer.c +4
-4- index = pos >>PAGE_CACHE_SHIFT ; - offset = pos & ~PAGE_CACHE_MASK ; + index =page_cache_index (mapping, pos); + offset =page_cache_offset (mapping, pos); -while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT )) { - zerofrom = curpos & ~PAGE_CACHE_MASK ; +while (index > (curidx =page_cache_index (mapping, (curpos = *bytes)))) { + zerofrom =page_cache_offset (mapping, curpos);
That doesn't get any prettier. Perhaps:
while (index > (curidx = page_cache_index(mapping, *bytes))) {
curpos = *bytes;
zerofrom = page_cache_offset(mapping, curpos);fs/buffer.c block_page_mkwrite(struct vm_area_struct · line 2371
Quoted 12 lines
fs/buffer.c +3
-1@@ -2356,20 +2362,22 @@ block_page_mkwrite(struct vm_area_structunsigned long end;loff_t size;int ret = -EINVAL ; +struct address_space *mapping;lock_page (page); + mapping = page->mapping; size =i_size_read (inode); -if ((page->mapping != inode->i_mapping) || +if ((mapping != inode->i_mapping) || (page_offset (page) > size)) {
Should check (page_cache_pos(mapping, page->index, 0) > size)
fs/buffer.c EXPORT_SYMBOL(nobh_write_end); · line 2622
Quoted 10 lines
fs/buffer.c +3
-2@@ -2607,9 +2616,10 @@ EXPORT_SYMBOL(nobh_write_end);int nobh_writepage (struct page *page,get_block_t *get_block,struct writeback_control *wbc) { -struct inode *const inode = page->mapping->host; +struct address_space *mapping = page->mapping; +struct inode *const inode = mapping->host;loff_t i_size =i_size_read (inode); -const pgoff_t end_index = i_size >>PAGE_CACHE_SHIFT ; +const pgoff_t end_index =page_cache_offset (mapping, i_size);
const pgoff_t end_index = page_cache_index(mapping, i_size);
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 10/19] Use page_cache_xxx in fs/buffer.c
Quoted 10 lines · David Chinner
Review
Quoted 4 lines
(quoted diff) +2
-2- while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT)) { - zerofrom = curpos & ~PAGE_CACHE_MASK; + while (index > (curidx = page_cache_index(mapping, (curpos = *bytes)))) { + zerofrom = page_cache_offset(mapping, curpos);That doesn't get any prettier. Perhaps:
while (index > (curidx = page_cache_index(mapping, *bytes))) { curpos = *bytes; zerofrom = page_cache_offset(mapping, curpos);
Results in a gcc warning about the possible use of an unitialized variable.
How about this?
fs/buffer.c enhancements and fixes
--- fs/buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/buffer.c +4 -4
@@ -914,11 +914,10 @@ struct buffer_head *alloc_page_buffers(s {struct buffer_head *bh, *head;long offset; -unsigned int page_size =page_cache_size (page->mapping); try_again: head =NULL ; - offset = page_size; + offset =page_cache_size (page->mapping);while ((offset -= size) >=0 ) { bh =alloc_buffer_head (GFP_NOFS );if (!bh)
@@ -2221,7 +2220,8 @@ int cont_expand_zero(struct file *file, index =page_cache_index (mapping, pos); offset =page_cache_offset (mapping, pos); -while (index > (curidx =page_cache_index (mapping, (curpos = *bytes)))) { +while (curpos = *bytes, curidx =page_cache_index (mapping, curpos), + index > curidx) { zerofrom =page_cache_offset (mapping, curpos);if (zerofrom & (blocksize-1 )) { *bytes |= (blocksize-1 );
@@ -2368,7 +2368,7 @@ block_page_mkwrite(struct vm_area_struct mapping = page->mapping; size =i_size_read (inode);if ((mapping != inode->i_mapping) || - (page_offset (page) > size)) { + (page_cache_pos (mapping, page->index,0 ) > size)) {/* page got truncated out from underneath us */ goto out_unlock; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 10/19] Use page_cache_xxx in fs/buffer.c
Quoted 9 lines · Christoph Lameter
Quoted 7 lines · David Chinner
Review
Quoted 4 lines
(quoted diff) +2
-2- while (index > (curidx = (curpos = *bytes)>>PAGE_CACHE_SHIFT)) { - zerofrom = curpos & ~PAGE_CACHE_MASK; + while (index > (curidx = page_cache_index(mapping, (curpos = *bytes)))) { + zerofrom = page_cache_offset(mapping, curpos);That doesn't get any prettier. Perhaps:
Quoted 6 lines
Quoted 3 lines
while (index > (curidx = page_cache_index(mapping, *bytes))) { curpos = *bytes; zerofrom = page_cache_offset(mapping, curpos);Results in a gcc warning about the possible use of an unitialized variable.
fmeh.
Quoted 39 lines
How about this?
fs/buffer.cenhancements and fixesSigned-off-by Christoph Lameter <[email protected]>--- fs/buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Index:
mm/fs/buffer.c
===================================================================fs/buffer.c +3
-3@@ -914,11 +914,10 @@ struct buffer_head *alloc_page_buffers(s {struct buffer_head *bh, *head;long offset; -unsigned int page_size =page_cache_size (page->mapping); try_again: head =NULL ; - offset = page_size; + offset =page_cache_size (page->mapping);while ((offset -= size) >=0 ) { bh =alloc_buffer_head (GFP_NOFS );if (!bh)@@ -2221,7 +2220,8 @@ int cont_expand_zero(struct file *file, index =page_cache_index (mapping, pos); offset =page_cache_offset (mapping, pos); -while (index > (curidx =page_cache_index (mapping, (curpos = *bytes)))) { +while (curpos = *bytes, curidx =page_cache_index (mapping, curpos), + index > curidx) { zerofrom =page_cache_offset (mapping, curpos);if (zerofrom & (blocksize-1 )) { *bytes |= (blocksize-1 );
fs/buffer.c block_page_mkwrite(struct vm_area_struct · line 2374
Quoted 8 lines
fs/buffer.c +1
-1@@ -2368,7 +2368,7 @@ block_page_mkwrite(struct vm_area_struct mapping = page->mapping; size =i_size_read (inode);if ((mapping != inode->i_mapping) || - (page_offset (page) > size)) { + (page_cache_pos (mapping, page->index,0 ) > size)) {/* page got truncated out from underneath us */ goto out_unlock; }
Works for me.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 11/19 Use page_cache_xxx in mm/mpage.c
In reply to Christoph LameterUse page_cache_xxx in mm/mpage.c
--- fs/mpage.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
fs/mpage.c +16 -12
@@ -125,7 +125,8 @@ mpage_alloc(struct block_device *bdev,static void map_buffer_to_page (struct page *page,struct buffer_head *bh,int page_block) { -struct inode *inode = page->mapping->host; +struct address_space *mapping = page->mapping; +struct inode *inode = mapping->host;struct buffer_head *page_bh, *head;int block =0 ;
@@ -134,9 +135,9 @@ map_buffer_to_page(struct page *page, st* don't make any buffers if there is only one buffer on * the page and the page just needs to be set up to date */ -if (inode->i_blkbits ==PAGE_CACHE_SHIFT && +if (inode->i_blkbits ==page_cache_shift (mapping) &&buffer_uptodate (bh)) { -SetPageUptodate (page); +SetPageUptodate (page);return ; }create_empty_buffers (page,1 << inode->i_blkbits,0 );
@@ -169,9 +170,10 @@ do_mpage_readpage(struct bio *bio, struc sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { - struct inode *inode = page->mapping->host; + struct address_space *mapping = page->mapping; +struct inode *inode = mapping->host;const unsigned blkbits = inode->i_blkbits; -const unsigned blocks_per_page =PAGE_CACHE_SIZE >> blkbits; +const unsigned blocks_per_page =page_cache_size (mapping) >> blkbits;const unsigned blocksize =1 << blkbits;sector_t block_in_file;sector_t last_block;
@@ -188,7 +190,7 @@ do_mpage_readpage(struct bio *bio, strucif (page_has_buffers (page)) goto confused; - block_in_file = (sector_t )page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t )page->index << (page_cache_shift (mapping) - blkbits); last_block = block_in_file + nr_pages * blocks_per_page; last_block_in_file = (i_size_read (inode) + blocksize -1 ) >> blkbits;if (last_block > last_block_in_file)
@@ -276,7 +278,8 @@ do_mpage_readpage(struct bio *bio, struc }if (first_hole != blocks_per_page) { -zero_user_segment (page, first_hole << blkbits,PAGE_CACHE_SIZE ); +zero_user_segment (page, first_hole << blkbits, +page_cache_size (mapping));if (first_hole ==0 ) {SetPageUptodate (page);unlock_page (page);
@@ -454,7 +457,7 @@ static int __mpage_writepage(struct pagestruct inode *inode = page->mapping->host;const unsigned blkbits = inode->i_blkbits;unsigned long end_index; -const unsigned blocks_per_page =PAGE_CACHE_SIZE >> blkbits; +const unsigned blocks_per_page =page_cache_size (mapping) >> blkbits;sector_t last_block;sector_t block_in_file;sector_t blocks[MAX_BUF_PER_PAGE ];
@@ -523,7 +526,8 @@ static int __mpage_writepage(struct page* The page has no buffers: map it to disk */ BUG_ON (!PageUptodate (page)); - block_in_file = (sector_t )page->index << (PAGE_CACHE_SHIFT - blkbits); + block_in_file = (sector_t )page->index << + (page_cache_shift (mapping) - blkbits); last_block = (i_size -1 ) >> blkbits; map_bh.b_page = page;for (page_block =0 ; page_block < blocks_per_page; ) {
@@ -555,7 +559,7 @@ static int __mpage_writepage(struct page first_unmapped = page_block; page_is_mapped: - end_index = i_size >>PAGE_CACHE_SHIFT ; + end_index =page_cache_index (mapping, i_size);if (page->index >= end_index) {/* * The page straddles i_size. It must be zeroed out on each
@@ -565,11 +569,11 @@ page_is_mapped:* is zeroed when mapped, and writes to that region are not * written out to the file." */ -unsigned offset = i_size & (PAGE_CACHE_SIZE -1 ); +unsigned offset =page_cache_offset (mapping, i_size);if (page->index > end_index || !offset) goto confused; -zero_user_segment (page, offset,PAGE_CACHE_SIZE ); +zero_user_segment (page, offset,page_cache_size (mapping)); }/*
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 12/19 Use page_cache_xxx in mm/fadvise.c
In reply to Christoph LameterUse page_cache_xxx in mm/fadvise.c
--- mm/fadvise.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/fadvise.c +4 -4
@@ -79,8 +79,8 @@ asmlinkage long sys_fadvise64_64(int fd, }/* First and last PARTIAL page! */ - start_index = offset >>PAGE_CACHE_SHIFT ; - end_index = endbyte >>PAGE_CACHE_SHIFT ; + start_index =page_cache_index (mapping, offset); + end_index =page_cache_index (mapping, endbyte);/* Careful about overflow on the "+1" */ nrpages = end_index - start_index +1 ;
@@ -100,8 +100,8 @@ asmlinkage long sys_fadvise64_64(int fd,filemap_flush (mapping);/* First and last FULL page! */ - start_index = (offset+(PAGE_CACHE_SIZE -1 )) >>PAGE_CACHE_SHIFT ; - end_index = (endbyte >>PAGE_CACHE_SHIFT ); + start_index =page_cache_next (mapping, offset); + end_index =page_cache_index (mapping, endbyte);if (end_index >= start_index) invalidate_mapping_pages(mapping, start_index,
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 13/19 Use page_cache_xxx in fs/splice.c
In reply to Christoph LameterUse page_cache_xxx in fs/splice.c
--- fs/splice.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
fs/splice.c +14 -13
@@ -285,9 +285,9 @@ __generic_file_splice_read(struct file * .spd_release = spd_release_page, }; - index = *ppos >>PAGE_CACHE_SHIFT ; - loff = *ppos & ~PAGE_CACHE_MASK ; - req_pages = (len + loff +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + index =page_cache_index (mapping, *ppos); + loff =page_cache_offset (mapping, *ppos); + req_pages =page_cache_next (mapping, len + loff); nr_pages =min (req_pages, (unsigned )PIPE_BUFFERS );/*
@@ -342,7 +342,7 @@ __generic_file_splice_read(struct file ** Now loop over the map and see if we need to start IO on any * pages, fill in the partial map, etc. */ - index = *ppos >>PAGE_CACHE_SHIFT ; + index =page_cache_index (mapping, *ppos); nr_pages = spd.nr_pages; spd.nr_pages =0 ;for (page_nr =0 ; page_nr < nr_pages; page_nr++) {
@@ -354,7 +354,8 @@ __generic_file_splice_read(struct file */* * this_len is the max we'll use from this page */ - this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff); + this_len = min_t(unsigned long, len, +page_cache_size (mapping) - loff); page = pages[page_nr];if (PageReadahead (page))
@@ -414,7 +415,7 @@ fill_it:* i_size must be checked after PageUptodate. */ isize =i_size_read (mapping->host); - end_index = (isize -1 ) >>PAGE_CACHE_SHIFT ; + end_index =page_cache_index (mapping, isize -1 );if (unlikely (!isize || index > end_index))break ;
@@ -428,7 +429,7 @@ fill_it:/* * max good bytes in this page */ - plen = ((isize -1 ) & ~PAGE_CACHE_MASK ) +1 ; + plen =page_cache_offset (mapping, isize -1 ) +1 ;if (plen <= loff)break ;
@@ -453,7 +454,7 @@ fill_it:*/ while (page_nr < nr_pages)page_cache_release (pages[page_nr++]); - in->f_ra.prev_pos = (loff_t )index <<PAGE_CACHE_SHIFT ; + in->f_ra.prev_pos =page_cache_index (mapping, index);if (spd.nr_pages)return splice_to_pipe (pipe, &spd);
@@ -579,11 +580,11 @@ static int pipe_to_file(struct pipe_inodif (unlikely (ret))return ret; - offset = sd->pos & ~PAGE_CACHE_MASK ; + offset =page_cache_offset (mapping, sd->pos); this_len = sd->len; -if (this_len + offset >PAGE_CACHE_SIZE ) - this_len =PAGE_CACHE_SIZE - offset; +if (this_len + offset >page_cache_size (mapping)) + this_len =page_cache_size (mapping) - offset; ret =pagecache_write_begin (file, mapping, sd->pos, this_len,AOP_FLAG_UNINTERRUPTIBLE , &page, &fsdata);
@@ -790,7 +791,7 @@ generic_file_splice_write_nolock(structunsigned long nr_pages; *ppos += ret; - nr_pages = (ret +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + nr_pages =page_cache_next (mapping, ret);/* * If file or inode is SYNC and we actually wrote some data,
@@ -852,7 +853,7 @@ generic_file_splice_write(struct pipe_inunsigned long nr_pages; *ppos += ret; - nr_pages = (ret +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; + nr_pages =page_cache_next (mapping, ret);/* * If file or inode is SYNC and we actually wrote some data,
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 13/19] Use page_cache_xxx in fs/splice.c
fs/splice.c fill_it: · line 457
Quoted 6 lines · Christoph Lameter
fs/splice.c +1
-1@@ -453,7 +454,7 @@ fill_it:*/ while (page_nr < nr_pages)page_cache_release (pages[page_nr++]); - in->f_ra.prev_pos = (loff_t )index <<PAGE_CACHE_SHIFT ; + in->f_ra.prev_pos =page_cache_index (mapping, index);
in->f_ra.prev_pos = page_cache_pos(mapping, index, 0);
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 13/19] Use page_cache_xxx in fs/splice.c
Quoted 10 lines · David Chinner
Review fill_it: · line 457
Quoted 6 lines · Christoph Lameter
(quoted diff) +1
-1@@ -453,7 +454,7 @@ fill_it: */ while (page_nr < nr_pages) page_cache_release(pages[page_nr++]); - in->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT; + in->f_ra.prev_pos = page_cache_index(mapping, index);in->f_ra.prev_pos = page_cache_pos(mapping, index, 0);
splice.c: Wrong inline function used
--- fs/splice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/splice.c +1 -1
@@ -454,7 +454,7 @@ fill_it:*/ while (page_nr < nr_pages)page_cache_release (pages[page_nr++]); - in->f_ra.prev_pos =page_cache_index (mapping, index); + in->f_ra.prev_pos =page_cache_pos (mapping, index,0 );if (spd.nr_pages)return splice_to_pipe (pipe, &spd);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 13/19] Use page_cache_xxx in fs/splice.c
Quoted 26 lines · Christoph Lameter
Quoted 10 lines · David Chinner
fs/splice.c fill_it: · line 457
Quoted 6 lines · Christoph Lameter
fs/splice.c +1
-1@@ -453,7 +454,7 @@ fill_it:*/ while (page_nr < nr_pages)page_cache_release (pages[page_nr++]); - in->f_ra.prev_pos = (loff_t )index <<PAGE_CACHE_SHIFT ; + in->f_ra.prev_pos =page_cache_index (mapping, index);in->f_ra.prev_pos = page_cache_pos(mapping, index, 0);
splice.c: Wrong inline function usedSigned-off-by Christoph Lameter <[email protected]>--- fs/splice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
mm/fs/splice.c
===================================================================
fs/splice.c fill_it: · line 460
Quoted 8 lines
fs/splice.c +1
-1@@ -454,7 +454,7 @@ fill_it:*/ while (page_nr < nr_pages)page_cache_release (pages[page_nr++]); - in->f_ra.prev_pos =page_cache_index (mapping, index); + in->f_ra.prev_pos =page_cache_pos (mapping, index,0 );if (spd.nr_pages)return splice_to_pipe (pipe, &spd);
Ok.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 14/19 Use page_cache_xxx in ext2
In reply to Christoph LameterUse page_cache_xxx functions in fs/ext2/*
--- fs/ext2/dir.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-)
fs/ext2/dir.c +23 -17
@@ -63,7 +63,8 @@ static inline void ext2_put_page(structstatic inline unsigned long dir_pages (struct inode *inode) { -return (inode->i_size+PAGE_CACHE_SIZE -1 )>>PAGE_CACHE_SHIFT ; +return (inode->i_size+page_cache_size (inode->i_mapping)-1 )>> +page_cache_shift (inode->i_mapping); }/*
@@ -74,10 +75,11 @@ static unsigned ext2_last_byte(struct inode *inode, unsigned long page_nr) { unsigned last_byte = inode->i_size; +struct address_space *mapping = inode->i_mapping; - last_byte -= page_nr <<PAGE_CACHE_SHIFT ; -if (last_byte >PAGE_CACHE_SIZE ) - last_byte =PAGE_CACHE_SIZE ; + last_byte -= page_nr <<page_cache_shift (mapping); +if (last_byte >page_cache_size (mapping)) + last_byte =page_cache_size (mapping);return last_byte; }
@@ -105,18 +107,19 @@ static int ext2_commit_chunk(struct pagestatic void ext2_check_page (struct page *page) { -struct inode *dir = page->mapping->host; +struct address_space *mapping = page->mapping; +struct inode *dir = mapping->host;struct super_block *sb = dir->i_sb;unsigned chunk_size =ext2_chunk_size (dir);char *kaddr =page_address (page);u32 max_inumber =le32_to_cpu (EXT2_SB (sb)->s_es->s_inodes_count);unsigned offs, rec_len; -unsigned limit =PAGE_CACHE_SIZE ; +unsigned limit =page_cache_size (mapping);ext2_dirent *p;char *error; -if ((dir->i_size >>PAGE_CACHE_SHIFT ) == page->index) { - limit = dir->i_size & ~PAGE_CACHE_MASK ; +if (page_cache_index (mapping, dir->i_size) == page->index) { + limit =page_cache_offset (mapping, dir->i_size);if (limit & (chunk_size -1 )) goto Ebadsize;if (!limit)
@@ -168,7 +171,7 @@ Einumber: bad_entry:ext2_error (sb,"ext2_check_page" ,"bad entry in directory #%lu: %s - " "offset=%lu, inode=%lu, rec_len=%d, name_len=%d" , - dir->i_ino, error, (page->index<<PAGE_CACHE_SHIFT )+offs, + dir->i_ino, error,page_cache_pos (mapping, page->index, offs), (unsigned long )le32_to_cpu (p->inode), rec_len, p->name_len); goto fail;
@@ -177,7 +180,7 @@ Eend:ext2_error (sb,"ext2_check_page" ,"entry in directory #%lu spans the page boundary" "offset=%lu, inode=%lu" , - dir->i_ino, (page->index<<PAGE_CACHE_SHIFT )+offs, + dir->i_ino,page_cache_pos (mapping, page->index, offs), (unsigned long )le32_to_cpu (p->inode)); fail:SetPageChecked (page);
@@ -276,8 +279,9 @@ ext2_readdir (struct file * filp, void *loff_t pos = filp->f_pos;struct inode *inode = filp->f_path.dentry->d_inode;struct super_block *sb = inode->i_sb; -unsigned int offset = pos & ~PAGE_CACHE_MASK ; -unsigned long n = pos >>PAGE_CACHE_SHIFT ; +struct address_space *mapping = inode->i_mapping; +unsigned int offset =page_cache_offset (mapping, pos); +unsigned long n =page_cache_index (mapping, pos);unsigned long npages =dir_pages (inode);unsigned chunk_mask = ~(ext2_chunk_size (inode)-1 );unsigned char *types =NULL ;
@@ -298,14 +302,14 @@ ext2_readdir (struct file * filp, void *ext2_error (sb, __FUNCTION__,"bad page in #%lu" , inode->i_ino); - filp->f_pos +=PAGE_CACHE_SIZE - offset; + filp->f_pos +=page_cache_size (mapping) - offset;return -EIO ; } kaddr =page_address (page);if (unlikely (need_revalidate)) {if (offset) { offset =ext2_validate_entry (kaddr, offset, chunk_mask); - filp->f_pos = (n<<PAGE_CACHE_SHIFT ) + offset; + filp->f_pos =page_cache_pos (mapping, n, offset); } filp->f_version = inode->i_version; need_revalidate =0 ;
@@ -328,7 +332,7 @@ ext2_readdir (struct file * filp, void * offset = (char *)de - kaddr; over =filldir (dirent, de->name, de->name_len, - (n<<PAGE_CACHE_SHIFT ) | offset, +page_cache_pos (mapping, n, offset),le32_to_cpu (de->inode), d_type);if (over) {ext2_put_page (page);
@@ -354,6 +358,7 @@ struct ext2_dir_entry_2 * ext2_find_entr struct dentry *dentry, struct page ** res_page) { const char *name = dentry->d_name.name; +struct address_space *mapping = dir->i_mapping;int namelen = dentry->d_name.len;unsigned reclen =EXT2_DIR_REC_LEN (namelen);unsigned long start, n;
@@ -395,7 +400,7 @@ struct ext2_dir_entry_2 * ext2_find_entrif (++n >= npages) n =0 ;/* next page is past the blocks we've got */ -if (unlikely (n > (dir->i_blocks >> (PAGE_CACHE_SHIFT -9 )))) { +if (unlikely (n > (dir->i_blocks >> (page_cache_shift (mapping) -9 )))) { ext2_error(dir->i_sb, __FUNCTION__, "dir %lu size %lld exceeds block count %llu", dir->i_ino, dir->i_size,
@@ -466,6 +471,7 @@ void ext2_set_link(struct inode *dir, stint ext2_add_link (struct dentry *dentry,struct inode *inode) {struct inode *dir = dentry->d_parent->d_inode; +struct address_space *mapping = inode->i_mapping;const char *name = dentry->d_name.name;int namelen = dentry->d_name.len;unsigned chunk_size =ext2_chunk_size (dir);
@@ -495,7 +501,7 @@ int ext2_add_link (struct dentry *dentry kaddr =page_address (page); dir_end = kaddr +ext2_last_byte (dir, n); de = (ext2_dirent *)kaddr; - kaddr +=PAGE_CACHE_SIZE - reclen; + kaddr +=page_cache_size (mapping) - reclen;while ((char *)de <= kaddr) {if ((char *)de == dir_end) {/* We hit i_size */
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 14/19] Use page_cache_xxx in ext2
Quoted 12 lines · Christoph Lameter
Use
page_cache_xxxfunctions infs/ext2/*Signed-off-by Christoph Lameter <[email protected]>--- fs/ext2/dir.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-)Index:
linux-2.6/fs/ext2/dir.c
===================================================================
fs/ext2/dir.c static inline void ext2_put_page(struct · line 68
Quoted 7 lines
fs/ext2/dir.c +2
-1@@ -63,7 +63,8 @@ static inline void ext2_put_page(structstatic inline unsigned long dir_pages (struct inode *inode) { -return (inode->i_size+PAGE_CACHE_SIZE -1 )>>PAGE_CACHE_SHIFT ; +return (inode->i_size+page_cache_size (inode->i_mapping)-1 )>> +page_cache_shift (inode->i_mapping); }
return page_cache_next(inode->mapping, inode->i_size);
fs/ext2/dir.c static unsigned · line 80
Quoted 12 lines
fs/ext2/dir.c +2
-3/* @@ -74,10 +75,11 @@ static unsigned ext2_last_byte(struct inode *inode, unsigned long page_nr) { unsigned last_byte = inode->i_size; +struct address_space *mapping = inode->i_mapping; - last_byte -= page_nr <<PAGE_CACHE_SHIFT ; -if (last_byte >PAGE_CACHE_SIZE ) - last_byte =PAGE_CACHE_SIZE ; + last_byte -= page_nr <<page_cache_shift (mapping);
last_byte -= page_cache_pos(mapping, page_nr, 0);
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 14/19] Use page_cache_xxx in ext2
--- fs/ext2/dir.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/ext2/dir.c +2 -7
@@ -63,8 +63,7 @@ static inline void ext2_put_page(structstatic inline unsigned long dir_pages (struct inode *inode) { -return (inode->i_size+page_cache_size (inode->i_mapping)-1 )>> -page_cache_shift (inode->i_mapping); +return page_cache_next (inode->i_mapping, inode->i_size); }/*
@@ -74,13 +73,9 @@ static inline unsigned long dir_pages(ststatic unsigned ext2_last_byte (struct inode *inode,unsigned long page_nr) { -unsigned last_byte = inode->i_size;struct address_space *mapping = inode->i_mapping; - last_byte -= page_nr <<page_cache_shift (mapping); -if (last_byte >page_cache_size (mapping)) - last_byte =page_cache_size (mapping); -return last_byte; +return inode->i_size -page_cache_pos (mapping, page_nr,0 ); }static int ext2_commit_chunk (struct page *page,loff_t pos,unsigned len)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 14/19] Use page_cache_xxx in ext2
Quoted 13 lines · Christoph Lameter
ext2: Simplify some functions
Signed-off-by Christoph Lameter <[email protected]>--- fs/ext2/dir.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)Index:
mm/fs/ext2/dir.c
===================================================================
fs/ext2/dir.c static inline void ext2_put_page(struct · line 67
Quoted 7 lines
fs/ext2/dir.c +1
-2@@ -63,8 +63,7 @@ static inline void ext2_put_page(structstatic inline unsigned long dir_pages (struct inode *inode) { -return (inode->i_size+page_cache_size (inode->i_mapping)-1 )>> -page_cache_shift (inode->i_mapping); +return page_cache_next (inode->i_mapping, inode->i_size); }
ok.
fs/ext2/dir.c static inline unsigned long dir_pages(st · line 78
Quoted 13 lines
fs/ext2/dir.c +1
-5/* @@ -74,13 +73,9 @@ static inline unsigned long dir_pages(ststatic unsigned ext2_last_byte (struct inode *inode,unsigned long page_nr) { -unsigned last_byte = inode->i_size;struct address_space *mapping = inode->i_mapping; - last_byte -= page_nr <<page_cache_shift (mapping); -if (last_byte >page_cache_size (mapping)) - last_byte =page_cache_size (mapping); -return last_byte; +return inode->i_size -page_cache_pos (mapping, page_nr,0 );
I don't think that gives the same return value. The return value is supposed to be clamped at a maximum of page_cache_size(mapping).
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 14/19] Use page_cache_xxx in ext2
Quoted 2 lines · David Chinner
I don't think that gives the same return value. The return value is supposed to be clamped at a maximum of
page_cache_size(mapping).
Ok. So this?
ext2: Simplify some functions
--- fs/ext2/dir.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/ext2/dir.c +2 -3
@@ -63,8 +63,7 @@ static inline void ext2_put_page(structstatic inline unsigned long dir_pages (struct inode *inode) { -return (inode->i_size+page_cache_size (inode->i_mapping)-1 )>> -page_cache_shift (inode->i_mapping); +return page_cache_next (inode->i_mapping, inode->i_size); }/*
@@ -77,7 +76,7 @@ ext2_last_byte(struct inode *inode, unsiunsigned last_byte = inode->i_size;struct address_space *mapping = inode->i_mapping; - last_byte -= page_nr <<page_cache_shift (mapping); + last_byte -=page_cache_pos (mapping, page_nr,0 );if (last_byte >page_cache_size (mapping)) last_byte =page_cache_size (mapping);return last_byte;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 14/19] Use page_cache_xxx in ext2
Quoted 6 lines · Christoph Lameter
Quoted 2 lines · David Chinner
I don't think that gives the same return value. The return value is supposed to be clamped at a maximum of
page_cache_size(mapping).Ok. So this?
Looks good.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 15/19 Use page_cache_xxx in fs/ext3
In reply to Christoph LameterUse page_cache_xxx in fs/ext3
--- fs/ext3/dir.c | 3 ++- fs/ext3/inode.c | 39 ++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 20 deletions(-)
fs/ext3/dir.c +2 -1
@@ -133,7 +133,8 @@ static int ext3_readdir(struct file * fi &map_bh, 0, 0);if (err >0 ) {pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_shift (inode->i_mapping) + - inode->i_blkbits);if (!ra_has_index (&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping,
fs/ext3/inode.c +20 -19
@@ -1159,8 +1159,8 @@ static int ext3_write_begin(struct filepgoff_t index;unsigned from, to; - index = pos >>PAGE_CACHE_SHIFT ; - from = pos & (PAGE_CACHE_SIZE -1 ); + index =page_cache_index (mapping, pos); + from =page_cache_offset (mapping, pos); to = from + len; retry:
@@ -1256,7 +1256,7 @@ static int ext3_ordered_write_end(structunsigned from, to;int ret =0 , ret2; - from = pos & (PAGE_CACHE_SIZE -1 ); + from =page_cache_offset (mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page),
@@ -1326,7 +1326,7 @@ static int ext3_journalled_write_end(strint partial =0 ;unsigned from, to; - from = pos & (PAGE_CACHE_SIZE -1 ); + from =page_cache_offset (mapping, pos); to = from + len;if (copied < len) {
@@ -1489,6 +1489,7 @@ static int ext3_ordered_writepage(structhandle_t *handle =NULL ;int ret =0 ;int err; +int pagesize =page_cache_size (inode->i_mapping);J_ASSERT (PageLocked (page));
@@ -1511,8 +1512,7 @@ static int ext3_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs =page_buffers (page); -walk_page_buffers (handle, page_bufs,0 , -PAGE_CACHE_SIZE ,NULL , bget_one); +walk_page_buffers (handle, page_bufs,0 , pagesize,NULL , bget_one); ret =block_write_full_page (page, ext3_get_block, wbc);
@@ -1529,13 +1529,12 @@ static int ext3_ordered_writepage(struct* and generally junk. */ if (ret ==0 ) { - err =walk_page_buffers (handle, page_bufs,0 ,PAGE_CACHE_SIZE , -NULL , journal_dirty_data_fn); + err =walk_page_buffers (handle, page_bufs,0 , pagesize, +NULL , journal_dirty_data_fn);if (!ret) ret = err; } -walk_page_buffers (handle, page_bufs,0 , -PAGE_CACHE_SIZE ,NULL , bput_one); +walk_page_buffers (handle, page_bufs,0 , pagesize,NULL , bput_one); err =ext3_journal_stop (handle);if (!ret) ret = err;
@@ -1583,10 +1582,12 @@ out_fail:static int ext3_journalled_writepage (struct page *page,struct writeback_control *wbc) { -struct inode *inode = page->mapping->host; +struct address_space *mapping = page->mapping; +struct inode *inode = mapping->host;handle_t *handle =NULL ;int ret =0 ;int err; +int pagesize =page_cache_size (inode->i_mapping);if (ext3_journal_current_handle ()) goto no_write;
@@ -1603,17 +1604,16 @@ static int ext3_journalled_writepage(str* doesn't seem much point in redirtying the page here. */ ClearPageChecked (page); - ret =block_prepare_write (page,0 ,PAGE_CACHE_SIZE , - ext3_get_block); + ret =block_prepare_write (page,0 , pagesize, ext3_get_block);if (ret !=0 ) {ext3_journal_stop (handle); goto out_unlock; } ret =walk_page_buffers (handle,page_buffers (page),0 , -PAGE_CACHE_SIZE ,NULL , do_journal_get_write_access); + pagesize,NULL , do_journal_get_write_access); err =walk_page_buffers (handle,page_buffers (page),0 , -PAGE_CACHE_SIZE ,NULL , write_end_fn); + pagesize,NULL , write_end_fn);if (ret ==0 ) ret = err;EXT3_I (inode)->i_state |=EXT3_STATE_JDATA ;
@@ -1828,8 +1828,8 @@ void ext3_set_aops(struct inode *inode)static int ext3_block_truncate_page (handle_t *handle,struct page *page,struct address_space *mapping,loff_t from) { -ext3_fsblk_t index = from >>PAGE_CACHE_SHIFT ; -unsigned offset = from & (PAGE_CACHE_SIZE -1 ); +ext3_fsblk_t index =page_cache_index (mapping, from); +unsigned offset =page_cache_offset (mapping, from);unsigned blocksize, iblock, length, pos;struct inode *inode = mapping->host;struct buffer_head *bh;
@@ -1837,7 +1837,8 @@ static int ext3_block_truncate_page(hand blocksize = inode->i_sb->s_blocksize; length = blocksize - (offset & (blocksize -1 )); - iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); + iblock = index << + (page_cache_shift (mapping) - inode->i_sb->s_blocksize_bits);/* * For "nobh" option, we can only work if we don't need to
@@ -2316,7 +2317,7 @@ void ext3_truncate(struct inode *inode) page =NULL ; }else { page =grab_cache_page (mapping, - inode->i_size >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, inode->i_size));if (!page)return ; }
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 16/19 Use page_cache_xxx in fs/ext4
In reply to Christoph LameterUse page_cache_xxx in fs/ext4
--- fs/ext4/dir.c | 3 ++- fs/ext4/inode.c | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-)
fs/ext4/dir.c +2 -1
@@ -132,7 +132,8 @@ static int ext4_readdir(struct file * fi err =ext4_get_blocks_wrap (NULL , inode, blk,1 , &map_bh,0 ,0 );if (err >0 ) {pgoff_t index = map_bh.b_blocknr >> - (PAGE_CACHE_SHIFT - inode->i_blkbits); + (page_cache_size (inode->i_mapping) + - inode->i_blkbits);if (!ra_has_index (&filp->f_ra, index)) page_cache_sync_readahead( sb->s_bdev->bd_inode->i_mapping,
fs/ext4/inode.c +17 -16
@@ -1110,8 +1110,8 @@ static int ext4_write_begin(struct filepgoff_t index;unsigned from, to; - index = pos >>PAGE_CACHE_SHIFT ; - from = pos & (PAGE_CACHE_SIZE -1 ); + index =page_cache_index (mapping, pos); + from =page_cache_offset (mapping, pos); to = from + len; retry:
@@ -1206,7 +1206,7 @@ static int ext4_ordered_write_end(structunsigned from, to;int ret =0 , ret2; - from = pos & (PAGE_CACHE_SIZE -1 ); + from =page_cache_offset (mapping, pos); to = from + len; ret = walk_page_buffers(handle, page_buffers(page),
@@ -1276,7 +1276,7 @@ static int ext4_journalled_write_end(strint partial =0 ;unsigned from, to; - from = pos & (PAGE_CACHE_SIZE -1 ); + from =page_cache_offset (mapping, pos); to = from + len;if (copied < len) {
@@ -1579,6 +1579,7 @@ static int ext4_ordered_writepage(structhandle_t *handle =NULL ;int ret =0 ;int err; +int pagesize =page_cache_size (inode->i_mapping);J_ASSERT (PageLocked (page));
@@ -1601,8 +1602,7 @@ static int ext4_ordered_writepage(struct (1 << BH_Dirty)|(1 << BH_Uptodate)); } page_bufs =page_buffers (page); -walk_page_buffers (handle, page_bufs,0 , -PAGE_CACHE_SIZE ,NULL , bget_one); +walk_page_buffers (handle, page_bufs,0 , pagesize,NULL , bget_one); ret =block_write_full_page (page, ext4_get_block, wbc);
@@ -1619,13 +1619,12 @@ static int ext4_ordered_writepage(struct* and generally junk. */ if (ret ==0 ) { - err =walk_page_buffers (handle, page_bufs,0 ,PAGE_CACHE_SIZE , + err =walk_page_buffers (handle, page_bufs,0 , pagesize,NULL , jbd2_journal_dirty_data_fn);if (!ret) ret = err; } -walk_page_buffers (handle, page_bufs,0 , -PAGE_CACHE_SIZE ,NULL , bput_one); +walk_page_buffers (handle, page_bufs,0 , pagesize,NULL , bput_one); err =ext4_journal_stop (handle);if (!ret) ret = err;
@@ -1677,6 +1676,7 @@ static int ext4_journalled_writepage(strhandle_t *handle =NULL ;int ret =0 ;int err; +int pagesize =page_cache_size (inode->i_mapping);if (ext4_journal_current_handle ()) goto no_write;
@@ -1693,17 +1693,17 @@ static int ext4_journalled_writepage(str* doesn't seem much point in redirtying the page here. */ ClearPageChecked (page); - ret =block_prepare_write (page,0 ,PAGE_CACHE_SIZE , + ret =block_prepare_write (page,0 ,page_cache_size (mapping), ext4_get_block);if (ret !=0 ) {ext4_journal_stop (handle); goto out_unlock; } ret =walk_page_buffers (handle,page_buffers (page),0 , -PAGE_CACHE_SIZE ,NULL , do_journal_get_write_access); +page_cache_size (mapping),NULL , do_journal_get_write_access); err =walk_page_buffers (handle,page_buffers (page),0 , -PAGE_CACHE_SIZE ,NULL , write_end_fn); +page_cache_size (mapping),NULL , write_end_fn);if (ret ==0 ) ret = err;EXT4_I (inode)->i_state |=EXT4_STATE_JDATA ;
@@ -1936,8 +1936,8 @@ void ext4_set_aops(struct inode *inode)int ext4_block_truncate_page (handle_t *handle,struct page *page,struct address_space *mapping,loff_t from) { -ext4_fsblk_t index = from >>PAGE_CACHE_SHIFT ; -unsigned offset = from & (PAGE_CACHE_SIZE -1 ); +ext4_fsblk_t index =page_cache_index (mapping, from); +unsigned offset =page_cache_offset (mapping, from);unsigned blocksize, length, pos;ext4_lblk_t iblock;struct inode *inode = mapping->host;
@@ -1946,7 +1946,8 @@ int ext4_block_truncate_page(handle_t *h blocksize = inode->i_sb->s_blocksize; length = blocksize - (offset & (blocksize -1 )); - iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); + iblock = index << + (page_cache_shift (mapping) - inode->i_sb->s_blocksize_bits);/* * For "nobh" option, we can only work if we don't need to
@@ -2426,7 +2427,7 @@ void ext4_truncate(struct inode *inode) page =NULL ; }else { page =grab_cache_page (mapping, - inode->i_size >>PAGE_CACHE_SHIFT ); +page_cache_index (mapping, inode->i_size));if (!page)return ; }
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 16/19] Use page_cache_xxx in fs/ext4
Quoted 16 lines · Christoph Lameter
fs/ext4/inode.c +2
-1@@ -1677,6 +1676,7 @@ static int ext4_journalled_writepage(strhandle_t *handle =NULL ;int ret =0 ;int err; +int pagesize =page_cache_size (inode->i_mapping);if (ext4_journal_current_handle ()) goto no_write;@@ -1693,17 +1693,17 @@ static int ext4_journalled_writepage(str* doesn't seem much point in redirtying the page here. */ ClearPageChecked (page); - ret =block_prepare_write (page,0 ,PAGE_CACHE_SIZE , + ret =block_prepare_write (page,0 ,page_cache_size (mapping), ext4_get_block);if (ret !=0 ) {
fs/ext4/inode.c static int ext4_journalled_writepage(str · line 1706
Quoted 10 lines
fs/ext4/inode.c +2
-2ext4_journal_stop (handle); goto out_unlock; } ret =walk_page_buffers (handle,page_buffers (page),0 , -PAGE_CACHE_SIZE ,NULL , do_journal_get_write_access); +page_cache_size (mapping),NULL , do_journal_get_write_access); err =walk_page_buffers (handle,page_buffers (page),0 , -PAGE_CACHE_SIZE ,NULL , write_end_fn); +page_cache_size (mapping),NULL , write_end_fn);
These three should use the pagesize variable.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 16/19] Use page_cache_xxx in fs/ext4
Quoted 1 line · David Chinner
These three should use the pagesize variable.
ext4: use pagesize variable instead of the inline function
--- fs/ext4/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/ext4/inode.c +3 -4
@@ -1693,17 +1693,16 @@ static int ext4_journalled_writepage(str* doesn't seem much point in redirtying the page here. */ ClearPageChecked (page); - ret =block_prepare_write (page,0 ,page_cache_size (mapping), - ext4_get_block); + ret =block_prepare_write (page,0 , pagesize, ext4_get_block);if (ret !=0 ) {ext4_journal_stop (handle); goto out_unlock; } ret =walk_page_buffers (handle,page_buffers (page),0 , -page_cache_size (mapping),NULL , do_journal_get_write_access); + pagesize,NULL , do_journal_get_write_access); err =walk_page_buffers (handle,page_buffers (page),0 , -page_cache_size (mapping),NULL , write_end_fn); + pagesize,NULL , write_end_fn);if (ret ==0 ) ret = err;EXT4_I (inode)->i_state |=EXT4_STATE_JDATA ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 16/19] Use page_cache_xxx in fs/ext4
Quoted 27 lines · Christoph Lameter
Quoted 1 line · David Chinner
These three should use the pagesize variable.
ext4: use pagesize variable instead of the inline function
Signed-off-by Christoph Lameter <[email protected]>--- fs/ext4/inode.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)Index:
mm/fs/ext4/inode.c
===================================================================fs/ext4/inode.c +1
-2@@ -1693,17 +1693,16 @@ static int ext4_journalled_writepage(str* doesn't seem much point in redirtying the page here. */ ClearPageChecked (page); - ret =block_prepare_write (page,0 ,page_cache_size (mapping), - ext4_get_block); + ret =block_prepare_write (page,0 , pagesize, ext4_get_block);if (ret !=0 ) {ext4_journal_stop (handle); goto out_unlock; }
fs/ext4/inode.c static int ext4_journalled_writepage(str · line 1708
Quoted 10 lines
fs/ext4/inode.c +2
-2ret =walk_page_buffers (handle,page_buffers (page),0 , -page_cache_size (mapping),NULL , do_journal_get_write_access); + pagesize,NULL , do_journal_get_write_access); err =walk_page_buffers (handle,page_buffers (page),0 , -page_cache_size (mapping),NULL , write_end_fn); + pagesize,NULL , write_end_fn);if (ret ==0 ) ret = err;EXT4_I (inode)->i_state |=EXT4_STATE_JDATA ;
ok.
Cheers,
dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 17/19 Use page_cache_xxx in fs/reiserfs
In reply to Christoph LameterUse page_cache_xxx in fs/reiserfs
--- fs/reiserfs/file.c | 6 ++++-- fs/reiserfs/inode.c | 33 ++++++++++++++++++++------------- fs/reiserfs/ioctl.c | 2 +- fs/reiserfs/stree.c | 5 +++-- fs/reiserfs/tail_conversion.c | 5 +++-- fs/reiserfs/xattr.c | 19 ++++++++++--------- 6 files changed, 41 insertions(+), 29 deletions(-)
fs/reiserfs/file.c +4 -2
@@ -161,11 +161,12 @@ int reiserfs_commit_page(struct inode *iint partial =0 ;unsigned blocksize;struct buffer_head *bh, *head; -unsigned long i_size_index = inode->i_size >>PAGE_CACHE_SHIFT ; +unsigned long i_size_index = +page_cache_index (inode->i_mapping, inode->i_size);int new;int logit =reiserfs_file_data_log (inode);struct super_block *s = inode->i_sb; -int bh_per_page =PAGE_CACHE_SIZE / s->s_blocksize; +int bh_per_page =page_cache_size (inode->i_mapping) / s->s_blocksize;struct reiserfs_transaction_handle th;int ret =0 ;
@@ -260,6 +261,7 @@ static ssize_t reiserfs_file_write(struc/* To simplify coding at this time, we store locked pages in array for now */ struct reiserfs_transaction_handle th; +struct address_space *mapping = inode->i_mapping; th.t_trans_id =0 ;/* If a filesystem is converted from 3.5 to 3.6, we'll have v3.5 items
fs/reiserfs/inode.c +20 -13
@@ -337,7 +337,8 @@ static int _get_block_create_0(struct in goto finished; }// read file tail into part of page - offset = (cpu_key_k_offset (&key) -1 ) & (PAGE_CACHE_SIZE -1 ); + offset =page_cache_offset (inode->i_mapping, +cpu_key_k_offset (&key) -1 ); fs_gen =get_generation (inode->i_sb);copy_item_head (&tmp_ih, ih);
@@ -523,10 +524,10 @@ static int convert_tail_for_hole(structreturn -EIO ;/* always try to read until the end of the block */ - tail_start = tail_offset & (PAGE_CACHE_SIZE -1 ); + tail_start =page_cache_offset (inode->i_mapping, tail_offset); tail_end = (tail_start | (bh_result->b_size -1 )) +1 ; - index = tail_offset >>PAGE_CACHE_SHIFT ; + index =page_cache_index (inode->i_mapping, tail_offset);/* hole_page can be zero in case of direct_io, we are sure that we cannot get here if we write with O_DIRECT into tail page */
@@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode */* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ -unsigned long index = (p_s_inode->i_size -1 ) >>PAGE_CACHE_SHIFT ; +unsigned long index =page_cache_index (p_s_inode->i_mapping, + p_s_inode->i_size -1 );unsigned long pos =0 ;unsigned long start =0 ;unsigned long blocksize = p_s_inode->i_sb->s_blocksize; -unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE -1 ); +unsigned long offset =page_cache_index (p_s_inode->i_mapping, + p_s_inode->i_size);struct buffer_head *bh;struct buffer_head *head;struct page *page;
@@ -2076,7 +2079,8 @@ int reiserfs_truncate_file(struct inode {struct reiserfs_transaction_handle th;/* we want the offset for the first byte after the end of the file */ -unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE -1 ); +unsigned long offset =page_cache_offset (p_s_inode->i_mapping, + p_s_inode->i_size);unsigned blocksize = p_s_inode->i_sb->s_blocksize;unsigned length;struct page *page =NULL ;
@@ -2225,7 +2229,7 @@ static int map_block_for_writepage(struc }else if (is_direct_le_ih (ih)) {char *p; p =page_address (bh_result->b_page); - p += (byte_offset -1 ) & (PAGE_CACHE_SIZE -1 ); + p +=page_cache_offset (inode->i_mapping, byte_offset -1 ); copy_size =ih_item_len (ih) - pos_in_item; fs_gen =get_generation (inode->i_sb);
@@ -2324,7 +2328,8 @@ static int reiserfs_write_full_page(stru struct writeback_control *wbc) {struct inode *inode = page->mapping->host; -unsigned long end_index = inode->i_size >>PAGE_CACHE_SHIFT ; +unsigned long end_index =page_cache_index (inode->i_mapping, + inode->i_size);int error =0 ;unsigned long block;sector_t last_block;
@@ -2334,7 +2339,7 @@ static int reiserfs_write_full_page(struint checked =PageChecked (page);struct reiserfs_transaction_handle th;struct super_block *s = inode->i_sb; -int bh_per_page =PAGE_CACHE_SIZE / s->s_blocksize; +int bh_per_page =page_cache_size (inode->i_mapping) / s->s_blocksize; th.t_trans_id =0 ;/* no logging allowed when nonblocking or from PF_MEMALLOC */
@@ -2361,16 +2366,18 @@ static int reiserfs_write_full_page(struif (page->index >= end_index) {unsigned last_offset; - last_offset = inode->i_size & (PAGE_CACHE_SIZE -1 ); + last_offset =page_cache_offset (inode->i_mapping, inode->i_size);/* no file contents in this page */ if (page->index >= end_index +1 || !last_offset) {unlock_page (page);return 0 ; } -zero_user_segment (page, last_offset,PAGE_CACHE_SIZE ); +zero_user_segment (page, last_offset, +page_cache_size (inode->i_mapping)); } bh = head; - block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits); + block = page->index << (page_cache_shift (inode->i_mapping) + - s->s_blocksize_bits); last_block = (i_size_read (inode) -1 ) >> inode->i_blkbits;/* first map all the buffers, logging any direct items we find */ do {
@@ -2765,7 +2772,7 @@ int reiserfs_commit_write(struct file *f unsigned from, unsigned to) {struct inode *inode = page->mapping->host; -loff_t pos = ((loff_t ) page->index <<PAGE_CACHE_SHIFT ) + to; +loff_t pos =page_cache_pos (page->mapping, page->index, to);int ret =0 ;int update_sd =0 ;struct reiserfs_transaction_handle *th =NULL ;
fs/reiserfs/ioctl.c +1 -1
@@ -194,8 +194,8 @@ static int reiserfs_unpack(struct inode** reiserfs_prepare_write on that page. This will force a ** reiserfs_get_block to unpack the tail for us. */ - index = inode->i_size >>PAGE_CACHE_SHIFT ; mapping = inode->i_mapping; + index =page_cache_index (mapping, inode->i_size); page =grab_cache_page (mapping, index); retval = -ENOMEM ;if (!page) {
fs/reiserfs/stree.c +3 -2
@@ -1283,7 +1283,8 @@ int reiserfs_delete_item(struct reiserfs*/ data =kmap_atomic (p_s_un_bh->b_page,KM_USER0 ); - off = ((le_ih_k_offset (&s_ih) -1 ) & (PAGE_CACHE_SIZE -1 )); + off =page_cache_offset (p_s_inode->i_mapping, +le_ih_k_offset (&s_ih) -1 );memcpy (data + off,B_I_PITEM (PATH_PLAST_BUFFER (p_s_path), &s_ih), n_ret_value);
@@ -1439,7 +1440,7 @@ static void unmap_buffers(struct page *pif (page) {if (page_has_buffers (page)) { - tail_index = pos & (PAGE_CACHE_SIZE -1 ); + tail_index =page_cache_offset (page_mapping (page), pos); cur_index =0 ; head =page_buffers (page); bh = head;
fs/reiserfs/tail_conversion.c +3 -2
@@ -128,7 +128,8 @@ int direct2indirect(struct reiserfs_tran*/ if (up_to_date_bh) {unsigned pgoff = - (tail_offset + total_tail -1 ) & (PAGE_CACHE_SIZE -1 ); +page_cache_offset (inode->i_mapping, + tail_offset + total_tail -1 );char *kaddr =kmap_atomic (up_to_date_bh->b_page,KM_USER0 );memset (kaddr + pgoff,0 , n_blk_size - total_tail);kunmap_atomic (kaddr,KM_USER0 );
@@ -238,7 +239,7 @@ int indirect2direct(struct reiserfs_tran** the page was locked and this part of the page was up to date when ** indirect2direct was called, so we know the bytes are still valid */ - tail = tail + (pos & (PAGE_CACHE_SIZE -1 )); + tail = tail +page_cache_offset (p_s_inode->i_mapping, pos);PATH_LAST_POSITION (p_s_path)++;
fs/reiserfs/xattr.c +10 -9
@@ -468,13 +468,13 @@ reiserfs_xattr_set(struct inode *inode,while (buffer_pos < buffer_size || buffer_pos ==0 ) {size_t chunk;size_t skip =0 ; -size_t page_offset = (file_pos & (PAGE_CACHE_SIZE -1 )); -if (buffer_size - buffer_pos >PAGE_CACHE_SIZE ) - chunk =PAGE_CACHE_SIZE ; +size_t page_offset =page_cache_offset (mapping, file_pos); +if (buffer_size - buffer_pos >page_cache_size (mapping)) + chunk =page_cache_size (mapping);else chunk = buffer_size - buffer_pos; - page =reiserfs_get_page (xinode, file_pos >>PAGE_CACHE_SHIFT ); + page =reiserfs_get_page (xinode,page_cache_index (mapping, file_pos));if (IS_ERR (page)) { err =PTR_ERR (page); goto out_filp;
@@ -486,8 +486,8 @@ reiserfs_xattr_set(struct inode *inode,if (file_pos ==0 ) {struct reiserfs_xattr_header *rxh; skip = file_pos =sizeof (struct reiserfs_xattr_header ); -if (chunk + skip >PAGE_CACHE_SIZE ) - chunk =PAGE_CACHE_SIZE - skip; +if (chunk + skip >page_cache_size (mapping)) + chunk =page_cache_size (mapping) - skip; rxh = (struct reiserfs_xattr_header *)data; rxh->h_magic =cpu_to_le32 (REISERFS_XATTR_MAGIC ); rxh->h_hash =cpu_to_le32 (xahash);
@@ -577,12 +577,13 @@ reiserfs_xattr_get(const struct inode *isize_t chunk;char *data;size_t skip =0 ; -if (isize - file_pos >PAGE_CACHE_SIZE ) - chunk =PAGE_CACHE_SIZE ; +if (isize - file_pos >page_cache_size (xinode->i_mapping)) + chunk =page_cache_size (xinode->i_mapping);else chunk = isize - file_pos; - page =reiserfs_get_page (xinode, file_pos >>PAGE_CACHE_SHIFT ); + page =reiserfs_get_page (xinode, +page_cache_index (xinode->i_mapping, file_pos));if (IS_ERR (page)) { err =PTR_ERR (page); goto out_dput;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 17/19] Use page_cache_xxx in fs/reiserfs
fs/reiserfs/inode.c static int grab_tail_page(struct inode * · line 2010
Quoted 13 lines · Christoph Lameter
fs/reiserfs/inode.c +4
-2@@ -2000,11 +2001,13 @@ static int grab_tail_page(struct inode */* we want the page with the last byte in the file, ** not the page that will hold the next byte for appending */ -unsigned long index = (p_s_inode->i_size -1 ) >>PAGE_CACHE_SHIFT ; +unsigned long index =page_cache_index (p_s_inode->i_mapping, + p_s_inode->i_size -1 );unsigned long pos =0 ;unsigned long start =0 ;unsigned long blocksize = p_s_inode->i_sb->s_blocksize; -unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE -1 ); +unsigned long offset =page_cache_index (p_s_inode->i_mapping, + p_s_inode->i_size);
unsigned long offset = page_cache_offset(p_s_inode->i_mapping,
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 17/19] Use page_cache_xxx in fs/reiserfs
Quoted 8 lines · David Chinner
Review
Quoted 5 lines
(quoted diff) +2
-1unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size);unsigned long offset = page_cache_offset(p_s_inode->i_mapping,
Reiserfs: Wrong type of inline function
--- fs/reiserfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/reiserfs/inode.c +1 -1
@@ -2006,7 +2006,7 @@ static int grab_tail_page(struct inode *unsigned long pos =0 ;unsigned long start =0 ;unsigned long blocksize = p_s_inode->i_sb->s_blocksize; -unsigned long offset =page_cache_index (p_s_inode->i_mapping, +unsigned long offset =page_cache_offset (p_s_inode->i_mapping, p_s_inode->i_size);struct buffer_head *bh;struct buffer_head *head;
Re: [patch 17/19] Use page_cache_xxx in fs/reiserfs
Quoted 26 lines · Christoph Lameter
Quoted 8 lines · David Chinner
Review
Quoted 5 lines
(quoted diff) +2
-1unsigned long start = 0; unsigned long blocksize = p_s_inode->i_sb->s_blocksize; - unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); + unsigned long offset = page_cache_index(p_s_inode->i_mapping, + p_s_inode->i_size);unsigned long offset = page_cache_offset(p_s_inode->i_mapping,Reiserfs: Wrong type of inline function
Signed-off-by Christoph Lameter <[email protected]>--- fs/reiserfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
mm/fs/reiserfs/inode.c
===================================================================
fs/reiserfs/inode.c static int grab_tail_page(struct inode * · line 2012
Quoted 8 lines
fs/reiserfs/inode.c +1
-1@@ -2006,7 +2006,7 @@ static int grab_tail_page(struct inode *unsigned long pos =0 ;unsigned long start =0 ;unsigned long blocksize = p_s_inode->i_sb->s_blocksize; -unsigned long offset =page_cache_index (p_s_inode->i_mapping, +unsigned long offset =page_cache_offset (p_s_inode->i_mapping, p_s_inode->i_size);struct buffer_head *bh;struct buffer_head *head;
Ok.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 18/19 Use page_cache_xxx for fs/xfs
In reply to Christoph LameterUse page_cache_xxx for fs/xfs
--- fs/xfs/linux-2.6/xfs_aops.c | 55 +++++++++++++++++++++++--------------------- fs/xfs/linux-2.6/xfs_lrw.c | 4 +-- 2 files changed, 31 insertions(+), 28 deletions(-)
fs/xfs/linux-2.6/xfs_aops.c +29 -26
@@ -75,7 +75,7 @@ xfs_page_trace(xfs_inode_t *ip;bhv_vnode_t *vp =vn_from_inode (inode);loff_t isize =i_size_read (inode); -loff_t offset =page_offset (page); +loff_t offset =page_cache_offset (page->mapping);int delalloc =-1 , unmapped =-1 , unwritten =-1 ;if (page_has_buffers (page))
@@ -618,7 +618,7 @@ xfs_probe_page(break ; }while ((bh = bh->b_this_page) != head); }else - ret = mapped ?0 :PAGE_CACHE_SIZE ; + ret = mapped ?0 :page_cache_size (page->mapping); }return ret;
@@ -645,7 +645,7 @@ xfs_probe_cluster( }while ((bh = bh->b_this_page) != head);/* if we reached the end of the page, sum forwards in following pages */ - tlast =i_size_read (inode) >>PAGE_CACHE_SHIFT ; + tlast =page_cache_index (inode->i_mapping,i_size_read (inode)); tindex = startpage->index +1 ;/* Prune this back to avoid pathological behavior */
@@ -663,14 +663,14 @@ xfs_probe_cluster(size_t pg_offset, pg_len =0 ;if (tindex == tlast) { - pg_offset = -i_size_read (inode) & (PAGE_CACHE_SIZE -1 ); + pg_offset =page_cache_offset (inode->i_mapping, +i_size_read (inode));if (!pg_offset) { done =1 ;break ; } }else - pg_offset =PAGE_CACHE_SIZE ; + pg_offset =page_cache_size (inode->i_mapping);if (page->index == tindex && !TestSetPageLocked (page)) { pg_len =xfs_probe_page (page, pg_offset, mapped);
@@ -752,7 +752,8 @@ xfs_convert_page(int bbits = inode->i_blkbits;int len, page_dirty;int count =0 , done =0 , uptodate =1 ; -xfs_off_t offset =page_offset (page); +struct address_space *map = inode->i_mapping; +xfs_off_t offset =page_cache_pos (map, page->index,0 );if (page->index != tindex) goto fail;
@@ -760,7 +761,7 @@ xfs_convert_page( goto fail;if (PageWriteback (page)) goto fail_unlock_page; -if (page->mapping != inode->i_mapping) +if (page->mapping != map) goto fail_unlock_page;if (!xfs_is_delayed_page (page, (*ioendp)->io_type)) goto fail_unlock_page;
@@ -772,20 +773,20 @@ xfs_convert_page(* Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset & page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index +1 ) <<PAGE_CACHE_SHIFT , + (xfs_off_t)(page->index +1 ) <<page_cache_shift (map),i_size_read (inode)); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1), -PAGE_CACHE_SIZE ); - p_offset = p_offset ?roundup (p_offset, len) :PAGE_CACHE_SIZE ; + p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), +page_cache_size (map)); + p_offset = p_offset ?roundup (p_offset, len) :page_cache_size (map); page_dirty = p_offset / len; bh = head =page_buffers (page);
@@ -941,6 +942,8 @@ xfs_page_state_convert(int page_dirty, count =0 ;int trylock =0 ;int all_bh = unmapped; +struct address_space *map = inode->i_mapping; +int pagesize =page_cache_size (map);if (startio) {if (wbc->sync_mode ==WB_SYNC_NONE && wbc->nonblocking)
@@ -949,11 +952,11 @@ xfs_page_state_convert(/* Is this page beyond the end of the file? */ offset =i_size_read (inode); - end_index = offset >>PAGE_CACHE_SHIFT ; - last_index = (offset -1 ) >>PAGE_CACHE_SHIFT ; + end_index =page_cache_index (map, offset); + last_index =page_cache_index (map, (offset -1 ));if (page->index >= end_index) {if ((page->index >= end_index +1 ) || - !(i_size_read (inode) & (PAGE_CACHE_SIZE -1 ))) { + !(page_cache_offset (map,i_size_read (inode)))) {if (startio)unlock_page (page);return 0 ;
@@ -967,22 +970,22 @@ xfs_page_state_convert(* Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and -* hence give us the correct page_dirty count. On any other page, +* If we are on the last page, (page_cache_offset(mapping, end_offset)) +* will evaluate non-zero and be less than page_cache_size(mapping) +* and hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index +1 ) <<PAGE_CACHE_SHIFT , offset); + (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ), offset); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1), -PAGE_CACHE_SIZE ); - p_offset = p_offset ?roundup (p_offset, len) :PAGE_CACHE_SIZE ; + p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), + pagesize); + p_offset = p_offset ?roundup (p_offset, len) : pagesize; page_dirty = p_offset / len; bh = head =page_buffers (page); - offset =page_offset (page); + offset =page_cache_pos (map, page->index,0 ); flags =BMAPI_READ ; type =IOMAP_NEW ;
@@ -1130,7 +1133,7 @@ xfs_page_state_convert(if (ioend && iomap_valid) { offset = (iomap.iomap_offset + iomap.iomap_bsize -1 ) >> -PAGE_CACHE_SHIFT ; +page_cache_shift (map); tlast =min_t (pgoff_t, offset, last_index);xfs_cluster_write (inode, page->index +1 , &iomap, &ioend, wbc, startio, all_bh, tlast);
fs/xfs/linux-2.6/xfs_lrw.c +2 -2
@@ -142,8 +142,8 @@ xfs_iozero(unsigned offset, bytes;void *fsdata; - offset = (pos & (PAGE_CACHE_SIZE -1 ));/* Within page */ - bytes =PAGE_CACHE_SIZE - offset; + offset =page_cache_offset (mapping, pos);/* Within page */ + bytes =page_cache_size (mapping) - offset;if (bytes > count) bytes = count;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
Quoted 13 lines · Christoph Lameter
Use
page_cache_xxxfor fs/xfsSigned-off-by Christoph Lameter <[email protected]>--- fs/xfs/linux-2.6/xfs_aops.c | 55 +++++++++++++++++++++++--------------------- fs/xfs/linux-2.6/xfs_lrw.c | 4 +-- 2 files changed, 31 insertions(+), 28 deletions(-)Index:
mm/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
fs/xfs/linux-2.6/xfs_aops.c xfs_page_trace( · line 78
Quoted 5 lines
fs/xfs/linux-2.6/xfs_aops.c +1
-1@@ -75,7 +75,7 @@ xfs_page_trace(xfs_inode_t *ip;bhv_vnode_t *vp =vn_from_inode (inode);loff_t isize =i_size_read (inode); -loff_t offset =page_offset (page); +loff_t offset =page_cache_offset (page->mapping);
That's not right. Should be
loff_t offset = page_cache_pos(page->mapping, page->index, 0);
fs/xfs/linux-2.6/xfs_aops.c xfs_convert_page( · line 756
Quoted 7 lines
fs/xfs/linux-2.6/xfs_aops.c +2
-1@@ -752,7 +752,8 @@ xfs_convert_page(int bbits = inode->i_blkbits;int len, page_dirty;int count =0 , done =0 , uptodate =1 ; -xfs_off_t offset =page_offset (page); +struct address_space *map = inode->i_mapping; +xfs_off_t offset =page_cache_pos (map, page->index,0 );
But you got that one right ;)
Quoted 5 lines
fs/xfs/linux-2.6/xfs_aops.c +0
-1@@ -772,20 +773,20 @@ xfs_convert_page(* Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1))
fs/xfs/linux-2.6/xfs_aops.c xfs_convert_page( · line 783
Quoted 10 lines
fs/xfs/linux-2.6/xfs_aops.c +3
-2-* will evaluate non-zero and be less than PAGE_CACHE_SIZE and +* If we are on the last page, (end_offset & page_cache_mask()) +* will evaluate non-zero and be less than page_cache_size() and * hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index + 1) << PAGE_CACHE_SHIFT, + (xfs_off_t)(page->index + 1) << page_cache_shift(map),
(xfs_off_t)page_cache_pos(map, page->index + 1, 0),
fs/xfs/linux-2.6/xfs_aops.c xfs_convert_page( · line 788
Quoted 8 lines
fs/xfs/linux-2.6/xfs_aops.c +2
-3i_size_read(inode)); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1), -PAGE_CACHE_SIZE ); - p_offset = p_offset ?roundup (p_offset, len) :PAGE_CACHE_SIZE ; + p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), +page_cache_size (map));
Hmmmm. p_offset = min(val & 4095, 4096)? I think that should just be:
p_offset = page_cache_offset(map, end_offset);
Quoted 6 lines
fs/xfs/linux-2.6/xfs_aops.c +0
-2@@ -967,22 +970,22 @@ xfs_page_state_convert(* Derivation: * * End offset is the highest offset that this page should represent. -* If we are on the last page, (end_offset & (PAGE_CACHE_SIZE - 1)) -* will evaluate non-zero and be less than PAGE_CACHE_SIZE and
fs/xfs/linux-2.6/xfs_aops.c xfs_page_state_convert( · line 980
Quoted 10 lines
fs/xfs/linux-2.6/xfs_aops.c +4
-2-* hence give us the correct page_dirty count. On any other page, +* If we are on the last page, (page_cache_offset(mapping, end_offset)) +* will evaluate non-zero and be less than page_cache_size(mapping) +* and hence give us the correct page_dirty count. On any other page, * it will be zero and in that case we need page_dirty to be the * count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index +1 ) <<PAGE_CACHE_SHIFT , offset); + (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ), offset);
You got that one ;)
fs/xfs/linux-2.6/xfs_aops.c xfs_page_state_convert( · line 983
Quoted 6 lines
fs/xfs/linux-2.6/xfs_aops.c +2
-3len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, end_offset & (PAGE_CACHE_SIZE - 1), -PAGE_CACHE_SIZE ); - p_offset = p_offset ?roundup (p_offset, len) :PAGE_CACHE_SIZE ; + p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), + pagesize);
Again, that can be:
p_offset = page_cache_offset(map, end_offset);
and you can kill the new temporary pagesize variable.
fs/xfs/linux-2.6/xfs_aops.c xfs_page_state_convert( · line 1136
Quoted 6 lines
fs/xfs/linux-2.6/xfs_aops.c +1
-1@@ -1130,7 +1133,7 @@ xfs_page_state_convert(if (ioend && iomap_valid) { offset = (iomap.iomap_offset + iomap.iomap_bsize -1 ) >> -PAGE_CACHE_SHIFT ; +page_cache_shift (map);
offset = page_cache_index(map, (iomap.iomap_offset + iomap.iomap_bsize - 1));
fs/xfs/linux-2.6/xfs_aops.c xfs_iozero( · line 146
Quoted 8 lines
fs/xfs/linux-2.6/xfs_aops.c +2
-2@@ -142,8 +142,8 @@ xfs_iozero(unsigned offset, bytes;void *fsdata; - offset = (pos & (PAGE_CACHE_SIZE -1 ));/* Within page */ - bytes =PAGE_CACHE_SIZE - offset; + offset =page_cache_offset (mapping, pos);/* Within page */ + bytes =page_cache_size (mapping) - offset;
Kill the "within page" comment.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
In other words the following patch?
Fixes to the use of page_cache_xx functions in xfs
--- fs/xfs/linux-2.6/xfs_aops.c | 17 ++++++----------- fs/xfs/linux-2.6/xfs_lrw.c | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-)
fs/xfs/linux-2.6/xfs_aops.c +6 -11
@@ -75,7 +75,7 @@ xfs_page_trace(xfs_inode_t *ip;bhv_vnode_t *vp =vn_from_inode (inode);loff_t isize =i_size_read (inode); -loff_t offset =page_cache_offset (page->mapping); +loff_t offset =page_cache_pos (page->mapping, page->index,0 );int delalloc =-1 , unmapped =-1 , unwritten =-1 ;if (page_has_buffers (page))
@@ -780,13 +780,11 @@ xfs_convert_page(* count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index +1 ) <<page_cache_shift (map), + (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ),i_size_read (inode)); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), -page_cache_size (map)); - p_offset = p_offset ?roundup (p_offset, len) :page_cache_size (map); + p_offset =page_cache_offset (map, end_offset); page_dirty = p_offset / len; bh = head =page_buffers (page);
@@ -943,7 +941,6 @@ xfs_page_state_convert(int trylock =0 ;int all_bh = unmapped;struct address_space *map = inode->i_mapping; -int pagesize =page_cache_size (map);if (startio) {if (wbc->sync_mode ==WB_SYNC_NONE && wbc->nonblocking)
@@ -979,9 +976,7 @@ xfs_page_state_convert( end_offset = min_t(unsigned long long, (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ), offset); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - pagesize); - p_offset = p_offset ?roundup (p_offset, len) : pagesize; + p_offset =page_cache_offset (map, end_offset); page_dirty = p_offset / len; bh = head =page_buffers (page);
@@ -1132,8 +1127,8 @@ xfs_page_state_convert(xfs_start_page_writeback (page, wbc,1 , count);if (ioend && iomap_valid) { - offset = (iomap.iomap_offset + iomap.iomap_bsize -1 ) >> -page_cache_shift (map); + offset =page_cache_index (map, + (iomap.iomap_offset + iomap.iomap_bsize -1 )); tlast =min_t (pgoff_t, offset, last_index);xfs_cluster_write (inode, page->index +1 , &iomap, &ioend, wbc, startio, all_bh, tlast);
fs/xfs/linux-2.6/xfs_lrw.c +1 -1
@@ -142,7 +142,7 @@ xfs_iozero(unsigned offset, bytes;void *fsdata; - offset =page_cache_offset (mapping, pos);/* Within page */ + offset =page_cache_offset (mapping, pos); bytes =page_cache_size (mapping) - offset;if (bytes > count) bytes = count;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
Quoted 6 lines · Christoph Lameter
In other words the following patch?
Index:mm/fs/xfs/linux-2.6/xfs_aops.c
===================================================================
fs/xfs/linux-2.6/xfs_aops.c xfs_page_trace( · line 81
Quoted 8 lines
fs/xfs/linux-2.6/xfs_aops.c +1
-1@@ -75,7 +75,7 @@ xfs_page_trace(xfs_inode_t *ip;bhv_vnode_t *vp =vn_from_inode (inode);loff_t isize =i_size_read (inode); -loff_t offset =page_cache_offset (page->mapping); +loff_t offset =page_cache_pos (page->mapping, page->index,0 );int delalloc =-1 , unmapped =-1 , unwritten =-1 ;if (page_has_buffers (page))
Good.
fs/xfs/linux-2.6/xfs_aops.c xfs_convert_page( · line 787
Quoted 13 lines
fs/xfs/linux-2.6/xfs_aops.c +2
-4@@ -780,13 +780,11 @@ xfs_convert_page(* count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index +1 ) <<page_cache_shift (map), + (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ),i_size_read (inode)); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), -page_cache_size (map)); - p_offset = p_offset ?roundup (p_offset, len) :page_cache_size (map); + p_offset =page_cache_offset (map, end_offset);
No, still need the roundup. i.e.:
- p_offset = min_t(unsigned long, page_cache_offset(map, end_offset),
- page_cache_size(map));
+ p_offset = page_cache_offset(map, end_offset); p_offset = p_offset ? roundup(p_offset, len) : page_cache_size(map);
Quoted 12 lines
fs/xfs/linux-2.6/xfs_aops.c +0
-1page_dirty = p_offset / len; bh = head =page_buffers (page);@@ -943,7 +941,6 @@ xfs_page_state_convert(int trylock =0 ;int all_bh = unmapped;struct address_space *map = inode->i_mapping; -int pagesize =page_cache_size (map);if (startio) {if (wbc->sync_mode ==WB_SYNC_NONE && wbc->nonblocking)
fs/xfs/linux-2.6/xfs_aops.c xfs_page_state_convert( · line 979
Quoted 7 lines
fs/xfs/linux-2.6/xfs_aops.c +1
-3@@ -979,9 +976,7 @@ xfs_page_state_convert( end_offset = min_t(unsigned long long, (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ), offset); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - pagesize); - p_offset = p_offset ?roundup (p_offset, len) : pagesize; + p_offset =page_cache_offset (map, end_offset);
And still need the roundup here as well.
fs/xfs/linux-2.6/xfs_aops.c xfs_page_state_convert( · line 1131
Quoted 11 lines
fs/xfs/linux-2.6/xfs_aops.c +2
-2page_dirty = p_offset / len; bh = head =page_buffers (page);@@ -1132,8 +1127,8 @@ xfs_page_state_convert(xfs_start_page_writeback (page, wbc,1 , count);if (ioend && iomap_valid) { - offset = (iomap.iomap_offset + iomap.iomap_bsize -1 ) >> -page_cache_shift (map); + offset =page_cache_index (map, + (iomap.iomap_offset + iomap.iomap_bsize -1 ));
Good.
fs/xfs/linux-2.6/xfs_lrw.c xfs_iozero( · line 145
Quoted 13 lines
fs/xfs/linux-2.6/xfs_aops.c +0
-0tlast =min_t (pgoff_t, offset, last_index);xfs_cluster_write (inode, page->index +1 , &iomap, &ioend, wbc, startio, all_bh, tlast);Index:
mm/fs/xfs/linux-2.6/xfs_lrw.c
===================================================================fs/xfs/linux-2.6/xfs_lrw.c +1
-1@@ -142,7 +142,7 @@ xfs_iozero(unsigned offset, bytes;void *fsdata; - offset =page_cache_offset (mapping, pos);/* Within page */ + offset =page_cache_offset (mapping, pos);
Ok.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
Is this correct?
Fixes to the use of page_cache_xx functions in xfs
--- fs/xfs/linux-2.6/xfs_aops.c | 18 ++++++++---------- fs/xfs/linux-2.6/xfs_lrw.c | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-)
fs/xfs/linux-2.6/xfs_aops.c +8 -10
@@ -75,7 +75,7 @@ xfs_page_trace(xfs_inode_t *ip;bhv_vnode_t *vp =vn_from_inode (inode);loff_t isize =i_size_read (inode); -loff_t offset =page_cache_offset (page->mapping); +loff_t offset =page_cache_pos (page->mapping, page->index,0 );int delalloc =-1 , unmapped =-1 , unwritten =-1 ;if (page_has_buffers (page))
@@ -780,12 +780,11 @@ xfs_convert_page(* count of buffers on the page. */ end_offset = min_t(unsigned long long, - (xfs_off_t)(page->index +1 ) <<page_cache_shift (map), + (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ),i_size_read (inode)); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), -page_cache_size (map)); + p_offset =page_cache_offset (map, end_offset); p_offset = p_offset ?roundup (p_offset, len) :page_cache_size (map); page_dirty = p_offset / len;
@@ -943,7 +942,6 @@ xfs_page_state_convert(int trylock =0 ;int all_bh = unmapped;struct address_space *map = inode->i_mapping; -int pagesize =page_cache_size (map);if (startio) {if (wbc->sync_mode ==WB_SYNC_NONE && wbc->nonblocking)
@@ -979,9 +977,9 @@ xfs_page_state_convert( end_offset = min_t(unsigned long long, (xfs_off_t )page_cache_pos (map, page->index +1 ,0 ), offset); len =1 << inode->i_blkbits; - p_offset = min_t(unsigned long, page_cache_offset(map, end_offset), - pagesize); - p_offset = p_offset ?roundup (p_offset, len) : pagesize; + p_offset =page_cache_offset (map, end_offset); + p_offset = p_offset ?roundup (p_offset, len) :page_cache_size (map); + page_dirty = p_offset / len; bh = head =page_buffers (page);
@@ -1132,8 +1130,8 @@ xfs_page_state_convert(xfs_start_page_writeback (page, wbc,1 , count);if (ioend && iomap_valid) { - offset = (iomap.iomap_offset + iomap.iomap_bsize -1 ) >> -page_cache_shift (map); + offset =page_cache_index (map, + (iomap.iomap_offset + iomap.iomap_bsize -1 )); tlast =min_t (pgoff_t, offset, last_index);xfs_cluster_write (inode, page->index +1 , &iomap, &ioend, wbc, startio, all_bh, tlast);
fs/xfs/linux-2.6/xfs_lrw.c +1 -1
@@ -142,7 +142,7 @@ xfs_iozero(unsigned offset, bytes;void *fsdata; - offset =page_cache_offset (mapping, pos);/* Within page */ + offset =page_cache_offset (mapping, pos); bytes =page_cache_size (mapping) - offset;if (bytes > count) bytes = count;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 18/19] Use page_cache_xxx for fs/xfs
Quoted 1 line · Christoph Lameter
Is this correct?
Yup, looks good now.
Cheers,
Dave.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [patch 18/19] Use page_cache_xxx for fs/xfs
Quoted 5 lines · On Thu, 29 Nov 2007 15:10:13 +1100 David Chinner <[email protected]> wrote:
Quoted 1 line · Christoph Lameter
Is this correct?
Yup, looks good now.
Given the error rate in the xfs patch my confidence in the rest of the series isn't terribly high, sorry.
I guess I can suck up the core and xfs bits, but who is going to review the rest of them this closely?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 19/19 Use page_cache_xxx in drivers/block/rd.c
In reply to Christoph LameterUse page_cache_xxx in drivers/block/rd.c
--- drivers/block/rd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/rd.c +4 -4
@@ -122,7 +122,7 @@ static void make_page_uptodate(struct pa } }while ((bh = bh->b_this_page) != head); }else { -memset (page_address (page),0 ,PAGE_CACHE_SIZE ); +memset (page_address (page),0 ,page_cache_size (page_mapping (page))); }flush_dcache_page (page);SetPageUptodate (page);
@@ -215,9 +215,9 @@ static const struct address_space_operatstatic int rd_blkdev_pagecache_IO (int rw,struct bio_vec *vec,sector_t sector,struct address_space *mapping) { -pgoff_t index = sector >> (PAGE_CACHE_SHIFT -9 ); +pgoff_t index = sector >> (page_cache_size (mapping) -9 );unsigned int vec_offset = vec->bv_offset; -int offset = (sector <<9 ) & ~PAGE_CACHE_MASK ; +int offset =page_cache_offset (mapping, (sector <<9 ));int size = vec->bv_len;int err =0 ;
@@ -227,7 +227,7 @@ static int rd_blkdev_pagecache_IO(int rwchar *src;char *dst; - count =PAGE_CACHE_SIZE - offset; + count =page_cache_size (mapping) - offset;if (count > size) count = size; size -= count;
Signature · 5 lines
-- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [patch 19/19] Use page_cache_xxx in drivers/block/rd.c
Quoted 21 lines · Christoph Lameter
Use
page_cache_xxxindrivers/block/rd.cSigned-off-by Christoph Lameter <[email protected]>--- drivers/block/rd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)Index:
mm/drivers/block/rd.c
===================================================================drivers/block/rd.c +1
-1@@ -122,7 +122,7 @@ static void make_page_uptodate(struct pa } }while ((bh = bh->b_this_page) != head); }else { -memset (page_address (page),0 ,PAGE_CACHE_SIZE ); +memset (page_address (page),0 ,page_cache_size (page_mapping (page))); }flush_dcache_page (page);SetPageUptodate (page);
drivers/block/rd.c static const struct address_space_operat · line 218
Quoted 5 lines
drivers/block/rd.c +1
-1@@ -215,9 +215,9 @@ static const struct address_space_operatstatic int rd_blkdev_pagecache_IO (int rw,struct bio_vec *vec,sector_t sector,struct address_space *mapping) { -pgoff_t index = sector >> (PAGE_CACHE_SHIFT -9 ); +pgoff_t index = sector >> (page_cache_size (mapping) -9 );
page_cache_shift
Cheers,
Fengguang
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Christoph Lameter
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls.
The ultimate goal is to replace all uses of
PAGE_CACHE_xxxin the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices.Patchset against 2.6.24-rc3-mm2.
Signature · 9 lines
Dave Chinner Principal Engineer SGI Australian Software Group -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 4 lines · On Thu, 29 Nov 2007 15:20:39 +1100 David Chinner <[email protected]> wrote:
Quoted 3 lines · Christoph Lameter
This patchset cleans up page cache handling by replacing open coded shifts and adds with inline function calls.
Quoted 8 lines
Quoted 6 lines
The ultimate goal is to replace all uses of
PAGE_CACHE_xxxin the kernel through the use of these functions. All the functions take a mapping parameter. The mapping parameter is required if we want to support large block sizes in filesystems and block devices.Patchset against 2.6.24-rc3-mm2.
Reviewed-by Dave Chinner <[email protected]>
thanks ;) I'll merge version 2..
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>