@@ -1148,7 +1148,7 @@ static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
1148
1148
qtail [JQ_BYPASS ] = & pcl -> next ;
1149
1149
}
1150
1150
1151
- static bool z_erofs_submit_queue (struct super_block * sb ,
1151
+ static void z_erofs_submit_queue (struct super_block * sb ,
1152
1152
z_erofs_next_pcluster_t owned_head ,
1153
1153
struct list_head * pagepool ,
1154
1154
struct z_erofs_decompressqueue * fgq ,
@@ -1157,19 +1157,12 @@ static bool z_erofs_submit_queue(struct super_block *sb,
1157
1157
struct erofs_sb_info * const sbi = EROFS_SB (sb );
1158
1158
z_erofs_next_pcluster_t qtail [NR_JOBQUEUES ];
1159
1159
struct z_erofs_decompressqueue * q [NR_JOBQUEUES ];
1160
- struct bio * bio ;
1161
1160
void * bi_private ;
1162
1161
/* since bio will be NULL, no need to initialize last_index */
1163
1162
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 ;
1166
1165
1167
- if (owned_head == Z_EROFS_PCLUSTER_TAIL )
1168
- return false;
1169
-
1170
- force_submit = false;
1171
- bio = NULL ;
1172
- nr_bios = 0 ;
1173
1166
bi_private = jobqueueset_init (sb , q , fgq , force_fg );
1174
1167
qtail [JQ_BYPASS ] = & q [JQ_BYPASS ]-> head ;
1175
1168
qtail [JQ_SUBMIT ] = & q [JQ_SUBMIT ]-> head ;
@@ -1179,67 +1172,60 @@ static bool z_erofs_submit_queue(struct super_block *sb,
1179
1172
1180
1173
do {
1181
1174
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;
1187
1178
1188
1179
/* no possible 'owned_head' equals the following */
1189
1180
DBG_BUGON (owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED );
1190
1181
DBG_BUGON (owned_head == Z_EROFS_PCLUSTER_NIL );
1191
1182
1192
1183
pcl = container_of (owned_head , struct z_erofs_pcluster , next );
1193
1184
1194
- clusterpages = BIT (pcl -> clusterbits );
1185
+ cur = pcl -> obj .index ;
1186
+ end = cur + BIT (pcl -> clusterbits );
1195
1187
1196
1188
/* close the main owned chain at first */
1197
1189
owned_head = cmpxchg (& pcl -> next , Z_EROFS_PCLUSTER_TAIL ,
1198
1190
Z_EROFS_PCLUSTER_TAIL_CLOSED );
1199
1191
1200
- first_index = pcl -> obj .index ;
1201
- force_submit |= (first_index != last_index + 1 );
1192
+ do {
1193
+ struct page * page ;
1194
+ int err ;
1202
1195
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 ;
1212
1201
1213
- if (bio && force_submit ) {
1202
+ if (bio && cur != last_index + 1 ) {
1214
1203
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
+ }
1221
1207
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 );
1228
1210
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
+ }
1231
1219
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 ;
1235
1223
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 );
1241
1227
1242
- if (bypass < clusterpages )
1228
+ if (! bypass )
1243
1229
qtail [JQ_SUBMIT ] = & pcl -> next ;
1244
1230
else
1245
1231
move_to_bypass_jobqueue (pcl , qtail , owned_head );
@@ -1254,10 +1240,9 @@ static bool z_erofs_submit_queue(struct super_block *sb,
1254
1240
*/
1255
1241
if (!* force_fg && !nr_bios ) {
1256
1242
kvfree (q [JQ_SUBMIT ]);
1257
- return true ;
1243
+ return ;
1258
1244
}
1259
1245
z_erofs_decompress_kickoff (q [JQ_SUBMIT ], * force_fg , nr_bios );
1260
- return true;
1261
1246
}
1262
1247
1263
1248
static void z_erofs_runqueue (struct super_block * sb ,
@@ -1266,9 +1251,9 @@ static void z_erofs_runqueue(struct super_block *sb,
1266
1251
{
1267
1252
struct z_erofs_decompressqueue io [NR_JOBQUEUES ];
1268
1253
1269
- if (!z_erofs_submit_queue (sb , clt -> owned_head ,
1270
- pagepool , io , & force_fg ))
1254
+ if (clt -> owned_head == Z_EROFS_PCLUSTER_TAIL )
1271
1255
return ;
1256
+ z_erofs_submit_queue (sb , clt -> owned_head , pagepool , io , & force_fg );
1272
1257
1273
1258
/* handle bypass queue (no i/o pclusters) immediately */
1274
1259
z_erofs_decompress_queue (& io [JQ_BYPASS ], pagepool );
0 commit comments