Skip to content

Commit

Permalink
vfs: Introduce filemap_fdatawait_range
Browse files Browse the repository at this point in the history
This simple helper saves some filesystems conversion from byte offset
to page numbers and also makes the fdata* interface more complete.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
  • Loading branch information
Jan Kara committed Sep 14, 2009
1 parent 86d7101 commit d3bccb6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,8 @@ extern int write_inode_now(struct inode *, int);
extern int filemap_fdatawrite(struct address_space *);
extern int filemap_flush(struct address_space *);
extern int filemap_fdatawait(struct address_space *);
extern int filemap_fdatawait_range(struct address_space *, loff_t lstart,
loff_t lend);
extern int filemap_write_and_wait(struct address_space *mapping);
extern int filemap_write_and_wait_range(struct address_space *mapping,
loff_t lstart, loff_t lend);
Expand Down
20 changes: 20 additions & 0 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,26 @@ int wait_on_page_writeback_range(struct address_space *mapping,
return ret;
}

/**
* filemap_fdatawait_range - wait for all under-writeback pages to complete in a given range
* @mapping: address space structure to wait for
* @start: offset in bytes where the range starts
* @end: offset in bytes where the range ends (inclusive)
*
* Walk the list of under-writeback pages of the given address space
* in the given range and wait for all of them.
*
* This is just a simple wrapper so that callers don't have to convert offsets
* to page indexes themselves
*/
int filemap_fdatawait_range(struct address_space *mapping, loff_t start,
loff_t end)
{
return wait_on_page_writeback_range(mapping, start >> PAGE_CACHE_SHIFT,
end >> PAGE_CACHE_SHIFT);
}
EXPORT_SYMBOL(filemap_fdatawait_range);

/**
* sync_page_range - write and wait on all pages in the passed range
* @inode: target inode
Expand Down

0 comments on commit d3bccb6

Please sign in to comment.