scsi: target: Detect UNMAP support post configuration
On our backend we can do something similar to LIO where we can enable and disable UNMAP support on the fly. In the SCSI/block layer we can detect this by just doing a rescan. However, LIO cannot detect this change because we only check during the initial configuration. This patch allows UNMAP detection to also happen when the user tries to turn it on. Link: https://lore.kernel.org/r/20220628200230.15052-6-michael.christie@oracle.com Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
33efaaf6e2
commit
34bd1dcacf
1 changed files with 19 additions and 8 deletions
|
@ -732,6 +732,7 @@ static ssize_t emulate_tpu_store(struct config_item *item,
|
||||||
const char *page, size_t count)
|
const char *page, size_t count)
|
||||||
{
|
{
|
||||||
struct se_dev_attrib *da = to_attrib(item);
|
struct se_dev_attrib *da = to_attrib(item);
|
||||||
|
struct se_device *dev = da->da_dev;
|
||||||
bool flag;
|
bool flag;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -744,9 +745,12 @@ static ssize_t emulate_tpu_store(struct config_item *item,
|
||||||
* Discard supported is detected iblock_create_virtdevice().
|
* Discard supported is detected iblock_create_virtdevice().
|
||||||
*/
|
*/
|
||||||
if (flag && !da->max_unmap_block_desc_count) {
|
if (flag && !da->max_unmap_block_desc_count) {
|
||||||
|
if (!dev->transport->configure_unmap ||
|
||||||
|
!dev->transport->configure_unmap(dev)) {
|
||||||
pr_err("Generic Block Discard not supported\n");
|
pr_err("Generic Block Discard not supported\n");
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
da->emulate_tpu = flag;
|
da->emulate_tpu = flag;
|
||||||
pr_debug("dev[%p]: SE Device Thin Provisioning UNMAP bit: %d\n",
|
pr_debug("dev[%p]: SE Device Thin Provisioning UNMAP bit: %d\n",
|
||||||
|
@ -758,6 +762,7 @@ static ssize_t emulate_tpws_store(struct config_item *item,
|
||||||
const char *page, size_t count)
|
const char *page, size_t count)
|
||||||
{
|
{
|
||||||
struct se_dev_attrib *da = to_attrib(item);
|
struct se_dev_attrib *da = to_attrib(item);
|
||||||
|
struct se_device *dev = da->da_dev;
|
||||||
bool flag;
|
bool flag;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -770,9 +775,12 @@ static ssize_t emulate_tpws_store(struct config_item *item,
|
||||||
* Discard supported is detected iblock_create_virtdevice().
|
* Discard supported is detected iblock_create_virtdevice().
|
||||||
*/
|
*/
|
||||||
if (flag && !da->max_unmap_block_desc_count) {
|
if (flag && !da->max_unmap_block_desc_count) {
|
||||||
|
if (!dev->transport->configure_unmap ||
|
||||||
|
!dev->transport->configure_unmap(dev)) {
|
||||||
pr_err("Generic Block Discard not supported\n");
|
pr_err("Generic Block Discard not supported\n");
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
da->emulate_tpws = flag;
|
da->emulate_tpws = flag;
|
||||||
pr_debug("dev[%p]: SE Device Thin Provisioning WRITE_SAME: %d\n",
|
pr_debug("dev[%p]: SE Device Thin Provisioning WRITE_SAME: %d\n",
|
||||||
|
@ -964,6 +972,7 @@ static ssize_t unmap_zeroes_data_store(struct config_item *item,
|
||||||
const char *page, size_t count)
|
const char *page, size_t count)
|
||||||
{
|
{
|
||||||
struct se_dev_attrib *da = to_attrib(item);
|
struct se_dev_attrib *da = to_attrib(item);
|
||||||
|
struct se_device *dev = da->da_dev;
|
||||||
bool flag;
|
bool flag;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -982,11 +991,13 @@ static ssize_t unmap_zeroes_data_store(struct config_item *item,
|
||||||
* Discard supported is detected iblock_configure_device().
|
* Discard supported is detected iblock_configure_device().
|
||||||
*/
|
*/
|
||||||
if (flag && !da->max_unmap_block_desc_count) {
|
if (flag && !da->max_unmap_block_desc_count) {
|
||||||
pr_err("dev[%p]: Thin Provisioning LBPRZ will not be set"
|
if (!dev->transport->configure_unmap ||
|
||||||
" because max_unmap_block_desc_count is zero\n",
|
!dev->transport->configure_unmap(dev)) {
|
||||||
|
pr_err("dev[%p]: Thin Provisioning LBPRZ will not be set because max_unmap_block_desc_count is zero\n",
|
||||||
da->da_dev);
|
da->da_dev);
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
da->unmap_zeroes_data = flag;
|
da->unmap_zeroes_data = flag;
|
||||||
pr_debug("dev[%p]: SE Device Thin Provisioning LBPRZ bit: %d\n",
|
pr_debug("dev[%p]: SE Device Thin Provisioning LBPRZ bit: %d\n",
|
||||||
da->da_dev, flag);
|
da->da_dev, flag);
|
||||||
|
|
Loading…
Add table
Reference in a new issue