iomap: add a iomap_sector helper
Factor the repeated calculation of the on-disk sector for a given logical block into a littler helper. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
6533b4e40d
commit
57fc505d11
19
fs/iomap.c
19
fs/iomap.c
|
@ -96,6 +96,12 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags,
|
||||||
return written ? written : ret;
|
return written ? written : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sector_t
|
||||||
|
iomap_sector(struct iomap *iomap, loff_t pos)
|
||||||
|
{
|
||||||
|
return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
|
iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
|
||||||
{
|
{
|
||||||
|
@ -353,11 +359,8 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,
|
||||||
static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes,
|
static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes,
|
||||||
struct iomap *iomap)
|
struct iomap *iomap)
|
||||||
{
|
{
|
||||||
sector_t sector = (iomap->addr +
|
return __dax_zero_page_range(iomap->bdev, iomap->dax_dev,
|
||||||
(pos & PAGE_MASK) - iomap->offset) >> 9;
|
iomap_sector(iomap, pos & PAGE_MASK), offset, bytes);
|
||||||
|
|
||||||
return __dax_zero_page_range(iomap->bdev, iomap->dax_dev, sector,
|
|
||||||
offset, bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static loff_t
|
static loff_t
|
||||||
|
@ -839,8 +842,7 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
|
||||||
|
|
||||||
bio = bio_alloc(GFP_KERNEL, 1);
|
bio = bio_alloc(GFP_KERNEL, 1);
|
||||||
bio_set_dev(bio, iomap->bdev);
|
bio_set_dev(bio, iomap->bdev);
|
||||||
bio->bi_iter.bi_sector =
|
bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
|
||||||
(iomap->addr + pos - iomap->offset) >> 9;
|
|
||||||
bio->bi_private = dio;
|
bio->bi_private = dio;
|
||||||
bio->bi_end_io = iomap_dio_bio_end_io;
|
bio->bi_end_io = iomap_dio_bio_end_io;
|
||||||
|
|
||||||
|
@ -934,8 +936,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
|
||||||
|
|
||||||
bio = bio_alloc(GFP_KERNEL, nr_pages);
|
bio = bio_alloc(GFP_KERNEL, nr_pages);
|
||||||
bio_set_dev(bio, iomap->bdev);
|
bio_set_dev(bio, iomap->bdev);
|
||||||
bio->bi_iter.bi_sector =
|
bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
|
||||||
(iomap->addr + pos - iomap->offset) >> 9;
|
|
||||||
bio->bi_write_hint = dio->iocb->ki_hint;
|
bio->bi_write_hint = dio->iocb->ki_hint;
|
||||||
bio->bi_private = dio;
|
bio->bi_private = dio;
|
||||||
bio->bi_end_io = iomap_dio_bio_end_io;
|
bio->bi_end_io = iomap_dio_bio_end_io;
|
||||||
|
|
Loading…
Reference in New Issue