Skip to content

Commit 594e25e

Browse files
jiangyilismNicholas Bellinger
authored andcommitted
target/file: Do not return error for UNMAP if length is zero
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. Signed-off-by: Jiang Yi <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent bb176f6 commit 594e25e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/target/target_core_file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ fd_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
482482
struct inode *inode = file->f_mapping->host;
483483
int ret;
484484

485+
if (!nolb) {
486+
return 0;
487+
}
488+
485489
if (cmd->se_dev->dev_attrib.pi_prot_type) {
486490
ret = fd_do_prot_unmap(cmd, lba, nolb);
487491
if (ret)

0 commit comments

Comments
 (0)