Hi Nic, The function fd_execute_unmap() in target_core_file.c calles ret = file->f_op->fallocate(file, mode, pos, len); Some filesystems implement fallocate() to return error if length is zero (e.g. btrfs) but according to SCSI Block Commands spec UNMAP should return success for zero length. By the way, I think we should call vfs_fallocate() instead of invoking the function pointers of struct file_operations. vfs_fallocate() also returns error if length is zero. So I propose a patch: Signed-off-by: Jiang Yi <jiangyilism@xxxxxxxxx> --- drivers/target/target_core_file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 24cf11d..8e69399 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -482,6 +482,10 @@ fd_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb) struct inode *inode = file->f_mapping->host; int ret; + if (!nolb) { + return 0; + } + if (cmd->se_dev->dev_attrib.pi_prot_type) { ret = fd_do_prot_unmap(cmd, lba, nolb); if (ret) @@ -512,7 +516,7 @@ fd_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb) if (!file->f_op->fallocate) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - ret = file->f_op->fallocate(file, mode, pos, len); + ret = vfs_fallocate(file, mode, pos, len); if (ret < 0) { pr_warn("FILEIO: fallocate() failed: %d\n", ret); return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; -- 2.5.0 by Jiang Yi -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html