blktests: use global configfs variable
PATCH 1/1 blktests: use global configfs variable
This patch introduces a global variable to hold the configfs nvmet path. Now we don't need repetitive local variables to hold the path and testcases can use the newly introduced variable if needed.
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
--- common/nvme | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
common/nvme +11 -16
@@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +NVMET_CFS="/sys/kernel/config/nvmet/" + _test_dev_is_nvme() { if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then SKIP_REASON="$TEST_DEV is not a NVMe device"
@@ -27,33 +29,29 @@ _test_dev_is_nvme() { _create_nvmet_port() { local trtype="$1" - local nvmet_cfs="/sys/kernel/config/nvmet/" - local port for ((port = 0; ; port++)); do - if [[ ! -e "${nvmet_cfs}/${port}" ]]; then + if [[ ! -e "${NVMET_CFS}/${port}" ]]; then break fi done - mkdir "${nvmet_cfs}/ports/${port}" - echo "${trtype}" > "${nvmet_cfs}/ports/${port}/addr_trtype" + mkdir "${NVMET_CFS}/ports/${port}" + echo "${trtype}" > "${NVMET_CFS}/ports/${port}/addr_trtype" echo "${port}" } _remove_nvmet_port() { local port="$1" - local nvmet_cfs="/sys/kernel/config/nvmet/" - rmdir "${nvmet_cfs}/ports/${port}" + rmdir "${NVMET_CFS}/ports/${port}" } _create_nvmet_subsystem() { local nvmet_subsystem="$1" local blkdev="$2" local uuid="00000000-0000-0000-0000-000000000000" - local nvmet_cfs="/sys/kernel/config/nvmet/" - local cfs_path="${nvmet_cfs}/subsystems/${nvmet_subsystem}" + local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" if [[ $# -eq 3 ]]; then uuid="$3"
@@ -69,8 +67,7 @@ _create_nvmet_subsystem() { _remove_nvmet_subsystem() { local nvmet_subsystem="$1" - local nvmet_cfs="/sys/kernel/config/nvmet/" - local cfs_path="${nvmet_cfs}/subsystems/${nvmet_subsystem}" + local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" echo 0 > "${cfs_path}/namespaces/1/enable" rmdir "${cfs_path}/namespaces/1/"
@@ -80,16 +77,14 @@ _remove_nvmet_subsystem() { _add_nvmet_subsys_to_port() { local port="$1" local nvmet_subsystem="$2" - local nvmet_cfs="/sys/kernel/config/nvmet/" - ln -s "${nvmet_cfs}/subsystems/${nvmet_subsystem}" \ - "${nvmet_cfs}/ports/${port}/subsystems/${nvmet_subsystem}" + ln -s "${NVMET_CFS}/subsystems/${nvmet_subsystem}" \ + "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}" } _remove_nvmet_subsystem_from_port() { local port="$1" local nvmet_subsystem="$2" - local nvmet_cfs="/sys/kernel/config/nvmet/" - rm "${nvmet_cfs}/ports/${port}/subsystems/${nvmet_subsystem}" + rm "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}" }
Signature · 1 line
2.9.5
PATCH 1/1 blktests: use global configfs variable
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 1/1 blktests: use global configfs variable
In reply to Chaitanya KulkarniQuoted 6 lines · Chaitanya Kulkarni
This patch introduces a global variable to hold the configfs nvmet path. Now we don't need repetitive local variables to hold the path and testcases can use the newly introduced variable if needed.
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
Thanks, Chaitanya, that's a good cleanup. Applied.