@@ -116,43 +116,56 @@ struct bio_post_read_ctx {
116
116
struct f2fs_sb_info * sbi ;
117
117
struct work_struct work ;
118
118
unsigned int enabled_steps ;
119
+ /*
120
+ * decompression_attempted keeps track of whether
121
+ * f2fs_end_read_compressed_page() has been called on the pages in the
122
+ * bio that belong to a compressed cluster yet.
123
+ */
124
+ bool decompression_attempted ;
119
125
block_t fs_blkaddr ;
120
126
};
121
127
128
+ /*
129
+ * Update and unlock a bio's pages, and free the bio.
130
+ *
131
+ * This marks pages up-to-date only if there was no error in the bio (I/O error,
132
+ * decryption error, or verity error), as indicated by bio->bi_status.
133
+ *
134
+ * "Compressed pages" (pagecache pages backed by a compressed cluster on-disk)
135
+ * aren't marked up-to-date here, as decompression is done on a per-compression-
136
+ * cluster basis rather than a per-bio basis. Instead, we only must do two
137
+ * things for each compressed page here: call f2fs_end_read_compressed_page()
138
+ * with failed=true if an error occurred before it would have normally gotten
139
+ * called (i.e., I/O error or decryption error, but *not* verity error), and
140
+ * release the bio's reference to the decompress_io_ctx of the page's cluster.
141
+ */
122
142
static void f2fs_finish_read_bio (struct bio * bio , bool in_task )
123
143
{
124
144
struct bio_vec * bv ;
125
145
struct bvec_iter_all iter_all ;
146
+ struct bio_post_read_ctx * ctx = bio -> bi_private ;
126
147
127
- /*
128
- * Update and unlock the bio's pagecache pages, and put the
129
- * decompression context for any compressed pages.
130
- */
131
148
bio_for_each_segment_all (bv , bio , iter_all ) {
132
149
struct page * page = bv -> bv_page ;
133
150
134
151
if (f2fs_is_compressed_page (page )) {
135
- if (bio -> bi_status )
152
+ if (ctx && ! ctx -> decompression_attempted )
136
153
f2fs_end_read_compressed_page (page , true, 0 ,
137
154
in_task );
138
155
f2fs_put_page_dic (page , in_task );
139
156
continue ;
140
157
}
141
158
142
- /* PG_error was set if verity failed. */
143
- if (bio -> bi_status || PageError (page )) {
159
+ if (bio -> bi_status )
144
160
ClearPageUptodate (page );
145
- /* will re-read again later */
146
- ClearPageError (page );
147
- } else {
161
+ else
148
162
SetPageUptodate (page );
149
- }
150
163
dec_page_count (F2FS_P_SB (page ), __read_io_type (page ));
151
164
unlock_page (page );
152
165
}
153
166
154
- if (bio -> bi_private )
155
- mempool_free (bio -> bi_private , bio_post_read_ctx_pool );
167
+ if (ctx )
168
+ mempool_free (ctx , bio_post_read_ctx_pool );
156
169
bio_put (bio );
157
170
}
158
171
@@ -185,8 +198,10 @@ static void f2fs_verify_bio(struct work_struct *work)
185
198
struct page * page = bv -> bv_page ;
186
199
187
200
if (!f2fs_is_compressed_page (page ) &&
188
- !fsverity_verify_page (page ))
189
- SetPageError (page );
201
+ !fsverity_verify_page (page )) {
202
+ bio -> bi_status = BLK_STS_IOERR ;
203
+ break ;
204
+ }
190
205
}
191
206
} else {
192
207
fsverity_verify_bio (bio );
@@ -245,6 +260,8 @@ static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx,
245
260
blkaddr ++ ;
246
261
}
247
262
263
+ ctx -> decompression_attempted = true;
264
+
248
265
/*
249
266
* Optimization: if all the bio's pages are compressed, then scheduling
250
267
* the per-bio verity work is unnecessary, as verity will be fully
@@ -1062,6 +1079,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
1062
1079
ctx -> sbi = sbi ;
1063
1080
ctx -> enabled_steps = post_read_steps ;
1064
1081
ctx -> fs_blkaddr = blkaddr ;
1082
+ ctx -> decompression_attempted = false;
1065
1083
bio -> bi_private = ctx ;
1066
1084
}
1067
1085
iostat_alloc_and_bind_ctx (sbi , bio , ctx );
@@ -1089,7 +1107,6 @@ static int f2fs_submit_page_read(struct inode *inode, struct page *page,
1089
1107
bio_put (bio );
1090
1108
return - EFAULT ;
1091
1109
}
1092
- ClearPageError (page );
1093
1110
inc_page_count (sbi , F2FS_RD_DATA );
1094
1111
f2fs_update_iostat (sbi , NULL , FS_DATA_READ_IO , F2FS_BLKSIZE );
1095
1112
__submit_bio (sbi , bio , DATA );
@@ -2141,7 +2158,6 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page,
2141
2158
inc_page_count (F2FS_I_SB (inode ), F2FS_RD_DATA );
2142
2159
f2fs_update_iostat (F2FS_I_SB (inode ), NULL , FS_DATA_READ_IO ,
2143
2160
F2FS_BLKSIZE );
2144
- ClearPageError (page );
2145
2161
* last_block_in_bio = block_nr ;
2146
2162
goto out ;
2147
2163
out :
@@ -2289,7 +2305,6 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
2289
2305
2290
2306
inc_page_count (sbi , F2FS_RD_DATA );
2291
2307
f2fs_update_iostat (sbi , inode , FS_DATA_READ_IO , F2FS_BLKSIZE );
2292
- ClearPageError (page );
2293
2308
* last_block_in_bio = blkaddr ;
2294
2309
}
2295
2310
@@ -2306,7 +2321,6 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
2306
2321
for (i = 0 ; i < cc -> cluster_size ; i ++ ) {
2307
2322
if (cc -> rpages [i ]) {
2308
2323
ClearPageUptodate (cc -> rpages [i ]);
2309
- ClearPageError (cc -> rpages [i ]);
2310
2324
unlock_page (cc -> rpages [i ]);
2311
2325
}
2312
2326
}
@@ -2403,7 +2417,6 @@ static int f2fs_mpage_readpages(struct inode *inode,
2403
2417
#ifdef CONFIG_F2FS_FS_COMPRESSION
2404
2418
set_error_page :
2405
2419
#endif
2406
- SetPageError (page );
2407
2420
zero_user_segment (page , 0 , PAGE_SIZE );
2408
2421
unlock_page (page );
2409
2422
}
0 commit comments