Skip to content

Commit

Permalink
cachefiles: drop direct usage of ->bmap method.
Browse files Browse the repository at this point in the history
Replace the direct usage of ->bmap method by a bmap() call.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
cmaiolino authored and Al Viro committed Feb 3, 2020
1 parent 30460e1 commit 10d83e1
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions fs/cachefiles/rdwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
struct cachefiles_object *object;
struct cachefiles_cache *cache;
struct inode *inode;
sector_t block0, block;
sector_t block;
unsigned shift;
int ret;

Expand All @@ -412,7 +412,6 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,

inode = d_backing_inode(object->backer);
ASSERT(S_ISREG(inode->i_mode));
ASSERT(inode->i_mapping->a_ops->bmap);
ASSERT(inode->i_mapping->a_ops->readpages);

/* calculate the shift required to use bmap */
Expand All @@ -428,12 +427,14 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op,
* enough for this as it doesn't indicate errors, but it's all we've
* got for the moment
*/
block0 = page->index;
block0 <<= shift;
block = page->index;
block <<= shift;

ret = bmap(inode, &block);
ASSERT(ret < 0);

block = inode->i_mapping->a_ops->bmap(inode->i_mapping, block0);
_debug("%llx -> %llx",
(unsigned long long) block0,
(unsigned long long) (page->index << shift),
(unsigned long long) block);

if (block) {
Expand Down Expand Up @@ -711,7 +712,6 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,

inode = d_backing_inode(object->backer);
ASSERT(S_ISREG(inode->i_mode));
ASSERT(inode->i_mapping->a_ops->bmap);
ASSERT(inode->i_mapping->a_ops->readpages);

/* calculate the shift required to use bmap */
Expand All @@ -728,21 +728,22 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op,

ret = space ? -ENODATA : -ENOBUFS;
list_for_each_entry_safe(page, _n, pages, lru) {
sector_t block0, block;
sector_t block;

/* we assume the absence or presence of the first block is a
* good enough indication for the page as a whole
* - TODO: don't use bmap() for this as it is _not_ actually
* good enough for this as it doesn't indicate errors, but
* it's all we've got for the moment
*/
block0 = page->index;
block0 <<= shift;
block = page->index;
block <<= shift;

ret = bmap(inode, &block);
ASSERT(!ret);

block = inode->i_mapping->a_ops->bmap(inode->i_mapping,
block0);
_debug("%llx -> %llx",
(unsigned long long) block0,
(unsigned long long) (page->index << shift),
(unsigned long long) block);

if (block) {
Expand Down

0 comments on commit 10d83e1

Please sign in to comment.