Commit fbc27241 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

squashfs: use bvec_virt

Use bvec_virt instead of open coding it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210804095634.460779-7-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 964cacfd
...@@ -49,8 +49,7 @@ static int copy_bio_to_actor(struct bio *bio, ...@@ -49,8 +49,7 @@ static int copy_bio_to_actor(struct bio *bio,
bytes_to_copy = min_t(int, bytes_to_copy, bytes_to_copy = min_t(int, bytes_to_copy,
req_length - copied_bytes); req_length - copied_bytes);
memcpy(actor_addr + actor_offset, memcpy(actor_addr + actor_offset, bvec_virt(bvec) + offset,
page_address(bvec->bv_page) + bvec->bv_offset + offset,
bytes_to_copy); bytes_to_copy);
actor_offset += bytes_to_copy; actor_offset += bytes_to_copy;
...@@ -177,7 +176,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length, ...@@ -177,7 +176,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
goto out_free_bio; goto out_free_bio;
} }
/* Extract the length of the metadata block */ /* Extract the length of the metadata block */
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
length = data[offset]; length = data[offset];
if (offset < bvec->bv_len - 1) { if (offset < bvec->bv_len - 1) {
length |= data[offset + 1] << 8; length |= data[offset + 1] << 8;
...@@ -186,7 +185,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length, ...@@ -186,7 +185,7 @@ int squashfs_read_data(struct super_block *sb, u64 index, int length,
res = -EIO; res = -EIO;
goto out_free_bio; goto out_free_bio;
} }
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
length |= data[0] << 8; length |= data[0] << 8;
} }
bio_free_pages(bio); bio_free_pages(bio);
......
...@@ -101,7 +101,7 @@ static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm, ...@@ -101,7 +101,7 @@ static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm,
while (bio_next_segment(bio, &iter_all)) { while (bio_next_segment(bio, &iter_all)) {
int avail = min(bytes, ((int)bvec->bv_len) - offset); int avail = min(bytes, ((int)bvec->bv_len) - offset);
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
memcpy(buff, data + offset, avail); memcpy(buff, data + offset, avail);
buff += avail; buff += avail;
bytes -= avail; bytes -= avail;
......
...@@ -76,7 +76,7 @@ static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm, ...@@ -76,7 +76,7 @@ static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm,
while (bio_next_segment(bio, &iter_all)) { while (bio_next_segment(bio, &iter_all)) {
int avail = min(bytes, ((int)bvec->bv_len) - offset); int avail = min(bytes, ((int)bvec->bv_len) - offset);
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
memcpy(buff, data + offset, avail); memcpy(buff, data + offset, avail);
buff += avail; buff += avail;
bytes -= avail; bytes -= avail;
......
...@@ -146,7 +146,7 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void *strm, ...@@ -146,7 +146,7 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void *strm,
} }
avail = min(length, ((int)bvec->bv_len) - offset); avail = min(length, ((int)bvec->bv_len) - offset);
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
length -= avail; length -= avail;
stream->buf.in = data + offset; stream->buf.in = data + offset;
stream->buf.in_size = avail; stream->buf.in_size = avail;
......
...@@ -76,7 +76,7 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm, ...@@ -76,7 +76,7 @@ static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm,
} }
avail = min(length, ((int)bvec->bv_len) - offset); avail = min(length, ((int)bvec->bv_len) - offset);
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
length -= avail; length -= avail;
stream->next_in = data + offset; stream->next_in = data + offset;
stream->avail_in = avail; stream->avail_in = avail;
......
...@@ -94,7 +94,7 @@ static int zstd_uncompress(struct squashfs_sb_info *msblk, void *strm, ...@@ -94,7 +94,7 @@ static int zstd_uncompress(struct squashfs_sb_info *msblk, void *strm,
} }
avail = min(length, ((int)bvec->bv_len) - offset); avail = min(length, ((int)bvec->bv_len) - offset);
data = page_address(bvec->bv_page) + bvec->bv_offset; data = bvec_virt(bvec);
length -= avail; length -= avail;
in_buf.src = data + offset; in_buf.src = data + offset;
in_buf.size = avail; in_buf.size = avail;
......
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