Skip to content

Commit cfae383

Browse files
committed
Revert "Squashfs: optimize reading uncompressed data"
This reverts commit 0c2f831. Change-Id: Iaf0c9182c682e4c92e78abeb283c96b30c756d21 Reviewed-on: https://tp-biosrd-v02/gerrit/81524 Reviewed-by: Alex Cheng(鄭富元) <Alex_Cheng@asus.com> Tested-by: Alex Cheng(鄭富元) <Alex_Cheng@asus.com>
1 parent d825a0a commit cfae383

File tree

2 files changed

+7
-55
lines changed

2 files changed

+7
-55
lines changed

fs/squashfs/block.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,6 @@ static void squashfs_bio_end_io(struct bio *bio)
206206
kfree(bio_req);
207207
}
208208

209-
static int bh_is_optional(struct squashfs_read_request *req, int idx)
210-
{
211-
int start_idx, end_idx;
212-
struct squashfs_sb_info *msblk = req->sb->s_fs_info;
213-
214-
start_idx = (idx * msblk->devblksize - req->offset) / PAGE_CACHE_SIZE;
215-
end_idx = ((idx + 1) * msblk->devblksize - req->offset + 1) / PAGE_CACHE_SIZE;
216-
if (start_idx >= req->output->pages)
217-
return 1;
218-
if (start_idx < 0)
219-
start_idx = end_idx;
220-
if (end_idx >= req->output->pages)
221-
end_idx = start_idx;
222-
return !req->output->page[start_idx] && !req->output->page[end_idx];
223-
}
224-
225209
static int actor_getblks(struct squashfs_read_request *req, u64 block)
226210
{
227211
int i;
@@ -231,15 +215,6 @@ static int actor_getblks(struct squashfs_read_request *req, u64 block)
231215
return -ENOMEM;
232216

233217
for (i = 0; i < req->nr_buffers; ++i) {
234-
/*
235-
* When dealing with an uncompressed block, the actor may
236-
* contains NULL pages. There's no need to read the buffers
237-
* associated with these pages.
238-
*/
239-
if (!req->compressed && bh_is_optional(req, i)) {
240-
req->bh[i] = NULL;
241-
continue;
242-
}
243218
req->bh[i] = sb_getblk(req->sb, block + i);
244219
if (!req->bh[i]) {
245220
while (--i) {

fs/squashfs/file_direct.c

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -114,38 +114,15 @@ int squashfs_readpages_block(struct page *target_page,
114114
struct squashfs_page_actor *actor;
115115
struct inode *inode = mapping->host;
116116
struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
117-
int start_index, end_index, file_end, actor_pages, res;
117+
int file_end = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
118118
int mask = (1 << (msblk->block_log - PAGE_CACHE_SHIFT)) - 1;
119+
int start_index = page_index & ~mask;
120+
int end_index = start_index | mask;
121+
int actor_pages, res;
119122

120-
/*
121-
* If readpage() is called on an uncompressed datablock, we can just
122-
* read the pages instead of fetching the whole block.
123-
* This greatly improves the performance when a process keep doing
124-
* random reads because we only fetch the necessary data.
125-
* The readahead algorithm will take care of doing speculative reads
126-
* if necessary.
127-
* We can't read more than 1 block even if readahead provides use more
128-
* pages because we don't know yet if the next block is compressed or
129-
* not.
130-
*/
131-
if (bsize && !SQUASHFS_COMPRESSED_BLOCK(bsize)) {
132-
u64 block_end = block + msblk->block_size;
133-
134-
block += (page_index & mask) * PAGE_CACHE_SIZE;
135-
actor_pages = (block_end - block) / PAGE_CACHE_SIZE;
136-
if (*nr_pages < actor_pages)
137-
actor_pages = *nr_pages;
138-
start_index = page_index;
139-
bsize = min_t(int, bsize, (PAGE_CACHE_SIZE * actor_pages)
140-
| SQUASHFS_COMPRESSED_BIT_BLOCK);
141-
} else {
142-
file_end = (i_size_read(inode) - 1) >> PAGE_CACHE_SHIFT;
143-
start_index = page_index & ~mask;
144-
end_index = start_index | mask;
145-
if (end_index > file_end)
146-
end_index = file_end;
147-
actor_pages = end_index - start_index + 1;
148-
}
123+
if (end_index > file_end)
124+
end_index = file_end;
125+
actor_pages = end_index - start_index + 1;
149126

150127
actor = actor_from_page_cache(actor_pages, target_page,
151128
readahead_pages, nr_pages, start_index,

0 commit comments

Comments
 (0)