Skip to content

Commit 1e4a295

Browse files
author
Gao Xiang
committed
erofs: clean up z_erofs_submit_queue()
A label and extra variables will be eliminated, which is more cleaner. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent 587a67b commit 1e4a295

File tree

1 file changed

+40
-55
lines changed

1 file changed

+40
-55
lines changed

fs/erofs/zdata.c

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
11481148
qtail[JQ_BYPASS] = &pcl->next;
11491149
}
11501150

1151-
static bool z_erofs_submit_queue(struct super_block *sb,
1151+
static void z_erofs_submit_queue(struct super_block *sb,
11521152
z_erofs_next_pcluster_t owned_head,
11531153
struct list_head *pagepool,
11541154
struct z_erofs_decompressqueue *fgq,
@@ -1157,19 +1157,12 @@ static bool z_erofs_submit_queue(struct super_block *sb,
11571157
struct erofs_sb_info *const sbi = EROFS_SB(sb);
11581158
z_erofs_next_pcluster_t qtail[NR_JOBQUEUES];
11591159
struct z_erofs_decompressqueue *q[NR_JOBQUEUES];
1160-
struct bio *bio;
11611160
void *bi_private;
11621161
/* since bio will be NULL, no need to initialize last_index */
11631162
pgoff_t uninitialized_var(last_index);
1164-
bool force_submit = false;
1165-
unsigned int nr_bios;
1163+
unsigned int nr_bios = 0;
1164+
struct bio *bio = NULL;
11661165

1167-
if (owned_head == Z_EROFS_PCLUSTER_TAIL)
1168-
return false;
1169-
1170-
force_submit = false;
1171-
bio = NULL;
1172-
nr_bios = 0;
11731166
bi_private = jobqueueset_init(sb, q, fgq, force_fg);
11741167
qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head;
11751168
qtail[JQ_SUBMIT] = &q[JQ_SUBMIT]->head;
@@ -1179,67 +1172,60 @@ static bool z_erofs_submit_queue(struct super_block *sb,
11791172

11801173
do {
11811174
struct z_erofs_pcluster *pcl;
1182-
unsigned int clusterpages;
1183-
pgoff_t first_index;
1184-
struct page *page;
1185-
unsigned int i = 0, bypass = 0;
1186-
int err;
1175+
pgoff_t cur, end;
1176+
unsigned int i = 0;
1177+
bool bypass = true;
11871178

11881179
/* no possible 'owned_head' equals the following */
11891180
DBG_BUGON(owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED);
11901181
DBG_BUGON(owned_head == Z_EROFS_PCLUSTER_NIL);
11911182

11921183
pcl = container_of(owned_head, struct z_erofs_pcluster, next);
11931184

1194-
clusterpages = BIT(pcl->clusterbits);
1185+
cur = pcl->obj.index;
1186+
end = cur + BIT(pcl->clusterbits);
11951187

11961188
/* close the main owned chain at first */
11971189
owned_head = cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_TAIL,
11981190
Z_EROFS_PCLUSTER_TAIL_CLOSED);
11991191

1200-
first_index = pcl->obj.index;
1201-
force_submit |= (first_index != last_index + 1);
1192+
do {
1193+
struct page *page;
1194+
int err;
12021195

1203-
repeat:
1204-
page = pickup_page_for_submission(pcl, i, pagepool,
1205-
MNGD_MAPPING(sbi),
1206-
GFP_NOFS);
1207-
if (!page) {
1208-
force_submit = true;
1209-
++bypass;
1210-
goto skippage;
1211-
}
1196+
page = pickup_page_for_submission(pcl, i++, pagepool,
1197+
MNGD_MAPPING(sbi),
1198+
GFP_NOFS);
1199+
if (!page)
1200+
continue;
12121201

1213-
if (bio && force_submit) {
1202+
if (bio && cur != last_index + 1) {
12141203
submit_bio_retry:
1215-
submit_bio(bio);
1216-
bio = NULL;
1217-
}
1218-
1219-
if (!bio) {
1220-
bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
1204+
submit_bio(bio);
1205+
bio = NULL;
1206+
}
12211207

1222-
bio->bi_end_io = z_erofs_decompressqueue_endio;
1223-
bio_set_dev(bio, sb->s_bdev);
1224-
bio->bi_iter.bi_sector = (sector_t)(first_index + i) <<
1225-
LOG_SECTORS_PER_BLOCK;
1226-
bio->bi_private = bi_private;
1227-
bio->bi_opf = REQ_OP_READ;
1208+
if (!bio) {
1209+
bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
12281210

1229-
++nr_bios;
1230-
}
1211+
bio->bi_end_io = z_erofs_decompressqueue_endio;
1212+
bio_set_dev(bio, sb->s_bdev);
1213+
bio->bi_iter.bi_sector = (sector_t)cur <<
1214+
LOG_SECTORS_PER_BLOCK;
1215+
bio->bi_private = bi_private;
1216+
bio->bi_opf = REQ_OP_READ;
1217+
++nr_bios;
1218+
}
12311219

1232-
err = bio_add_page(bio, page, PAGE_SIZE, 0);
1233-
if (err < PAGE_SIZE)
1234-
goto submit_bio_retry;
1220+
err = bio_add_page(bio, page, PAGE_SIZE, 0);
1221+
if (err < PAGE_SIZE)
1222+
goto submit_bio_retry;
12351223

1236-
force_submit = false;
1237-
last_index = first_index + i;
1238-
skippage:
1239-
if (++i < clusterpages)
1240-
goto repeat;
1224+
last_index = cur;
1225+
bypass = false;
1226+
} while (++cur < end);
12411227

1242-
if (bypass < clusterpages)
1228+
if (!bypass)
12431229
qtail[JQ_SUBMIT] = &pcl->next;
12441230
else
12451231
move_to_bypass_jobqueue(pcl, qtail, owned_head);
@@ -1254,10 +1240,9 @@ static bool z_erofs_submit_queue(struct super_block *sb,
12541240
*/
12551241
if (!*force_fg && !nr_bios) {
12561242
kvfree(q[JQ_SUBMIT]);
1257-
return true;
1243+
return;
12581244
}
12591245
z_erofs_decompress_kickoff(q[JQ_SUBMIT], *force_fg, nr_bios);
1260-
return true;
12611246
}
12621247

12631248
static void z_erofs_runqueue(struct super_block *sb,
@@ -1266,9 +1251,9 @@ static void z_erofs_runqueue(struct super_block *sb,
12661251
{
12671252
struct z_erofs_decompressqueue io[NR_JOBQUEUES];
12681253

1269-
if (!z_erofs_submit_queue(sb, clt->owned_head,
1270-
pagepool, io, &force_fg))
1254+
if (clt->owned_head == Z_EROFS_PCLUSTER_TAIL)
12711255
return;
1256+
z_erofs_submit_queue(sb, clt->owned_head, pagepool, io, &force_fg);
12721257

12731258
/* handle bypass queue (no i/o pclusters) immediately */
12741259
z_erofs_decompress_queue(&io[JQ_BYPASS], pagepool);

0 commit comments

Comments
 (0)