History

Btrfs: fix meta data raid-repair merge problem

Commit 4a54c8c16 introduced raid-repair, killing the individual readpage_io_failed_hook entries from inode.c and disk-io.c. Commit 4bb31e92 introduced new readahead code, adding a readpage_io_failed_hook to disk-io.c. The raid-repair commit had logic to disable raid-repair, if readpage_io_failed_hook is set. Thus, the readahead commit effectively disabled raid-repair for meta data. This commit changes the logic to always attempt raid-repair when needed and call the readpage_io_failed_hook in case raid-repair fails. This is much more straight forward and should have been like that from the beginning.

Jan Schmidt committed 14 years ago

Commit f4a8e651 parent be064d11 file · +20 −7Browse files

Unified · Split

fs/btrfs/extent_io.c+20−7
@@ -2287,14 +2287,20 @@ static void end_bio_extent_readpage(struct bio *bio, int err) · 2286 unmodified lines
22872287 if (!uptodate) {
22882288 int failed_mirror;
22892289 failed_mirror = (int)(unsigned long)bio->bi_bdev;
2290− if (tree->ops && tree->ops->readpage_io_failed_hook)
2291− ret = tree->ops->readpage_io_failed_hook(
2292− bio, page, start, end,
2293− failed_mirror, state);
2294− else
2295− ret = bio_readpage_error(bio, page, start, end,
2296− failed_mirror, NULL);
2290+ /*
2291+ * The generic bio_readpage_error handles errors the
2292+ * following way: If possible, new read requests are
2293+ * created and submitted and will end up in
2294+ * end_bio_extent_readpage as well (if we're lucky, not
2295+ * in the !uptodate case). In that case it returns 0 and
2296+ * we just go on with the next page in our bio. If it
2297+ * can't handle the error it will return -EIO and we
2298+ * remain responsible for that page.
2299+ */
2300+ ret = bio_readpage_error(bio, page, start, end,
2301+ failed_mirror, NULL);
22972302 if (ret == 0) {
2303+error_handled:
22982304 uptodate =
22992305 test_bit(BIO_UPTODATE, &bio->bi_flags);
23002306 if (err)
@@ -2302,6 +2308,13 @@ static void end_bio_extent_readpage(struct bio *bio, int err) · 1 unmodified line
23022308 uncache_state(&cached);
23032309 continue;
23042310 }
2311+ if (tree->ops && tree->ops->readpage_io_failed_hook) {
2312+ ret = tree->ops->readpage_io_failed_hook(
2313+ bio, page, start, end,
2314+ failed_mirror, state);
2315+ if (ret == 0)
2316+ goto error_handled;
2317+ }
23052318 }
23062319
23072320 if (uptodate) {