diff options
author | Andy Grover <agrover@redhat.com> | 2013-05-16 13:40:57 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-06-14 03:04:39 -0400 |
commit | 0607decdca51ee33c2caae288a44a82455149b51 (patch) | |
tree | 3082fda83ec853e388a848ef534e7acbb1f0f053 /drivers/target/target_core_pr.c | |
parent | 1f070cc2ac7783afd0174c29dc59d2b4fac72646 (diff) |
target: Simplify metadata handling when clearing aptpl metadata
Simpler to just set buf in update_and_write_aptpl(), rather than passing
down to ____core_scsi3_update_aptpl_buf().
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_pr.c')
-rw-r--r-- | drivers/target/target_core_pr.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index c797e79dc5c1..2e10014c8c33 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -1834,8 +1834,7 @@ out: | |||
1834 | static int __core_scsi3_update_aptpl_buf( | 1834 | static int __core_scsi3_update_aptpl_buf( |
1835 | struct se_device *dev, | 1835 | struct se_device *dev, |
1836 | unsigned char *buf, | 1836 | unsigned char *buf, |
1837 | u32 pr_aptpl_buf_len, | 1837 | u32 pr_aptpl_buf_len) |
1838 | int clear_aptpl_metadata) | ||
1839 | { | 1838 | { |
1840 | struct se_lun *lun; | 1839 | struct se_lun *lun; |
1841 | struct se_portal_group *tpg; | 1840 | struct se_portal_group *tpg; |
@@ -1845,14 +1844,7 @@ static int __core_scsi3_update_aptpl_buf( | |||
1845 | int reg_count = 0; | 1844 | int reg_count = 0; |
1846 | 1845 | ||
1847 | memset(buf, 0, pr_aptpl_buf_len); | 1846 | memset(buf, 0, pr_aptpl_buf_len); |
1848 | /* | 1847 | |
1849 | * Called to clear metadata once APTPL has been deactivated. | ||
1850 | */ | ||
1851 | if (clear_aptpl_metadata) { | ||
1852 | snprintf(buf, pr_aptpl_buf_len, | ||
1853 | "No Registrations or Reservations\n"); | ||
1854 | return 0; | ||
1855 | } | ||
1856 | /* | 1848 | /* |
1857 | * Walk the registration list.. | 1849 | * Walk the registration list.. |
1858 | */ | 1850 | */ |
@@ -1937,14 +1929,12 @@ static int __core_scsi3_update_aptpl_buf( | |||
1937 | static int core_scsi3_update_aptpl_buf( | 1929 | static int core_scsi3_update_aptpl_buf( |
1938 | struct se_device *dev, | 1930 | struct se_device *dev, |
1939 | unsigned char *buf, | 1931 | unsigned char *buf, |
1940 | u32 pr_aptpl_buf_len, | 1932 | u32 pr_aptpl_buf_len) |
1941 | int clear_aptpl_metadata) | ||
1942 | { | 1933 | { |
1943 | int ret; | 1934 | int ret; |
1944 | 1935 | ||
1945 | spin_lock(&dev->dev_reservation_lock); | 1936 | spin_lock(&dev->dev_reservation_lock); |
1946 | ret = __core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len, | 1937 | ret = __core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len); |
1947 | clear_aptpl_metadata); | ||
1948 | spin_unlock(&dev->dev_reservation_lock); | 1938 | spin_unlock(&dev->dev_reservation_lock); |
1949 | 1939 | ||
1950 | return ret; | 1940 | return ret; |
@@ -1997,32 +1987,21 @@ core_scsi3_update_and_write_aptpl(struct se_device *dev, unsigned char *in_buf, | |||
1997 | u32 in_pr_aptpl_buf_len) | 1987 | u32 in_pr_aptpl_buf_len) |
1998 | { | 1988 | { |
1999 | unsigned char null_buf[64], *buf; | 1989 | unsigned char null_buf[64], *buf; |
2000 | u32 pr_aptpl_buf_len; | ||
2001 | int clear_aptpl_metadata = 0; | ||
2002 | int ret; | 1990 | int ret; |
2003 | 1991 | ||
2004 | /* | 1992 | /* |
2005 | * Can be called with a NULL pointer from PROUT service action CLEAR | 1993 | * Can be called with a NULL pointer from PROUT service action CLEAR |
2006 | */ | 1994 | */ |
2007 | if (!in_buf) { | 1995 | if (!in_buf) { |
2008 | memset(null_buf, 0, 64); | 1996 | snprintf(null_buf, 64, "No Registrations or Reservations\n"); |
2009 | buf = &null_buf[0]; | 1997 | buf = null_buf; |
2010 | /* | ||
2011 | * This will clear the APTPL metadata to: | ||
2012 | * "No Registrations or Reservations" status | ||
2013 | */ | ||
2014 | pr_aptpl_buf_len = 64; | ||
2015 | clear_aptpl_metadata = 1; | ||
2016 | } else { | 1998 | } else { |
1999 | ret = core_scsi3_update_aptpl_buf(dev, in_buf, in_pr_aptpl_buf_len); | ||
2000 | if (ret != 0) | ||
2001 | return ret; | ||
2017 | buf = in_buf; | 2002 | buf = in_buf; |
2018 | pr_aptpl_buf_len = in_pr_aptpl_buf_len; | ||
2019 | } | 2003 | } |
2020 | 2004 | ||
2021 | ret = core_scsi3_update_aptpl_buf(dev, buf, pr_aptpl_buf_len, | ||
2022 | clear_aptpl_metadata); | ||
2023 | if (ret != 0) | ||
2024 | return ret; | ||
2025 | |||
2026 | /* | 2005 | /* |
2027 | * __core_scsi3_write_aptpl_to_file() will call strlen() | 2006 | * __core_scsi3_write_aptpl_to_file() will call strlen() |
2028 | * on the passed buf to determine pr_aptpl_buf_len. | 2007 | * on the passed buf to determine pr_aptpl_buf_len. |