From patchwork Sat Jan 25 01:29:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shin'ichiro Kawasaki X-Patchwork-Id: 13950092 Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE4181EE01C for ; Sat, 25 Jan 2025 01:29:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.141.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737768554; cv=none; b=jrhPLXIfgD8SQx7aVwz9YBWNpRhKB2LSDkeBsB5zuBQxZxcQauUPVMtJ3MAr1veaX1+1/0c6D5WhXoGrEqRN3z2UDLuV8Cuyj3mjEV9toT9ZMdb9gFqxdEkX3X+dlVHyOqq0hOSa4Me/rwT9YH5KxESG7gGvw1O3yDkpdzmq6nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737768554; c=relaxed/simple; bh=3mdbxzZKMwLju/UgfYOtK0jHFq4qwY9NzTr+P6V24QM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bvKEc4jvKGh+Yg8PnpIGavb0Z5RAkM5UDPuzYdncITJFSYShHwJpQOnYHwE6TJnEZSN34Jpr7oj+UXXiIz8GkxavtFQrOqPyi473htph2zLz621Ivs2KMOHQN7OEW5DMHAU2zJ03DPHpN/RKvT92vKcB8T6TmeyWYph2vHpOWd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=QDq+Ula0; arc=none smtp.client-ip=68.232.141.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="QDq+Ula0" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1737768552; x=1769304552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3mdbxzZKMwLju/UgfYOtK0jHFq4qwY9NzTr+P6V24QM=; b=QDq+Ula0qitunDvJ7akIxFtmDAMBasKAkU3mSEwMjEWeRtLN77WfD1nq l876bBBI0pVgGKNNAx0TOM/15lD2QLbWuTF6lXaK5DHDwrCAEBxhWk5Ec wiFnl7Ssmy+5o/YtA0ikvzZI2l4aMcvv76m9gPf+75YorRT+2N8aqDpSP 1uPVsMg/1X34EB0gi+HchMhNLJwYFNB1FpL9D31kiQjXTqUxkER6FG8Df V/dATPZotWyUTRDBzHSg+ssTFd3wVNRAFBuw99n3c/EOh0UXl0YK25jeV XSKLPCbpti+9kvk4UtcPbhUW+uQalA397wBEXYzPMN6j2d83oDZ38j371 w==; X-CSE-ConnectionGUID: tf4rVKulT/KvYAzQiF43tg== X-CSE-MsgGUID: 8ABCQZtCQ9S4/lC7my1E+A== X-IronPort-AV: E=Sophos;i="6.13,232,1732550400"; d="scan'208";a="37973936" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 25 Jan 2025 09:29:11 +0800 IronPort-SDR: 679430cd_tXGvxmcSDpyfmNUCfXwTITy9pEricDqib+mWvtGbm8+iKjL L6JoBG8pp9ol9M7ISPzFeGj+Iq5gC9tB6/+yGNA== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 24 Jan 2025 16:31:10 -0800 WDCIronportException: Internal Received: from unknown (HELO shindev.ssa.fujisawa.hgst.com) ([10.149.66.30]) by uls-op-cesaip01.wdc.com with ESMTP; 24 Jan 2025 17:29:11 -0800 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, Jens Axboe Cc: Damien Le Moal , Bart Van Assche , Shin'ichiro Kawasaki Subject: [PATCH v5 2/5] null_blk: introduce badblocks_once parameter Date: Sat, 25 Jan 2025 10:29:05 +0900 Message-ID: <20250125012908.1259887-3-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250125012908.1259887-1-shinichiro.kawasaki@wdc.com> References: <20250125012908.1259887-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When IO errors happen on real storage devices, the IOs repeated to the same target range can success by virtue of recovery features by devices, such as reserved block assignment. To simulate such IO errors and recoveries, introduce the new parameter badblocks_once parameter. When this parameter is set to 1, the specified badblocks are cleared after the first IO error, so that the next IO to the blocks succeed. Reviewed-by: Damien Le Moal Reviewed-by: Chaitanya Kulkarni Signed-off-by: Shin'ichiro Kawasaki --- drivers/block/null_blk/main.c | 11 ++++++++--- drivers/block/null_blk/null_blk.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 0725d221cff4..2a060a6ea8c0 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -473,6 +473,7 @@ NULLB_DEVICE_ATTR(shared_tags, bool, NULL); NULLB_DEVICE_ATTR(shared_tag_bitmap, bool, NULL); NULLB_DEVICE_ATTR(fua, bool, NULL); NULLB_DEVICE_ATTR(rotational, bool, NULL); +NULLB_DEVICE_ATTR(badblocks_once, bool, NULL); static ssize_t nullb_device_power_show(struct config_item *item, char *page) { @@ -593,6 +594,7 @@ CONFIGFS_ATTR_WO(nullb_device_, zone_offline); static struct configfs_attribute *nullb_device_attrs[] = { &nullb_device_attr_badblocks, + &nullb_device_attr_badblocks_once, &nullb_device_attr_blocking, &nullb_device_attr_blocksize, &nullb_device_attr_cache_size, @@ -1315,10 +1317,13 @@ static inline blk_status_t null_handle_badblocks(struct nullb_cmd *cmd, sector_t first_bad; int bad_sectors; - if (badblocks_check(bb, sector, nr_sectors, &first_bad, &bad_sectors)) - return BLK_STS_IOERR; + if (!badblocks_check(bb, sector, nr_sectors, &first_bad, &bad_sectors)) + return BLK_STS_OK; - return BLK_STS_OK; + if (cmd->nq->dev->badblocks_once) + badblocks_clear(bb, first_bad, bad_sectors); + + return BLK_STS_IOERR; } static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd, diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index 6f9fe6171087..3c4c07f0418b 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -63,6 +63,7 @@ struct nullb_device { unsigned long flags; /* device flags */ unsigned int curr_cache; struct badblocks badblocks; + bool badblocks_once; unsigned int nr_zones; unsigned int nr_zones_imp_open;