Skip to content

Commit

Permalink
[PATCH] Make address_space_operations->invalidatepage return void
Browse files Browse the repository at this point in the history
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 comments
suggesting a BUG_ON.

[akpm@osdl.org: JBD BUG fix]
[akpm@osdl.org: rework for git-nfs]
[akpm@osdl.org: don't go BUG in block_invalidate_page()]
Signed-off-by: Neil Brown <neilb@suse.de>
Acked-by: Dave Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Mar 26, 2006
1 parent 3978d71 commit 2ff28e2
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 38 deletions.
6 changes: 3 additions & 3 deletions fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static int afs_file_release(struct inode *inode, struct file *file);
#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 = {
Expand Down Expand Up @@ -212,7 +212,7 @@ int afs_cache_get_page_cookie(struct page *page,
/*
* 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;

Expand All @@ -238,11 +238,11 @@ static int afs_file_invalidatepage(struct page *page, unsigned long offset)
if (!PageWriteback(page))
ret = page->mapping->a_ops->releasepage(page,
0);
/* possibly should BUG_ON(!ret); - neilb */
}
}

_leave(" = %d", ret);
return ret;
} /* end afs_file_invalidatepage() */

/*****************************************************************************/
Expand Down
18 changes: 8 additions & 10 deletions fs/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,11 +1593,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))
Expand All @@ -1624,19 +1623,18 @@ int block_invalidatepage(struct page *page, unsigned long offset)
* so real IO is not possible anymore.
*/
if (offset == 0)
ret = try_to_release_page(page, 0);
try_to_release_page(page, 0);
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);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ ext3_readpages(struct file *file, struct address_space *mapping,
return 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);

Expand All @@ -1440,7 +1440,7 @@ static int ext3_invalidatepage(struct page *page, unsigned long offset)
if (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)
Expand Down
13 changes: 5 additions & 8 deletions fs/jbd/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1873,16 +1873,15 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
}

/**
* 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)
{
Expand All @@ -1893,7 +1892,7 @@ int journal_invalidatepage(journal_t *journal,
if (!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
Expand All @@ -1916,11 +1915,9 @@ int journal_invalidatepage(journal_t *journal,
} while (bh != head);

if (!offset) {
if (!may_free || !try_to_free_buffers(page))
return 0;
J_ASSERT(!page_has_buffers(page));
if (may_free && try_to_free_buffers(page))
J_ASSERT(!page_has_buffers(page));
}
return 1;
}

/*
Expand Down
7 changes: 3 additions & 4 deletions fs/jfs/jfs_metapage.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,14 +578,13 @@ static int metapage_releasepage(struct page *page, gfp_t gfp_mask)
return 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 = {
Expand Down
3 changes: 1 addition & 2 deletions fs/nfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,9 @@ static int nfs_commit_write(struct file *file, struct page *page, unsigned offse
return status;
}

static int nfs_invalidate_page(struct page *page, unsigned long offset)
static void nfs_invalidate_page(struct page *page, unsigned long offset)
{
/* FIXME: we really should cancel any unstarted writes on this page */
return 1;
}

static int nfs_release_page(struct page *page, gfp_t gfp)
Expand Down
8 changes: 5 additions & 3 deletions fs/reiserfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ static int invalidatepage_can_drop(struct inode *inode, struct buffer_head *bh)
}

/* 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;
Expand Down Expand Up @@ -2832,10 +2832,12 @@ static int reiserfs_invalidatepage(struct page *page, unsigned long offset)
* 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);
/* maybe should BUG_ON(!ret); - neilb */
}
out:
return ret;
return;
}

static int reiserfs_set_page_dirty(struct page *page)
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/linux-2.6/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1442,14 +1442,14 @@ xfs_vm_readpages(
return mpage_readpages(mapping, pages, nr_pages, xfs_get_block);
}

STATIC int
STATIC void
xfs_vm_invalidatepage(
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);
}

struct address_space_operations xfs_address_space_operations = {
Expand Down
4 changes: 2 additions & 2 deletions include/linux/buffer_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,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);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/jbd.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ extern int journal_dirty_metadata (handle_t *, struct buffer_head *);
extern 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 *);
Expand Down

0 comments on commit 2ff28e2

Please sign in to comment.