Skip to content

Commit 80dcd0c

Browse files
Sagi GrimbergNicholas Bellinger
authored andcommitted
Target/file: place escape values for protection information format
No need to actually compute protection information when formatting Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 19f9361 commit 80dcd0c

1 file changed

Lines changed: 1 addition & 39 deletions

File tree

‎drivers/target/target_core_file.c‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -854,36 +854,15 @@ static int fd_init_prot(struct se_device *dev)
854854
return 0;
855855
}
856856

857-
static void fd_init_format_buf(struct se_device *dev, unsigned char *buf,
858-
u32 unit_size, u32 *ref_tag, u16 app_tag,
859-
bool inc_reftag)
860-
{
861-
unsigned char *p = buf;
862-
int i;
863-
864-
for (i = 0; i < unit_size; i += dev->prot_length) {
865-
*((u16 *)&p[0]) = 0xffff;
866-
*((__be16 *)&p[2]) = cpu_to_be16(app_tag);
867-
*((__be32 *)&p[4]) = cpu_to_be32(*ref_tag);
868-
869-
if (inc_reftag)
870-
(*ref_tag)++;
871-
872-
p += dev->prot_length;
873-
}
874-
}
875-
876857
static int fd_format_prot(struct se_device *dev)
877858
{
878859
struct fd_dev *fd_dev = FD_DEV(dev);
879860
struct file *prot_fd = fd_dev->fd_prot_file;
880861
sector_t prot_length, prot;
881862
unsigned char *buf;
882863
loff_t pos = 0;
883-
u32 ref_tag = 0;
884864
int unit_size = FDBD_FORMAT_UNIT_SIZE * dev->dev_attrib.block_size;
885865
int rc, ret = 0, size, len;
886-
bool inc_reftag = false;
887866

888867
if (!dev->dev_attrib.pi_prot_type) {
889868
pr_err("Unable to format_prot while pi_prot_type == 0\n");
@@ -894,37 +873,20 @@ static int fd_format_prot(struct se_device *dev)
894873
return -ENODEV;
895874
}
896875

897-
switch (dev->dev_attrib.pi_prot_type) {
898-
case TARGET_DIF_TYPE3_PROT:
899-
ref_tag = 0xffffffff;
900-
break;
901-
case TARGET_DIF_TYPE2_PROT:
902-
case TARGET_DIF_TYPE1_PROT:
903-
inc_reftag = true;
904-
break;
905-
default:
906-
break;
907-
}
908-
909876
buf = vzalloc(unit_size);
910877
if (!buf) {
911878
pr_err("Unable to allocate FILEIO prot buf\n");
912879
return -ENOMEM;
913880
}
914-
915881
prot_length = (dev->transport->get_blocks(dev) + 1) * dev->prot_length;
916882
size = prot_length;
917883

918884
pr_debug("Using FILEIO prot_length: %llu\n",
919885
(unsigned long long)prot_length);
920886

887+
memset(buf, 0xff, unit_size);
921888
for (prot = 0; prot < prot_length; prot += unit_size) {
922-
923-
fd_init_format_buf(dev, buf, unit_size, &ref_tag, 0xffff,
924-
inc_reftag);
925-
926889
len = min(unit_size, size);
927-
928890
rc = kernel_write(prot_fd, buf, len, pos);
929891
if (rc != len) {
930892
pr_err("vfs_write to prot file failed: %d\n", rc);

0 commit comments

Comments
 (0)