From: Nicholas Bellinger Date: Mon, 23 Feb 2015 06:17:13 +0000 (-0800) Subject: target: Disallow changing of WRITE cache/FUA attrs after export X-Git-Tag: Ubuntu-5.2.0-15.16~11698^2~9 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=4b36b68ca8bab6edf7e99f859c42a91f3ad1846e;p=mirror_ubuntu-eoan-kernel.git target: Disallow changing of WRITE cache/FUA attrs after export Now that incoming FUA=1 bit check is enforced for backends with FUA or WCE disabled, go ahead and disallow the changing of related backend attributes when active fabric exports exist. This is required to avoid potential failures with existing initiator LUN registrations that have been previously created with FUA=1. Reported-by: Christoph Hellwig Cc: Doug Gilbert Cc: James Bottomley Cc: Ronnie Sahlberg Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 58f49ff69b14..37449bdd62f6 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -767,6 +767,16 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) pr_err("Illegal value %d\n", flag); return -EINVAL; } + if (flag && + dev->transport->get_write_cache) { + pr_err("emulate_fua_write not supported for this device\n"); + return -EINVAL; + } + if (dev->export_count) { + pr_err("emulate_fua_write cannot be changed with active" + " exports: %d\n", dev->export_count); + return -EINVAL; + } dev->dev_attrib.emulate_fua_write = flag; pr_debug("dev[%p]: SE Device Forced Unit Access WRITEs: %d\n", dev, dev->dev_attrib.emulate_fua_write); @@ -801,7 +811,11 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) pr_err("emulate_write_cache not supported for this device\n"); return -EINVAL; } - + if (dev->export_count) { + pr_err("emulate_write_cache cannot be changed with active" + " exports: %d\n", dev->export_count); + return -EINVAL; + } dev->dev_attrib.emulate_write_cache = flag; pr_debug("dev[%p]: SE Device WRITE_CACHE_EMULATION flag: %d\n", dev, dev->dev_attrib.emulate_write_cache);