target: don't call an unmap callback if a range length is zero

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/9960f85181dd08cda03fddcf0bc8d81190bec4eb
Commit:     9960f85181dd08cda03fddcf0bc8d81190bec4eb
Parent:     ce512d79d0466a604793addb6b769d12ee326822
Refname:    refs/heads/master
Author:     Andrei Vagin <[email protected]>
AuthorDate: Wed Dec 13 13:55:13 2017 -0800
Committer:  Nicholas Bellinger <[email protected]>
CommitDate: Fri Jan 12 15:07:28 2018 -0800

    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 <[email protected]>
    Signed-off-by: Nicholas Bellinger <[email protected]>
---
 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 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;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.