tcm/iblock: Add WriteCache and Forced Unit Access WRITE emulation

This patch adds support for WriteCache emulation using a struct block_device
backend and block/blk-barrier.c:blkdev_issue_flush().  It also adds support
for Forced Unit Access WRITE emulation, and using the TCM callers, can be
configured independently via ConfigFS using generic device attributes added
in commit ab60b29471.

For the WriteCache bit, the iblock_do_sync_cache_range() caller for SYNCHRONIZE_CACHE*
ops have been added, which are called by transport_generic_synchronize_cache() using
struct se_subsystem_api->do_sync_cache_range().  For the FUA WRITE struct se_task context
case, __iblock_do_sync_cache() is called directly from iblock_do_task(), which note
currently does *not* return a failed SAM status, even if the write flush itself using
block/blk-barrier.c:blkdev_issue_flush() caller fails.

In iblock_create_virtdevice(), an explict call to __iblock_do_sync_cache() ->
blkdev_issue_flush() has been added in order to determine if a block flush operation
is supported by the struct block_device, and set ib_dev->ibd_flags |= IBDF_BDEV_ISSUE_FLUSH.
This flag is used in iblock_emulated_write_cache() and iblock_emulated_fua_write()
in order to determine the proper caching control and device TYPE_DISK specific mode page
area used for WCE=1 and DPOFUA=1.

Finally, this patch adds supports the SYNCHRONIZE_CACHE* Immed=1 bit to generate CDB
status for the struct se_cmd + struct se_task context with transport_complete_sync_cache()
before doing the actual __iblock_do_sync_cache().

Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
2 files changed