Message ID | 20171213215513.26416-1-avagin@openvz.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Andrei, Apologies for the delayed follow up. On Wed, 2017-12-13 at 13:55 -0800, Andrei Vagin wrote: > 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> > --- > drivers/target/target_core_sbc.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > Applied. Thank you. -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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;
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> --- drivers/target/target_core_sbc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)