@@ -76,6 +76,7 @@ static mempool_t *metapage_mempool;
76
76
struct meta_anchor {
77
77
int mp_count ;
78
78
atomic_t io_count ;
79
+ blk_status_t status ;
79
80
struct metapage * mp [MPS_PER_PAGE ];
80
81
};
81
82
@@ -138,12 +139,16 @@ static inline void inc_io(struct folio *folio)
138
139
atomic_inc (& anchor -> io_count );
139
140
}
140
141
141
- static inline void dec_io (struct folio * folio , void (* handler ) (struct folio * ))
142
+ static inline void dec_io (struct folio * folio , blk_status_t status ,
143
+ void (* handler )(struct folio * , blk_status_t ))
142
144
{
143
145
struct meta_anchor * anchor = folio -> private ;
144
146
147
+ if (anchor -> status == BLK_STS_OK )
148
+ anchor -> status = status ;
149
+
145
150
if (atomic_dec_and_test (& anchor -> io_count ))
146
- handler (folio );
151
+ handler (folio , anchor -> status );
147
152
}
148
153
149
154
#else
@@ -168,7 +173,7 @@ static inline void remove_metapage(struct folio *folio, struct metapage *mp)
168
173
}
169
174
170
175
#define inc_io (folio ) do {} while(0)
171
- #define dec_io (folio , handler ) handler(folio)
176
+ #define dec_io (folio , status , handler ) handler(folio, status )
172
177
173
178
#endif
174
179
@@ -258,23 +263,20 @@ static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
258
263
return lblock ;
259
264
}
260
265
261
- static void last_read_complete (struct folio * folio )
266
+ static void last_read_complete (struct folio * folio , blk_status_t status )
262
267
{
263
- if (!folio_test_error (folio ))
264
- folio_mark_uptodate (folio );
265
- folio_unlock (folio );
268
+ if (status )
269
+ printk (KERN_ERR "Read error %d at %#llx\n" , status ,
270
+ folio_pos (folio ));
271
+
272
+ folio_end_read (folio , status == 0 );
266
273
}
267
274
268
275
static void metapage_read_end_io (struct bio * bio )
269
276
{
270
277
struct folio * folio = bio -> bi_private ;
271
278
272
- if (bio -> bi_status ) {
273
- printk (KERN_ERR "metapage_read_end_io: I/O error\n" );
274
- folio_set_error (folio );
275
- }
276
-
277
- dec_io (folio , last_read_complete );
279
+ dec_io (folio , bio -> bi_status , last_read_complete );
278
280
bio_put (bio );
279
281
}
280
282
@@ -300,11 +302,17 @@ static void remove_from_logsync(struct metapage *mp)
300
302
LOGSYNC_UNLOCK (log , flags );
301
303
}
302
304
303
- static void last_write_complete (struct folio * folio )
305
+ static void last_write_complete (struct folio * folio , blk_status_t status )
304
306
{
305
307
struct metapage * mp ;
306
308
unsigned int offset ;
307
309
310
+ if (status ) {
311
+ int err = blk_status_to_errno (status );
312
+ printk (KERN_ERR "metapage_write_end_io: I/O error\n" );
313
+ mapping_set_error (folio -> mapping , err );
314
+ }
315
+
308
316
for (offset = 0 ; offset < PAGE_SIZE ; offset += PSIZE ) {
309
317
mp = folio_to_mp (folio , offset );
310
318
if (mp && test_bit (META_io , & mp -> flag )) {
@@ -326,12 +334,7 @@ static void metapage_write_end_io(struct bio *bio)
326
334
327
335
BUG_ON (!folio -> private );
328
336
329
- if (bio -> bi_status ) {
330
- int err = blk_status_to_errno (bio -> bi_status );
331
- printk (KERN_ERR "metapage_write_end_io: I/O error\n" );
332
- mapping_set_error (folio -> mapping , err );
333
- }
334
- dec_io (folio , last_write_complete );
337
+ dec_io (folio , bio -> bi_status , last_write_complete );
335
338
bio_put (bio );
336
339
}
337
340
@@ -454,10 +457,10 @@ static int metapage_write_folio(struct folio *folio,
454
457
4 , bio , sizeof (* bio ), 0 );
455
458
bio_put (bio );
456
459
folio_unlock (folio );
457
- dec_io (folio , last_write_complete );
460
+ dec_io (folio , BLK_STS_OK , last_write_complete );
458
461
err_out :
459
462
while (bad_blocks -- )
460
- dec_io (folio , last_write_complete );
463
+ dec_io (folio , BLK_STS_OK , last_write_complete );
461
464
return - EIO ;
462
465
}
463
466
0 commit comments