From patchwork Mon Apr 8 01:41:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 787876 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5A6462838E; Mon, 8 Apr 2024 01:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712540523; cv=none; b=tYBwbXopPSh1iCpLi3fgOa7Ffpz8HWFMTUOY1yObLBz1GGDlzZtCQfxR+21dII8U/qW2Zbfmm4RYdsg13COQv2sl8f18R3cYKeLNELk4LjmzQo6VNDFjf3toi7rwcxu8ggVUvmqbX+fAteO1DjtnND4sFpXqw+gBPIP3T3iu+Rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712540523; c=relaxed/simple; bh=QOV+zkL37kOcX6meYmcdfK9cZIvUVPoX4nh2HY33pnY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NehoSZP2YGrtufcOBXtWHhQ+YTTyt0i1dm2T6hpw6supbuCzHgJIavv+zT4DcqV1nUSsmfuofYIDpaUWMJeBXScNHGuZtVRL5tTwEyyY9PUsLf6u8q9HtgYr50SfTEl2ONFZHTx894M1tUO7NUfc+BNTZFGCKCdSThSxBgZEi0s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PQzQzI4T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PQzQzI4T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F06DC433C7; Mon, 8 Apr 2024 01:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712540523; bh=QOV+zkL37kOcX6meYmcdfK9cZIvUVPoX4nh2HY33pnY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PQzQzI4ToxuxPPyrR82FGmGpYtnjv3XIxuSK685iwe4bGy1LhEHVh66pvWhXlPBr7 wDPF7+MEPpDKnqKeeHNRZHgdMEe3SQWUIwZvlLKIqphgBlzdGItCerT1ijL/hcSE8C b3yjDG1xFZqallfWL/fs5rWRpQ7jM7rjPybjdCXU0XsJo5a5lhc5dYe9PAzQplYQ5Y o66wd8uh5S4Q3iLKodAmGa0AKTOIhln1paUeKn8/mrE8Ctmt4NPE4fQbJbboYGTfvG OVO3YOmrHw07XU/915ebjk5TgUXxRYRISXs2/84EJYEWHOqtvrOGoHeAXsqOlr2U63 5FuWEObxS1Ubg== From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" , dm-devel@lists.linux.dev, Mike Snitzer , linux-nvme@lists.infradead.org, Keith Busch , Christoph Hellwig Subject: [PATCH v7 17/28] null_blk: Introduce fua attribute Date: Mon, 8 Apr 2024 10:41:17 +0900 Message-ID: <20240408014128.205141-18-dlemoal@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408014128.205141-1-dlemoal@kernel.org> References: <20240408014128.205141-1-dlemoal@kernel.org> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the fua configfs attribute and module parameter to allow configuring if the device supports FUA or not. Using this attribute has an effect on the null_blk device only if memory backing is enabled together with a write cache (cache_size option). This new attribute allows configuring a null_blk device with a write cache but without FUA support. This is convenient to test the block layer flush machinery. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Bart Van Assche Reviewed-by: Chaitanya Kulkarni Tested-by: Hans Holmberg Tested-by: Dennis Maisenbacher Reviewed-by: Martin K. Petersen --- drivers/block/null_blk/main.c | 12 ++++++++++-- drivers/block/null_blk/null_blk.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 14e9aa867afe..993e9e8a7e69 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -225,6 +225,10 @@ static unsigned long g_cache_size; module_param_named(cache_size, g_cache_size, ulong, 0444); MODULE_PARM_DESC(mbps, "Cache size in MiB for memory-backed device. Default: 0 (none)"); +static bool g_fua = true; +module_param_named(fua, g_fua, bool, 0444); +MODULE_PARM_DESC(zoned, "Enable/disable FUA support when cache_size is used. Default: true"); + static unsigned int g_mbps; module_param_named(mbps, g_mbps, uint, 0444); MODULE_PARM_DESC(mbps, "Limit maximum bandwidth (in MiB/s). Default: 0 (no limit)"); @@ -446,6 +450,7 @@ NULLB_DEVICE_ATTR(virt_boundary, bool, NULL); NULLB_DEVICE_ATTR(no_sched, bool, NULL); NULLB_DEVICE_ATTR(shared_tags, bool, NULL); NULLB_DEVICE_ATTR(shared_tag_bitmap, bool, NULL); +NULLB_DEVICE_ATTR(fua, bool, NULL); static ssize_t nullb_device_power_show(struct config_item *item, char *page) { @@ -593,6 +598,7 @@ static struct configfs_attribute *nullb_device_attrs[] = { &nullb_device_attr_no_sched, &nullb_device_attr_shared_tags, &nullb_device_attr_shared_tag_bitmap, + &nullb_device_attr_fua, NULL, }; @@ -671,7 +677,7 @@ nullb_group_drop_item(struct config_group *group, struct config_item *item) static ssize_t memb_group_features_show(struct config_item *item, char *page) { return snprintf(page, PAGE_SIZE, - "badblocks,blocking,blocksize,cache_size," + "badblocks,blocking,blocksize,cache_size,fua," "completion_nsec,discard,home_node,hw_queue_depth," "irqmode,max_sectors,mbps,memory_backed,no_sched," "poll_queues,power,queue_mode,shared_tag_bitmap," @@ -763,6 +769,8 @@ static struct nullb_device *null_alloc_dev(void) dev->no_sched = g_no_sched; dev->shared_tags = g_shared_tags; dev->shared_tag_bitmap = g_shared_tag_bitmap; + dev->fua = g_fua; + return dev; } @@ -1920,7 +1928,7 @@ static int null_add_dev(struct nullb_device *dev) if (dev->cache_size > 0) { set_bit(NULLB_DEV_FL_CACHE, &nullb->dev->flags); - blk_queue_write_cache(nullb->q, true, true); + blk_queue_write_cache(nullb->q, true, dev->fua); } nullb->q->queuedata = nullb; diff --git a/drivers/block/null_blk/null_blk.h b/drivers/block/null_blk/null_blk.h index a9c5df650ddb..3234e6c85eed 100644 --- a/drivers/block/null_blk/null_blk.h +++ b/drivers/block/null_blk/null_blk.h @@ -105,6 +105,7 @@ struct nullb_device { bool no_sched; /* no IO scheduler for the device */ bool shared_tags; /* share tag set between devices for blk-mq */ bool shared_tag_bitmap; /* use hostwide shared tags */ + bool fua; /* Support FUA */ }; struct nullb {