Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blktests: use global configfs variable
@ 2018-05-08  5:45 Chaitanya Kulkarni
  2018-05-08  6:38 ` Johannes Thumshirn
  2018-05-14 20:07 ` Omar Sandoval
  0 siblings, 2 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2018-05-08  5:45 UTC (permalink / raw)


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(-)

diff --git a/common/nvme b/common/nvme
index c6718f0..797e6db 100644
--- a/common/nvme
+++ b/common/nvme
@@ -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}"
 }
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] blktests: use global configfs variable
@ 2018-05-07 20:04 Chaitanya Kulkarni
  2018-05-07 20:41 ` chaitany kulkarni
  0 siblings, 1 reply; 5+ messages in thread
From: Chaitanya Kulkarni @ 2018-05-07 20:04 UTC (permalink / raw)


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(-)

diff --git a/common/nvme b/common/nvme
index c6718f0..797e6db 100644
--- a/common/nvme
+++ b/common/nvme
@@ -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_CFG}/${port}" ]]; then
 			break
 		fi
 	done
 
-	mkdir "${nvmet_cfs}/ports/${port}"
-	echo "${trtype}" > "${nvmet_cfs}/ports/${port}/addr_trtype"
+	mkdir "${NVMET_CFG}/ports/${port}"
+	echo "${trtype}" > "${NVMET_CFG}/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_CFG}/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_CFG}/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_CFG}/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_CFG}/subsystems/${nvmet_subsystem}" \
+		"${NVMET_CFG}/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_CFG}/ports/${port}/subsystems/${nvmet_subsystem}"
 }
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-14 20:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-08  5:45 [PATCH] blktests: use global configfs variable Chaitanya Kulkarni
2018-05-08  6:38 ` Johannes Thumshirn
2018-05-14 20:07 ` Omar Sandoval
  -- strict thread matches above, loose matches on Subject: below --
2018-05-07 20:04 Chaitanya Kulkarni
2018-05-07 20:41 ` chaitany kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox