[Devel] [PATCH RHEL7 COMMIT] target: don't call an unmap callback if a range length is zero
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Dec 27 19:05:43 MSK 2017
The commit is pushed to "branch-rh7-3.10.0-693.11.1.vz7.39.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.1.vz7.39.9
------>
commit ab1e0ca107585279a02870be5aa06378d2da742d
Author: Andrei Vagin <avagin at openvz.org>
Date: Wed Dec 27 19:05:43 2017 +0300
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.
According to specification, UNMAP command can be received with a zero range:
If the UNMAP BLOCK DESCRIPTOR DATA LENGTH is set to zero, then no unmap block
descriptors are included in the UNMAP parameter list. This condition shall not
be considered an error.
The issues has been found while running libscsi tests.
https://github.com/sahlberg/libiscsi
https://patchwork.kernel.org/patch/10110977/
https://jira.sw.ru/browse/PSBM-79534
Cc: Alexey.Kuznetsov at acronis.com
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
drivers/target/target_core_sbc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 59a1235a633a..99fb25f681af 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -1132,9 +1132,11 @@ sbc_execute_unmap(struct se_cmd *cmd,
goto err;
}
- ret = do_unmap_fn(cmd, priv, lba, range);
- if (ret)
- goto err;
+ if (range) {
+ ret = do_unmap_fn(cmd, priv, lba, range);
+ if (ret)
+ goto err;
+ }
ptr += 16;
size -= 16;
More information about the Devel
mailing list