From: Darrick J. Wong <djwong@xxxxxxxxxx> If the media scan finds that media have been lost, report this to the kernel so that the healthmon code can pass that along to xfs_scrubbed. Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --- scrub/phase6.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scrub/phase6.c b/scrub/phase6.c index 5a1f29738680e5..b5f6f3c1d4bc63 100644 --- a/scrub/phase6.c +++ b/scrub/phase6.c @@ -671,6 +671,29 @@ clean_pool( return ret; } +static void +report_ioerr_to_kernel( + struct scrub_ctx *ctx, + struct disk *disk, + uint64_t start, + uint64_t length) +{ + struct xfs_media_error me = { + .daddr = start, + .bbcount = length, + }; + dev_t dev = disk_to_dev(ctx, disk); + + if (dev == ctx->fsinfo.fs_datadev) + me.flags |= XFS_MEDIA_ERROR_DATADEV; + else if (dev == ctx->fsinfo.fs_rtdev) + me.flags |= XFS_MEDIA_ERROR_RTDEV; + else if (dev == ctx->fsinfo.fs_logdev) + me.flags |= XFS_MEDIA_ERROR_LOGDEV; + + ioctl(ctx->mnt.fd, XFS_IOC_MEDIA_ERROR, &me); +} + /* Remember a media error for later. */ static void remember_ioerr( @@ -695,6 +718,8 @@ remember_ioerr( return; } + report_ioerr_to_kernel(ctx, disk, start, length); + tree = bitmap_for_disk(ctx, disk, vs); if (!tree) { str_liberror(ctx, ENOENT, _("finding bad block bitmap"));