summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>2021-02-28 06:56:45 +0100
committerMartin K. Petersen <martin.petersen@oracle.com>2021-03-10 05:47:18 +0100
commit4524a0b159028c2910dfe40469ed6512c455df61 (patch)
tree7efc03ffa60df069500467897a6ebc755d34d99f /drivers/target
parentscsi: target: core: pr: Initialize arrays at declaration time (diff)
downloadlinux-4524a0b159028c2910dfe40469ed6512c455df61.tar.xz
linux-4524a0b159028c2910dfe40469ed6512c455df61.zip
scsi: target: core: file: Don't duplicate memset(0xff)
The function fd_do_prot_fill() is called from two callers fd_do_prot_unmap() and fd_format_prot(). Both callers initialize the passed buffer to 0xff with memset(). Move the memset() call to fd_do_prot_fill() to avoid duplication. Link: https://lore.kernel.org/r/20210228055645.22253-24-chaitanya.kulkarni@wdc.com Reviewed-by: Mike Christie <michael.christie@oracle.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_file.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 5a66854def95..ef4a8e189fba 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -498,6 +498,7 @@ fd_do_prot_fill(struct se_device *se_dev, sector_t lba, sector_t nolb,
prot_length = nolb * se_dev->prot_length;
+ memset(buf, 0xff, bufsize);
for (prot = 0; prot < prot_length;) {
sector_t len = min_t(sector_t, bufsize, prot_length - prot);
ssize_t ret = kernel_write(prot_fd, buf, len, &pos);
@@ -523,7 +524,6 @@ fd_do_prot_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
pr_err("Unable to allocate FILEIO prot buf\n");
return -ENOMEM;
}
- memset(buf, 0xff, PAGE_SIZE);
rc = fd_do_prot_fill(cmd->se_dev, lba, nolb, buf, PAGE_SIZE);
@@ -882,7 +882,6 @@ static int fd_format_prot(struct se_device *dev)
(unsigned long long)(dev->transport->get_blocks(dev) + 1) *
dev->prot_length);
- memset(buf, 0xff, unit_size);
ret = fd_do_prot_fill(dev, 0, dev->transport->get_blocks(dev) + 1,
buf, unit_size);
vfree(buf);