Lines Matching refs:sblock

64 	struct scrub_block	*sblock;
216 struct scrub_block *sblock,
218 static void scrub_recheck_block_checksum(struct scrub_block *sblock);
224 static void scrub_write_block_to_dev_replace(struct scrub_block *sblock);
225 static int scrub_write_page_to_dev_replace(struct scrub_block *sblock,
227 static int scrub_checksum_data(struct scrub_block *sblock);
228 static int scrub_checksum_tree_block(struct scrub_block *sblock);
229 static int scrub_checksum_super(struct scrub_block *sblock);
230 static void scrub_block_get(struct scrub_block *sblock);
231 static void scrub_block_put(struct scrub_block *sblock);
244 static void scrub_block_complete(struct scrub_block *sblock);
551 scrub_block_put(sbio->pagev[i]->sblock);
728 static void scrub_print_warning(const char *errstr, struct scrub_block *sblock)
745 WARN_ON(sblock->page_count < 1);
746 dev = sblock->pagev[0]->dev;
747 fs_info = sblock->sctx->fs_info;
753 swarn.physical = sblock->pagev[0]->physical;
754 swarn.logical = sblock->pagev[0]->logical;
1198 struct scrub_block *sblock = sblocks_for_recheck +
1203 for (page_index = 0; page_index < sblock->page_count;
1205 sblock->pagev[page_index]->sblock = NULL;
1206 recover = sblock->pagev[page_index]->recover;
1209 sblock->pagev[page_index]->recover =
1212 scrub_page_put(sblock->pagev[page_index]);
1327 struct scrub_block *sblock;
1330 sblock = sblocks_for_recheck + mirror_index;
1331 sblock->sctx = sctx;
1343 sblock->pagev[page_index] = page;
1344 page->sblock = sblock;
1373 sblock->page_count++;
1407 mirror_num = page->sblock->pagev[0]->mirror_num;
1419 struct scrub_block *sblock)
1421 struct scrub_page *first_page = sblock->pagev[0];
1425 /* All pages in sblock belong to the same stripe on the same device. */
1433 for (page_num = 0; page_num < sblock->page_count; page_num++) {
1434 struct scrub_page *page = sblock->pagev[page_num];
1447 scrub_recheck_block_checksum(sblock);
1451 for (page_num = 0; page_num < sblock->page_count; page_num++)
1452 sblock->pagev[page_num]->io_error = 1;
1454 sblock->no_io_error_seen = 0;
1465 struct scrub_block *sblock,
1470 sblock->no_io_error_seen = 1;
1473 if (!retry_failed_mirror && scrub_is_page_on_raid56(sblock->pagev[0]))
1474 return scrub_recheck_block_on_raid56(fs_info, sblock);
1476 for (page_num = 0; page_num < sblock->page_count; page_num++) {
1478 struct scrub_page *page = sblock->pagev[page_num];
1482 sblock->no_io_error_seen = 0;
1496 sblock->no_io_error_seen = 0;
1502 if (sblock->no_io_error_seen)
1503 scrub_recheck_block_checksum(sblock);
1516 static void scrub_recheck_block_checksum(struct scrub_block *sblock)
1518 sblock->header_error = 0;
1519 sblock->checksum_error = 0;
1520 sblock->generation_error = 0;
1522 if (sblock->pagev[0]->flags & BTRFS_EXTENT_FLAG_DATA)
1523 scrub_checksum_data(sblock);
1525 scrub_checksum_tree_block(sblock);
1592 static void scrub_write_block_to_dev_replace(struct scrub_block *sblock)
1594 struct btrfs_fs_info *fs_info = sblock->sctx->fs_info;
1601 if (sblock->sparity)
1604 for (page_num = 0; page_num < sblock->page_count; page_num++) {
1607 ret = scrub_write_page_to_dev_replace(sblock, page_num);
1613 static int scrub_write_page_to_dev_replace(struct scrub_block *sblock,
1616 struct scrub_page *spage = sblock->pagev[page_num];
1622 return scrub_add_page_to_wr_bio(sblock->sctx, spage);
1749 static int scrub_checksum(struct scrub_block *sblock)
1762 sblock->header_error = 0;
1763 sblock->generation_error = 0;
1764 sblock->checksum_error = 0;
1766 WARN_ON(sblock->page_count < 1);
1767 flags = sblock->pagev[0]->flags;
1770 ret = scrub_checksum_data(sblock);
1772 ret = scrub_checksum_tree_block(sblock);
1774 (void)scrub_checksum_super(sblock);
1778 scrub_handle_errored_block(sblock);
1783 static int scrub_checksum_data(struct scrub_block *sblock)
1785 struct scrub_ctx *sctx = sblock->sctx;
1792 BUG_ON(sblock->page_count < 1);
1793 spage = sblock->pagev[0];
1804 sblock->checksum_error = 1;
1806 return sblock->checksum_error;
1809 static int scrub_checksum_tree_block(struct scrub_block *sblock)
1811 struct scrub_ctx *sctx = sblock->sctx;
1822 BUG_ON(sblock->page_count < 1);
1823 spage = sblock->pagev[0];
1834 sblock->header_error = 1;
1837 sblock->header_error = 1;
1838 sblock->generation_error = 1;
1842 sblock->header_error = 1;
1846 sblock->header_error = 1;
1854 kaddr = page_address(sblock->pagev[i]->page);
1860 sblock->checksum_error = 1;
1862 return sblock->header_error || sblock->checksum_error;
1865 static int scrub_checksum_super(struct scrub_block *sblock)
1868 struct scrub_ctx *sctx = sblock->sctx;
1877 BUG_ON(sblock->page_count < 1);
1878 spage = sblock->pagev[0];
1919 static void scrub_block_get(struct scrub_block *sblock)
1921 refcount_inc(&sblock->refs);
1924 static void scrub_block_put(struct scrub_block *sblock)
1926 if (refcount_dec_and_test(&sblock->refs)) {
1929 if (sblock->sparity)
1930 scrub_parity_put(sblock->sparity);
1932 for (i = 0; i < sblock->page_count; i++)
1933 scrub_page_put(sblock->pagev[i]);
1934 kfree(sblock);
1968 struct scrub_block *sblock = spage->sblock;
2029 scrub_block_get(sblock); /* one for the page added to the bio */
2030 atomic_inc(&sblock->outstanding_pages);
2040 struct scrub_block *sblock = bio->bi_private;
2041 struct btrfs_fs_info *fs_info = sblock->sctx->fs_info;
2044 sblock->no_io_error_seen = 0;
2048 btrfs_queue_work(fs_info->scrub_workers, &sblock->work);
2053 struct scrub_block *sblock = container_of(work, struct scrub_block, work);
2054 struct scrub_ctx *sctx = sblock->sctx;
2059 logical = sblock->pagev[0]->logical;
2060 dev = sblock->pagev[0]->dev;
2062 if (sblock->no_io_error_seen)
2063 scrub_recheck_block_checksum(sblock);
2065 if (!sblock->no_io_error_seen) {
2072 } else if (sblock->header_error || sblock->checksum_error) {
2080 scrub_write_block_to_dev_replace(sblock);
2089 scrub_block_put(sblock);
2093 static void scrub_missing_raid56_pages(struct scrub_block *sblock)
2095 struct scrub_ctx *sctx = sblock->sctx;
2097 u64 length = sblock->page_count * PAGE_SIZE;
2098 u64 logical = sblock->pagev[0]->logical;
2124 bio->bi_private = sblock;
2131 for (i = 0; i < sblock->page_count; i++) {
2132 struct scrub_page *spage = sblock->pagev[i];
2137 btrfs_init_work(&sblock->work, scrub_missing_raid56_worker, NULL, NULL);
2138 scrub_block_get(sblock);
2158 struct scrub_block *sblock;
2161 sblock = kzalloc(sizeof(*sblock), GFP_KERNEL);
2162 if (!sblock) {
2171 refcount_set(&sblock->refs, 1);
2172 sblock->sctx = sctx;
2173 sblock->no_io_error_seen = 1;
2185 scrub_block_put(sblock);
2190 sblock->pagev[index] = spage;
2191 spage->sblock = sblock;
2205 sblock->page_count++;
2215 WARN_ON(sblock->page_count == 0);
2221 scrub_missing_raid56_pages(sblock);
2223 for (index = 0; index < sblock->page_count; index++) {
2224 struct scrub_page *spage = sblock->pagev[index];
2229 scrub_block_put(sblock);
2239 scrub_block_put(sblock);
2266 spage->sblock->no_io_error_seen = 0;
2273 struct scrub_block *sblock = spage->sblock;
2275 if (atomic_dec_and_test(&sblock->outstanding_pages))
2276 scrub_block_complete(sblock);
2277 scrub_block_put(sblock);
2339 static void scrub_block_complete(struct scrub_block *sblock)
2343 if (!sblock->no_io_error_seen) {
2345 scrub_handle_errored_block(sblock);
2352 corrupted = scrub_checksum(sblock);
2353 if (!corrupted && sblock->sctx->is_dev_replace)
2354 scrub_write_block_to_dev_replace(sblock);
2357 if (sblock->sparity && corrupted && !sblock->data_corrected) {
2358 u64 start = sblock->pagev[0]->logical;
2359 u64 end = sblock->pagev[sblock->page_count - 1]->logical +
2362 scrub_parity_mark_sectors_error(sblock->sparity,
2463 struct scrub_block *sblock;
2466 sblock = kzalloc(sizeof(*sblock), GFP_KERNEL);
2467 if (!sblock) {
2476 refcount_set(&sblock->refs, 1);
2477 sblock->sctx = sctx;
2478 sblock->no_io_error_seen = 1;
2479 sblock->sparity = sparity;
2492 scrub_block_put(sblock);
2498 sblock->pagev[index] = spage;
2502 spage->sblock = sblock;
2515 sblock->page_count++;
2524 WARN_ON(sblock->page_count == 0);
2525 for (index = 0; index < sblock->page_count; index++) {
2526 struct scrub_page *spage = sblock->pagev[index];
2531 scrub_block_put(sblock);
2537 scrub_block_put(sblock);