Commit fad0a1ab authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

iomap: constify iomap_iter_srcmap

The srcmap returned from iomap_iter_srcmap is never modified, so mark
the iomap returned from it const and constify a lot of code that never
modifies the iomap.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent 65dd814a
...@@ -205,10 +205,10 @@ struct iomap_readpage_ctx { ...@@ -205,10 +205,10 @@ struct iomap_readpage_ctx {
struct readahead_control *rac; struct readahead_control *rac;
}; };
static loff_t iomap_read_inline_data(struct iomap_iter *iter, static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
struct page *page) struct page *page)
{ {
struct iomap *iomap = iomap_iter_srcmap(iter); const struct iomap *iomap = iomap_iter_srcmap(iter);
size_t size = i_size_read(iter->inode) - iomap->offset; size_t size = i_size_read(iter->inode) - iomap->offset;
size_t poff = offset_in_page(iomap->offset); size_t poff = offset_in_page(iomap->offset);
void *addr; void *addr;
...@@ -234,20 +234,20 @@ static loff_t iomap_read_inline_data(struct iomap_iter *iter, ...@@ -234,20 +234,20 @@ static loff_t iomap_read_inline_data(struct iomap_iter *iter,
return PAGE_SIZE - poff; return PAGE_SIZE - poff;
} }
static inline bool iomap_block_needs_zeroing(struct iomap_iter *iter, static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter,
loff_t pos) loff_t pos)
{ {
struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
return srcmap->type != IOMAP_MAPPED || return srcmap->type != IOMAP_MAPPED ||
(srcmap->flags & IOMAP_F_NEW) || (srcmap->flags & IOMAP_F_NEW) ||
pos >= i_size_read(iter->inode); pos >= i_size_read(iter->inode);
} }
static loff_t iomap_readpage_iter(struct iomap_iter *iter, static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
struct iomap_readpage_ctx *ctx, loff_t offset) struct iomap_readpage_ctx *ctx, loff_t offset)
{ {
struct iomap *iomap = &iter->iomap; const struct iomap *iomap = &iter->iomap;
loff_t pos = iter->pos + offset; loff_t pos = iter->pos + offset;
loff_t length = iomap_length(iter) - offset; loff_t length = iomap_length(iter) - offset;
struct page *page = ctx->cur_page; struct page *page = ctx->cur_page;
...@@ -352,7 +352,7 @@ iomap_readpage(struct page *page, const struct iomap_ops *ops) ...@@ -352,7 +352,7 @@ iomap_readpage(struct page *page, const struct iomap_ops *ops)
} }
EXPORT_SYMBOL_GPL(iomap_readpage); EXPORT_SYMBOL_GPL(iomap_readpage);
static loff_t iomap_readahead_iter(struct iomap_iter *iter, static loff_t iomap_readahead_iter(const struct iomap_iter *iter,
struct iomap_readpage_ctx *ctx) struct iomap_readpage_ctx *ctx)
{ {
loff_t length = iomap_length(iter); loff_t length = iomap_length(iter);
...@@ -536,10 +536,10 @@ iomap_read_page_sync(loff_t block_start, struct page *page, unsigned poff, ...@@ -536,10 +536,10 @@ iomap_read_page_sync(loff_t block_start, struct page *page, unsigned poff,
return submit_bio_wait(&bio); return submit_bio_wait(&bio);
} }
static int __iomap_write_begin(struct iomap_iter *iter, loff_t pos, static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
unsigned len, struct page *page) unsigned len, struct page *page)
{ {
struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
struct iomap_page *iop = iomap_page_create(iter->inode, page); struct iomap_page *iop = iomap_page_create(iter->inode, page);
loff_t block_size = i_blocksize(iter->inode); loff_t block_size = i_blocksize(iter->inode);
loff_t block_start = round_down(pos, block_size); loff_t block_start = round_down(pos, block_size);
...@@ -577,7 +577,7 @@ static int __iomap_write_begin(struct iomap_iter *iter, loff_t pos, ...@@ -577,7 +577,7 @@ static int __iomap_write_begin(struct iomap_iter *iter, loff_t pos,
return 0; return 0;
} }
static int iomap_write_begin_inline(struct iomap_iter *iter, static int iomap_write_begin_inline(const struct iomap_iter *iter,
struct page *page) struct page *page)
{ {
int ret; int ret;
...@@ -591,11 +591,11 @@ static int iomap_write_begin_inline(struct iomap_iter *iter, ...@@ -591,11 +591,11 @@ static int iomap_write_begin_inline(struct iomap_iter *iter,
return 0; return 0;
} }
static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, unsigned len, static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
struct page **pagep) unsigned len, struct page **pagep)
{ {
const struct iomap_page_ops *page_ops = iter->iomap.page_ops; const struct iomap_page_ops *page_ops = iter->iomap.page_ops;
struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
struct page *page; struct page *page;
int status = 0; int status = 0;
...@@ -666,10 +666,10 @@ static size_t __iomap_write_end(struct inode *inode, loff_t pos, size_t len, ...@@ -666,10 +666,10 @@ static size_t __iomap_write_end(struct inode *inode, loff_t pos, size_t len,
return copied; return copied;
} }
static size_t iomap_write_end_inline(struct iomap_iter *iter, struct page *page, static size_t iomap_write_end_inline(const struct iomap_iter *iter,
loff_t pos, size_t copied) struct page *page, loff_t pos, size_t copied)
{ {
struct iomap *iomap = &iter->iomap; const struct iomap *iomap = &iter->iomap;
void *addr; void *addr;
WARN_ON_ONCE(!PageUptodate(page)); WARN_ON_ONCE(!PageUptodate(page));
...@@ -689,7 +689,7 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, ...@@ -689,7 +689,7 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len,
size_t copied, struct page *page) size_t copied, struct page *page)
{ {
const struct iomap_page_ops *page_ops = iter->iomap.page_ops; const struct iomap_page_ops *page_ops = iter->iomap.page_ops;
struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
loff_t old_size = iter->inode->i_size; loff_t old_size = iter->inode->i_size;
size_t ret; size_t ret;
...@@ -814,7 +814,7 @@ EXPORT_SYMBOL_GPL(iomap_file_buffered_write); ...@@ -814,7 +814,7 @@ EXPORT_SYMBOL_GPL(iomap_file_buffered_write);
static loff_t iomap_unshare_iter(struct iomap_iter *iter) static loff_t iomap_unshare_iter(struct iomap_iter *iter)
{ {
struct iomap *iomap = &iter->iomap; struct iomap *iomap = &iter->iomap;
struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
loff_t pos = iter->pos; loff_t pos = iter->pos;
loff_t length = iomap_length(iter); loff_t length = iomap_length(iter);
long status = 0; long status = 0;
...@@ -890,7 +890,7 @@ static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length) ...@@ -890,7 +890,7 @@ static s64 __iomap_zero_iter(struct iomap_iter *iter, loff_t pos, u64 length)
static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero) static loff_t iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
{ {
struct iomap *iomap = &iter->iomap; struct iomap *iomap = &iter->iomap;
struct iomap *srcmap = iomap_iter_srcmap(iter); const struct iomap *srcmap = iomap_iter_srcmap(iter);
loff_t pos = iter->pos; loff_t pos = iter->pos;
loff_t length = iomap_length(iter); loff_t length = iomap_length(iter);
loff_t written = 0; loff_t written = 0;
......
...@@ -211,7 +211,7 @@ static inline u64 iomap_length(const struct iomap_iter *iter) ...@@ -211,7 +211,7 @@ static inline u64 iomap_length(const struct iomap_iter *iter)
* for a given operation, which may or may no be identical to the destination * for a given operation, which may or may no be identical to the destination
* map in &i->iomap. * map in &i->iomap.
*/ */
static inline struct iomap *iomap_iter_srcmap(struct iomap_iter *i) static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i)
{ {
if (i->srcmap.type != IOMAP_HOLE) if (i->srcmap.type != IOMAP_HOLE)
return &i->srcmap; return &i->srcmap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment