Skip to content

Commit

Permalink
feat(udev): drop AZURE_LUN_CALCULATION_BY_NSID_ENABLED option
Browse files Browse the repository at this point in the history
Given that this is guaranteed to be supported for Linux OS VMs,
drop the conditional.  This saves us from having to generate the
the final udev rules as well, so remove that logic as well.

Consolidate the two udev rule lines that deal with the data disk
while here.  No change of behavior, but with the shorter line length
it seems reasonable to streamline it.

Signed-off-by: Chris Patterson <[email protected]>
  • Loading branch information
cjp256 committed Jul 31, 2024
1 parent 9138ab7 commit 5e8b06d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 39 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ obj-*
/build/
/debian/
/src/version.h
/udev/80-azure-nvme.rules
/out/
15 changes: 1 addition & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,14 @@ add_executable(azure-nvme-id src/main.c)
set(AZURE_NVME_ID_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/sbin")
set(UDEV_RULES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d" CACHE PATH "udev rules.d installation directory")

option(AZURE_LUN_CALCULATION_BY_NSID_ENABLED "Enable fallback \"LUN\" calculation via NSID" ON)
if(AZURE_LUN_CALCULATION_BY_NSID_ENABLED)
set(AZURE_LUN_CALCULATION_BY_NSID_ENABLED 1)
else()
set(AZURE_LUN_CALCULATION_BY_NSID_ENABLED 0)
endif()

configure_file(
"${PROJECT_SOURCE_DIR}/udev/80-azure-nvme.rules.in"
"${PROJECT_BINARY_DIR}/udev/80-azure-nvme.rules"
@ONLY
)

configure_file(
"${CMAKE_SOURCE_DIR}/src/version.h.in"
"${CMAKE_SOURCE_DIR}/src/version.h"
@ONLY
)

install(TARGETS azure-nvme-id DESTINATION ${AZURE_NVME_ID_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/udev/80-azure-nvme.rules DESTINATION ${UDEV_RULES_INSTALL_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/udev/80-azure-nvme.rules DESTINATION ${UDEV_RULES_INSTALL_DIR})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
Expand Down
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,6 @@ To run in udev mode:
DEVNAME=/dev/nvme0n1 azure-nvme-id --udev
```

### Enabling LUN Calculation by Namespace Identifier (Default)

The "LUN" configured by the user for data disks can be computed by the namespace identifier for "MSFT NVMe Accelerator v1.0" controllers.

This is currently enabled by default to support cases where there is no identification information available in the vendor-specific field of Identify Namespace data structure.

It can be explicitly enabled by passing AZURE_LUN_CALCULATION_BY_NSID_ENABLED=1 to cmake:

```
cmake -DAZURE_LUN_CALCULATION_BY_NSID_ENABLED=1 .
```

## Disabling LUN Calculation by Namespace Identifier

Pass AZURE_LUN_CALCULATION_BY_NSID_ENABLED=0 to cmake:

```
cmake -DAZURE_LUN_CALCULATION_BY_NSID_ENABLED=0 .
```

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down
6 changes: 2 additions & 4 deletions udev/80-azure-nvme.rules.in → udev/80-azure-nvme.rules
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ ATTRS{nsid}=="?*", ENV{AZURE_NVME_TYPE}="local"
GOTO="azure_nvme_start"

LABEL="azure_nvme_remote_start"
ATTRS{nsid}=="?*", ENV{AZURE_LUN_CALCULATION_BY_NSID_ENABLED}="@AZURE_LUN_CALCULATION_BY_NSID_ENABLED@"
ENV{AZURE_LUN_CALCULATION_BY_NSID_ENABLED}=="1", ATTRS{nsid}=="1", ENV{AZURE_NVME_TYPE}="os", GOTO="azure_nvme_start"
ENV{AZURE_LUN_CALCULATION_BY_NSID_ENABLED}=="1", ATTRS{nsid}=="?*", ENV{AZURE_NVME_TYPE}="data"
ENV{AZURE_LUN_CALCULATION_BY_NSID_ENABLED}=="1", ENV{AZURE_NVME_TYPE}=="data", ATTRS{nsid}=="?*", PROGRAM="/bin/sh -ec 'echo $$((%s{nsid}-2))'", ENV{AZURE_NVME_LUN}="$result"
ATTRS{nsid}=="1", ENV{AZURE_NVME_TYPE}="os", GOTO="azure_nvme_start"
ATTRS{nsid}=="?*", ENV{AZURE_NVME_TYPE}="data", PROGRAM="/bin/sh -ec 'echo $$((%s{nsid}-2))'", ENV{AZURE_NVME_LUN}="$result"
GOTO="azure_nvme_start"

LABEL="azure_nvme_start"
Expand Down

0 comments on commit 5e8b06d

Please sign in to comment.