Introduction - make some address_space_operations return void
Subsystems (4)
PATCH 1/1 Introduction - make some address_space_operations return void
While reading through the address_space_operations code, I discoverred that two methods return 'int' values that are never used: invalidatepage and sync_page.
Accordingly, the following two patches convert them to return 'void'.
Any comments?
NeilBrown
[PATCH 001 of 2] Make address_space_operations->invalidatepage return void [PATCH 002 of 2] Make address_space_operations->sync_page return void.
PATCH 1/1 Make address_space_operations->invalidatepage return void
The return value of this function is never used, so let's be honest and declare it as void.
Some places where invalidatepage returned 0, I have inserted a BUG_ON, partly for documentation purposes. I would be nice if these were verified by someone with more knowledge...
### Diffstat output
./fs/afs/file.c | 6 +++--- ./fs/buffer.c | 22 +++++++++++----------- ./fs/ext3/inode.c | 4 ++-- ./fs/jbd/transaction.c | 11 ++++------- ./fs/jfs/jfs_metapage.c | 7 +++---- ./fs/reiser4/as_ops.c | 13 ++++++------- ./fs/reiser4/vfs_ops.h | 2 +- ./fs/reiserfs/inode.c | 8 +++++--- ./fs/xfs/linux-2.6/xfs_aops.c | 4 ++-- ./include/linux/buffer_head.h | 4 ++-- ./include/linux/fs.h | 2 +- ./include/linux/jbd.h | 2 +- 12 files changed, 41 insertions(+), 44 deletions(-)
fs/afs/file.c renamed from fs/afs/file.c~current~ +3 -3
@@ -28,7 +28,7 @@ static int afs_file_release(struct inode#endif static int afs_file_readpage (struct file *file,struct page *page); -static int afs_file_invalidatepage (struct page *page,unsigned long offset); +static void afs_file_invalidatepage (struct page *page,unsigned long offset);static int afs_file_releasepage (struct page *page,gfp_t gfp_flags);struct inode_operations afs_file_inode_operations = {
@@ -212,7 +212,7 @@ int afs_cache_get_page_cookie(struct pag/* * invalidate part or all of a page */ -static int afs_file_invalidatepage (struct page *page,unsigned long offset) +static void afs_file_invalidatepage (struct page *page,unsigned long offset) {int ret =1 ;
@@ -238,11 +238,11 @@ static int afs_file_invalidatepage(strucif (!PageWriteback (page)) ret = page->mapping->a_ops->releasepage (page,0 ); +BUG_ON (!ret); } }_leave (" = %d" , ret); -return ret; }/* end afs_file_invalidatepage() */ /*****************************************************************************/
fs/buffer.c renamed from fs/buffer.c~current~ +11 -11
@@ -1598,11 +1598,10 @@ EXPORT_SYMBOL(try_to_release_page);* point. Because the caller is about to free (and possibly reuse) those * blocks on-disk. */ -int block_invalidatepage (struct page *page,unsigned long offset) +void block_invalidatepage (struct page *page,unsigned long offset) {struct buffer_head *head, *bh, *next;unsigned int curr_off =0 ; -int ret =1 ;BUG_ON (!PageLocked (page));if (!page_has_buffers (page))
@@ -1628,20 +1627,21 @@ int block_invalidatepage(struct page *pa* The get_block cached value has been unconditionally invalidated, * so real IO is not possible anymore. */ -if (offset ==0 ) - ret =try_to_release_page (page,0 ); +if (offset ==0 ) { +int ret =try_to_release_page (page,0 ); +BUG_ON (!ret); + } out: -return ret; +return ; }EXPORT_SYMBOL (block_invalidatepage); -int do_invalidatepage (struct page *page,unsigned long offset) +void do_invalidatepage (struct page *page,unsigned long offset) { -int (*invalidatepage)(struct page *,unsigned long ); - invalidatepage = page->mapping->a_ops->invalidatepage; -if (invalidatepage ==NULL ) - invalidatepage = block_invalidatepage; -return (*invalidatepage)(page, offset); +void (*invalidatepage)(struct page *,unsigned long ); + invalidatepage = page->mapping->a_ops->invalidatepage ? : + block_invalidatepage; + (*invalidatepage)(page, offset); }/*
fs/ext3/inode.c renamed from fs/ext3/inode.c~current~ +2 -2
@@ -1591,7 +1591,7 @@ ext3_readpages(struct file *file, structreturn mpage_readpages (mapping, pages, nr_pages, ext3_get_block); } -static int ext3_invalidatepage (struct page *page,unsigned long offset) +static void ext3_invalidatepage (struct page *page,unsigned long offset) {journal_t *journal =EXT3_JOURNAL (page->mapping->host);
@@ -1601,7 +1601,7 @@ static int ext3_invalidatepage(struct paif (offset ==0 )ClearPageChecked (page); -return journal_invalidatepage (journal, page, offset); +journal_invalidatepage (journal, page, offset); }static int ext3_releasepage (struct page *page,gfp_t wait)
fs/jbd/transaction.c renamed from fs/jbd/transaction.c~current~ +4 -7
@@ -1873,16 +1873,15 @@ zap_buffer_unlocked: }/** -* int journal_invalidatepage() +* void journal_invalidatepage() * @journal: journal to use for flush... * @page: page to flush * @offset: length of page to invalidate. * * Reap page buffers containing data after offset in page. * -* Return non-zero if the page's buffers were successfully reaped. */ -int journal_invalidatepage (journal_t *journal, +void journal_invalidatepage (journal_t *journal,struct page *page,unsigned long offset) {
@@ -1893,7 +1892,7 @@ int journal_invalidatepage(journal_t *joif (!PageLocked (page))BUG ();if (!page_has_buffers (page)) -return 1 ; +return ;/* We will potentially be playing with lists other than just the * data lists (especially for journaled data mode), so be
@@ -1916,11 +1915,9 @@ int journal_invalidatepage(journal_t *jo }while (bh != head);if (!offset) { -if (!may_free || !try_to_free_buffers (page)) -return 0 ; +BUG_ON (!may_free || !try_to_free_buffers (page));J_ASSERT (!page_has_buffers (page)); } -return 1 ; }/*
fs/jfs/jfs_metapage.c renamed from fs/jfs/jfs_metapage.c~current~ +3 -4
@@ -579,14 +579,13 @@ static int metapage_releasepage(struct preturn 0 ; } -static int metapage_invalidatepage (struct page *page,unsigned long offset) +static void metapage_invalidatepage (struct page *page,unsigned long offset) {BUG_ON (offset); -if (PageWriteback (page)) -return 0 ; +BUG_ON (PageWriteback (page)); -return metapage_releasepage (page,0 ); +metapage_releasepage (page,0 ); }struct address_space_operations jfs_metapage_aops = {
fs/reiser4/as_ops.c renamed from fs/reiser4/as_ops.c~current~ +6 -7
@@ -170,7 +170,7 @@ reiser4_readpages(struct file *file, str* @offset: starting offset for partial invalidation * */ -int reiser4_invalidatepage (struct page *page,unsigned long offset) +void reiser4_invalidatepage (struct page *page,unsigned long offset) {int ret =0 ;reiser4_context *ctx;
@@ -208,11 +208,11 @@ int reiser4_invalidatepage(struct page ** them. Check for this, and do nothing. */ if (get_super_fake (inode->i_sb) == inode) -return 0 ; +return ;if (get_cc_fake (inode->i_sb) == inode) -return 0 ; +return ;if (get_bitmap_fake (inode->i_sb) == inode) -return 0 ; +return ;assert ("vs-1426" ,PagePrivate (page));assert ("vs-1427" , page->mapping ==jnode_get_mapping (jnode_by_page (page)));
@@ -222,7 +222,7 @@ int reiser4_invalidatepage(struct page * ctx =init_context (inode->i_sb);if (IS_ERR (ctx)) -return PTR_ERR (ctx); +return ; node =jprivate (page);spin_lock_jnode (node);
@@ -236,7 +236,7 @@ int reiser4_invalidatepage(struct page *unhash_unformatted_jnode (node);jput (node);reiser4_exit_context (ctx); -return 0 ; +return ; }spin_unlock_jnode (node);
@@ -265,7 +265,6 @@ int reiser4_invalidatepage(struct page * }reiser4_exit_context (ctx); -return ret; }/* help function called from reiser4_releasepage(). It returns true if jnode
fs/reiser4/vfs_ops.h renamed from fs/reiser4/vfs_ops.h~current~ +1 -1
@@ -24,7 +24,7 @@ int reiser4_writepage(struct page *, strint reiser4_set_page_dirty (struct page *);int reiser4_readpages (struct file *,struct address_space *,struct list_head *pages,unsigned nr_pages); -int reiser4_invalidatepage (struct page *,unsigned long offset); +void reiser4_invalidatepage (struct page *,unsigned long offset);int reiser4_releasepage (struct page *,gfp_t );extern int reiser4_update_sd (struct inode *);
fs/reiserfs/inode.c renamed from fs/reiserfs/inode.c~current~ +5 -3
@@ -2797,7 +2797,7 @@ static int invalidatepage_can_drop(struc }/* clm -- taken from fs/buffer.c:block_invalidate_page */ -static int reiserfs_invalidatepage (struct page *page,unsigned long offset) +static void reiserfs_invalidatepage (struct page *page,unsigned long offset) {struct buffer_head *head, *bh, *next;struct inode *inode = page->mapping->host;
@@ -2836,10 +2836,12 @@ static int reiserfs_invalidatepage(struc* The get_block cached value has been unconditionally invalidated, * so real IO is not possible anymore. */ -if (!offset && ret) +if (!offset && ret) { ret =try_to_release_page (page,0 ); +BUG_ON (!ret); + } out: -return ret; +return ; }static int reiserfs_set_page_dirty (struct page *page)
fs/xfs/linux-2.6/xfs_aops.c renamed from fs/xfs/linux-2.6/xfs_aops.c~current~ +2 -2
@@ -1371,14 +1371,14 @@ out_unlock:return error; } -STATIC int +STATIC voidlinvfs_invalidate_page (struct page *page,unsigned long offset) {xfs_page_trace (XFS_INVALIDPAGE_ENTER , page->mapping->host, page, offset); -return block_invalidatepage (page, offset); +block_invalidatepage (page, offset); }/*
include/linux/buffer_head.h renamed from include/linux/buffer_head.h~current~ +2 -2
@@ -189,8 +189,8 @@ extern int buffer_heads_over_limit;* address_spaces. */ int try_to_release_page (struct page * page,gfp_t gfp_mask); -int block_invalidatepage (struct page *page,unsigned long offset); -int do_invalidatepage (struct page *page,unsigned long offset); +void block_invalidatepage (struct page *page,unsigned long offset); +void do_invalidatepage (struct page *page,unsigned long offset);int block_write_full_page (struct page *page,get_block_t *get_block,struct writeback_control *wbc);int block_read_full_page (struct page *,get_block_t *);
include/linux/fs.h renamed from include/linux/fs.h~current~ +1 -1
@@ -359,7 +359,7 @@ struct address_space_operations {int (*commit_write)(struct file *,struct page *,unsigned ,unsigned );/* Unfortunately this kludge is needed for FIBMAP. Don't use it */ sector_t (*bmap)(struct address_space *,sector_t ); -int (*invalidatepage) (struct page *,unsigned long ); +void (*invalidatepage) (struct page *,unsigned long );int (*releasepage) (struct page *,gfp_t );ssize_t (*direct_IO)(int ,struct kiocb *,const struct iovec *iov,loff_t offset,unsigned long nr_segs);
include/linux/jbd.h renamed from include/linux/jbd.h~current~ +1 -1
@@ -900,7 +900,7 @@ extern int journal_dirty_metadata (handextern void journal_release_buffer (handle_t *,struct buffer_head *);extern int journal_forget (handle_t *,struct buffer_head *);extern void journal_sync_buffer (struct buffer_head *); -extern int journal_invalidatepage (journal_t *, +extern void journal_invalidatepage (journal_t *,struct page *,unsigned long );extern int journal_try_to_free_buffers (journal_t *,struct page *,gfp_t );extern int journal_stop (handle_t *);
PATCH 1/1 Make address_space_operations->sync_page return void.
In reply to NeilBrownThe only user ignores the return value, and the only instanace (block_sync_page) always returns 0...
### Diffstat output
./fs/buffer.c | 3 +-- ./fs/cifs/file.c | 6 ++++-- ./include/linux/buffer_head.h | 2 +- ./include/linux/fs.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-)
fs/buffer.c renamed from fs/buffer.c~current~ +1 -2
@@ -3012,7 +3012,7 @@ out: }EXPORT_SYMBOL (try_to_free_buffers); -int block_sync_page (struct page *page) +void block_sync_page (struct page *page) {struct address_space *mapping;
@@ -3020,7 +3020,6 @@ int block_sync_page(struct page *page) mapping =page_mapping (page);if (mapping)blk_run_backing_dev (mapping->backing_dev_info, page); -return 0 ; }/*
fs/cifs/file.c renamed from fs/cifs/file.c~current~ +4 -2
@@ -1339,7 +1339,7 @@ int cifs_fsync(struct file *file, structreturn rc; } -/* static int cifs_sync_page(struct page *page) +/* static void cifs_sync_page(struct page *page) { struct address_space *mapping; struct inode *inode;
@@ -1353,16 +1353,18 @@ int cifs_fsync(struct file *file, structreturn 0; inode = mapping->host; if (!inode) -return 0; */ +return; */ /* fill in rpages then result = cifs_pagein_inode(inode, index, rpages); */ /* BB finish */ /* cFYI(1, ("rpages is %d for sync page of Index %ld ", rpages, index)); +#if 0 if (rc < 0) return rc; return 0; +#endif } */ /*
include/linux/buffer_head.h renamed from include/linux/buffer_head.h~current~ +1 -1
@@ -200,7 +200,7 @@ int cont_prepare_write(struct page*, unsint generic_cont_expand (struct inode *inode,loff_t size);int generic_cont_expand_simple (struct inode *inode,loff_t size);int block_commit_write (struct page *page,unsigned from,unsigned to); -int block_sync_page (struct page *); +void block_sync_page (struct page *);sector_t generic_block_bmap (struct address_space *,sector_t ,get_block_t *);int generic_commit_write (struct file *,struct page *,unsigned ,unsigned );int block_truncate_page (struct address_space *,loff_t ,get_block_t *);
include/linux/fs.h renamed from include/linux/fs.h~current~ +1 -1
@@ -340,7 +340,7 @@ struct writeback_control;struct address_space_operations {int (*writepage)(struct page *page,struct writeback_control *wbc);int (*readpage)(struct file *,struct page *); -int (*sync_page)(struct page *); +void (*sync_page)(struct page *);/* Write back some dirty pages from this mapping. */ int (*writepages)(struct address_space *,struct writeback_control *);