Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sagi Grimberg and committed by
Nicholas Bellinger
80dcd0c1 19f9361a

+1 -39
+1 -39
drivers/target/target_core_file.c
··· 854 854 return 0; 855 855 } 856 856 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 - 876 857 static int fd_format_prot(struct se_device *dev) 877 858 { 878 859 struct fd_dev *fd_dev = FD_DEV(dev); ··· 861 880 sector_t prot_length, prot; 862 881 unsigned char *buf; 863 882 loff_t pos = 0; 864 - u32 ref_tag = 0; 865 883 int unit_size = FDBD_FORMAT_UNIT_SIZE * dev->dev_attrib.block_size; 866 884 int rc, ret = 0, size, len; 867 - bool inc_reftag = false; 868 885 869 886 if (!dev->dev_attrib.pi_prot_type) { 870 887 pr_err("Unable to format_prot while pi_prot_type == 0\n"); ··· 873 894 return -ENODEV; 874 895 } 875 896 876 - switch (dev->dev_attrib.pi_prot_type) { 877 - case TARGET_DIF_TYPE3_PROT: 878 - ref_tag = 0xffffffff; 879 - break; 880 - case TARGET_DIF_TYPE2_PROT: 881 - case TARGET_DIF_TYPE1_PROT: 882 - inc_reftag = true; 883 - break; 884 - default: 885 - break; 886 - } 887 - 888 897 buf = vzalloc(unit_size); 889 898 if (!buf) { 890 899 pr_err("Unable to allocate FILEIO prot buf\n"); 891 900 return -ENOMEM; 892 901 } 893 - 894 902 prot_length = (dev->transport->get_blocks(dev) + 1) * dev->prot_length; 895 903 size = prot_length; 896 904 897 905 pr_debug("Using FILEIO prot_length: %llu\n", 898 906 (unsigned long long)prot_length); 899 907 908 + memset(buf, 0xff, unit_size); 900 909 for (prot = 0; prot < prot_length; prot += unit_size) { 901 - 902 - fd_init_format_buf(dev, buf, unit_size, &ref_tag, 0xffff, 903 - inc_reftag); 904 - 905 910 len = min(unit_size, size); 906 - 907 911 rc = kernel_write(prot_fd, buf, len, pos); 908 912 if (rc != len) { 909 913 pr_err("vfs_write to prot file failed: %d\n", rc);