summaryrefslogtreecommitdiff
path: root/drivers/target
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@openvz.org>2017-12-14 00:55:13 +0300
committerNicholas Bellinger <nab@linux-iscsi.org>2018-01-13 02:07:28 +0300
commit9960f85181dd08cda03fddcf0bc8d81190bec4eb (patch)
tree69c7bb7df93a367bdbd5dd665f1ada7260d41f6e /drivers/target
parentce512d79d0466a604793addb6b769d12ee326822 (diff)
downloadlinux-9960f85181dd08cda03fddcf0bc8d81190bec4eb.tar.xz
target: don't call an unmap callback if a range length is zero
If a length of a range is zero, it means there is nothing to unmap and we can skip this range. Here is one more reason, why we have to skip such ranges. An unmap callback calls file_operations->fallocate(), but the man page for the fallocate syscall says that fallocate(fd, mode, offset, let) returns EINVAL, if len is zero. It means that file_operations->fallocate() isn't obligated to handle zero ranges too. Signed-off-by: Andrei Vagin <avagin@openvz.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_sbc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 750a04ed0e93..b054682e974f 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -1216,9 +1216,11 @@ sbc_execute_unmap(struct se_cmd *cmd)
goto err;
}
- ret = ops->execute_unmap(cmd, lba, range);
- if (ret)
- goto err;
+ if (range) {
+ ret = ops->execute_unmap(cmd, lba, range);
+ if (ret)
+ goto err;
+ }
ptr += 16;
size -= 16;