Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions tests/nvme_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import subprocess
import sys
import unittest
import time

from nvme_test_logger import TestNVMeLogger

Expand Down Expand Up @@ -407,12 +408,18 @@ def attach_ns(self, ctrl_id, nsid):
err = subprocess.call(attach_ns_cmd,
shell=True,
stdout=subprocess.DEVNULL)
if err == 0:
# enumerate new namespace block device
self.nvme_reset_ctrl()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me confirm below.
Before the controller reset done before the blkdev checking but is it not necessary to be done for the changes as waiting for 5 seconds instead? (I am not sure the reason for the reset on the current TP.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reset should not be necessary. When the device announce a new namespace (AEN) the driver exposes the new namespace (new block device) to userspace and announces it via udev. We could obviously also try to listen to udev and test this interface as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Thank you for your explaining.

# check if new namespace block device exists
err = 0 if stat.S_ISBLK(os.stat(self.ctrl + "n" + str(nsid)).st_mode) else 1
return err
if err != 0:
return err

# Try to find block device for 5 seconds
device_path = f"{self.ctrl}n{str(nsid)}"
stop_time = time.time() + 5
while time.time() < stop_time:
if os.path.exists(device_path) and stat.S_ISBLK(os.stat(device_path).st_mode):
return 0
time.sleep(0.1)

return 1

def detach_ns(self, ctrl_id, nsid):
""" Wrapper for detaching the namespace.
Expand Down