diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2014-02-19 10:50:16 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-04-07 04:48:39 -0400 |
commit | 80dcd0c10482719bd9250b7d11bd5c360a02403a (patch) | |
tree | 3ae03f1b8a5a0c71e0fc2365a52aa8a5bac10537 /drivers/target | |
parent | 19f9361af7dfa0bb1f98c7619544ed71d2dded39 (diff) |
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>
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/target_core_file.c | 40 |
1 files changed, 1 insertions, 39 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index cf991a91a8a9..7d6cddaec525 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -854,25 +854,6 @@ static int fd_init_prot(struct se_device *dev) | |||
854 | return 0; | 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 | static int fd_format_prot(struct se_device *dev) | 857 | static int fd_format_prot(struct se_device *dev) |
877 | { | 858 | { |
878 | struct fd_dev *fd_dev = FD_DEV(dev); | 859 | struct fd_dev *fd_dev = FD_DEV(dev); |
@@ -880,10 +861,8 @@ static int fd_format_prot(struct se_device *dev) | |||
880 | sector_t prot_length, prot; | 861 | sector_t prot_length, prot; |
881 | unsigned char *buf; | 862 | unsigned char *buf; |
882 | loff_t pos = 0; | 863 | loff_t pos = 0; |
883 | u32 ref_tag = 0; | ||
884 | int unit_size = FDBD_FORMAT_UNIT_SIZE * dev->dev_attrib.block_size; | 864 | int unit_size = FDBD_FORMAT_UNIT_SIZE * dev->dev_attrib.block_size; |
885 | int rc, ret = 0, size, len; | 865 | int rc, ret = 0, size, len; |
886 | bool inc_reftag = false; | ||
887 | 866 | ||
888 | if (!dev->dev_attrib.pi_prot_type) { | 867 | if (!dev->dev_attrib.pi_prot_type) { |
889 | pr_err("Unable to format_prot while pi_prot_type == 0\n"); | 868 | 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) | |||
894 | return -ENODEV; | 873 | return -ENODEV; |
895 | } | 874 | } |
896 | 875 | ||
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 | |||
909 | buf = vzalloc(unit_size); | 876 | buf = vzalloc(unit_size); |
910 | if (!buf) { | 877 | if (!buf) { |
911 | pr_err("Unable to allocate FILEIO prot buf\n"); | 878 | pr_err("Unable to allocate FILEIO prot buf\n"); |
912 | return -ENOMEM; | 879 | return -ENOMEM; |
913 | } | 880 | } |
914 | |||
915 | prot_length = (dev->transport->get_blocks(dev) + 1) * dev->prot_length; | 881 | prot_length = (dev->transport->get_blocks(dev) + 1) * dev->prot_length; |
916 | size = prot_length; | 882 | size = prot_length; |
917 | 883 | ||
918 | pr_debug("Using FILEIO prot_length: %llu\n", | 884 | pr_debug("Using FILEIO prot_length: %llu\n", |
919 | (unsigned long long)prot_length); | 885 | (unsigned long long)prot_length); |
920 | 886 | ||
887 | memset(buf, 0xff, unit_size); | ||
921 | for (prot = 0; prot < prot_length; prot += unit_size) { | 888 | 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 | |||
926 | len = min(unit_size, size); | 889 | len = min(unit_size, size); |
927 | |||
928 | rc = kernel_write(prot_fd, buf, len, pos); | 890 | rc = kernel_write(prot_fd, buf, len, pos); |
929 | if (rc != len) { | 891 | if (rc != len) { |
930 | pr_err("vfs_write to prot file failed: %d\n", rc); | 892 | pr_err("vfs_write to prot file failed: %d\n", rc); |