Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

null_blk: Introduce fua attribute

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 <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Tested-by: Hans Holmberg <hans.holmberg@wdc.com>
Tested-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240408014128.205141-18-dlemoal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Damien Le Moal and committed by
Jens Axboe
f4f84586 997a1f08

+11 -2
+10 -2
drivers/block/null_blk/main.c
··· 225 225 module_param_named(cache_size, g_cache_size, ulong, 0444); 226 226 MODULE_PARM_DESC(mbps, "Cache size in MiB for memory-backed device. Default: 0 (none)"); 227 227 228 + static bool g_fua = true; 229 + module_param_named(fua, g_fua, bool, 0444); 230 + MODULE_PARM_DESC(zoned, "Enable/disable FUA support when cache_size is used. Default: true"); 231 + 228 232 static unsigned int g_mbps; 229 233 module_param_named(mbps, g_mbps, uint, 0444); 230 234 MODULE_PARM_DESC(mbps, "Limit maximum bandwidth (in MiB/s). Default: 0 (no limit)"); ··· 450 446 NULLB_DEVICE_ATTR(no_sched, bool, NULL); 451 447 NULLB_DEVICE_ATTR(shared_tags, bool, NULL); 452 448 NULLB_DEVICE_ATTR(shared_tag_bitmap, bool, NULL); 449 + NULLB_DEVICE_ATTR(fua, bool, NULL); 453 450 454 451 static ssize_t nullb_device_power_show(struct config_item *item, char *page) 455 452 { ··· 598 593 &nullb_device_attr_no_sched, 599 594 &nullb_device_attr_shared_tags, 600 595 &nullb_device_attr_shared_tag_bitmap, 596 + &nullb_device_attr_fua, 601 597 NULL, 602 598 }; 603 599 ··· 677 671 static ssize_t memb_group_features_show(struct config_item *item, char *page) 678 672 { 679 673 return snprintf(page, PAGE_SIZE, 680 - "badblocks,blocking,blocksize,cache_size," 674 + "badblocks,blocking,blocksize,cache_size,fua," 681 675 "completion_nsec,discard,home_node,hw_queue_depth," 682 676 "irqmode,max_sectors,mbps,memory_backed,no_sched," 683 677 "poll_queues,power,queue_mode,shared_tag_bitmap," ··· 769 763 dev->no_sched = g_no_sched; 770 764 dev->shared_tags = g_shared_tags; 771 765 dev->shared_tag_bitmap = g_shared_tag_bitmap; 766 + dev->fua = g_fua; 767 + 772 768 return dev; 773 769 } 774 770 ··· 1928 1920 1929 1921 if (dev->cache_size > 0) { 1930 1922 set_bit(NULLB_DEV_FL_CACHE, &nullb->dev->flags); 1931 - blk_queue_write_cache(nullb->q, true, true); 1923 + blk_queue_write_cache(nullb->q, true, dev->fua); 1932 1924 } 1933 1925 1934 1926 nullb->q->queuedata = nullb;
+1
drivers/block/null_blk/null_blk.h
··· 105 105 bool no_sched; /* no IO scheduler for the device */ 106 106 bool shared_tags; /* share tag set between devices for blk-mq */ 107 107 bool shared_tag_bitmap; /* use hostwide shared tags */ 108 + bool fua; /* Support FUA */ 108 109 }; 109 110 110 111 struct nullb {