Reset a Zoned SCSI Write Pointer Safely with sg_reset_wp
You will send the SCSI RESET WRITE POINTER command to a zoned storage device, either for one zone or for all open and full zones. This is a state-changing storage operation: use it only when you understand the device's zone state and have stopped writers that could race with it. Allow about 15 minutes for a prepared maintenance task, longer if you first need to identify the correct device.
The route
Jump straight to the step you need, or tick off Done means at the end.
The examples use sg_reset_wp from the installed sg3-utils package, version 1.46-3ubuntu4. The utility reports its own version as 1.14 20191220. The local manual page is dated May 2018, while the package is newer, so the installed help output is included where it gives a useful confirmation.
1. Confirm the utility and its syntax
Start with an unprivileged check. It does not contact a storage device or change any zone:
$ command -v sg_reset_wp
/usr/bin/sg_reset_wp
$ dpkg-query -W -f='${Package} ${Version}\n' sg3-utils
sg3-utils 1.46-3ubuntu4
$ sg_reset_wp --version
version: 1.14 20191220
Read the usage text before preparing a command:
$ sg_reset_wp --help
Usage: sg_reset_wp [--all] [--count=ZC] [--help] [--verbose]
[--version] [--zone=ID] DEVICE
...
The required shape is sg_reset_wp --zone=ZONE_START_LBA DEVICE or sg_reset_wp --all DEVICE. The device argument is normally a SCSI generic pass-through path such as /dev/sg3, but the correct path is host-specific. Do not guess it from an example.
2. Identify the target before touching it
Map the device path to the storage system's own inventory. Check the path and permissions without opening it for a write-pointer reset:
$ DEVICE='/dev/sg3'
$ ls -l "$DEVICE"
crw-rw---- 1 root disk 21, 3 ... /dev/sg3
Replace /dev/sg3 with the path you have verified from your SCSI host, enclosure or multipath documentation. A generic device number is not an identity. Check the serial number, enclosure slot and logical unit with your normal inventory tools, and make sure the path is not a different disk after a reboot or device rescan.
Checkpoint: write down the intended device and zone start LBA before proceeding. If you cannot explain why that exact path and LBA are correct, stop here. Do not use sudo as a substitute for identification.
3. Stop competing writers
A reset write pointer changes the device's zoned write state. Stop the application, filesystem workload, RAID operation or other process that can write to the target. Follow the storage vendor's maintenance procedure for flushing or quiescing outstanding I/O. This utility does not provide a rollback, and the manpage does not promise to preserve data written after the pointer state becomes inconsistent.
Elevated privileges may be required to open the device. Use them only after the target and maintenance window are confirmed:
$ sudo sg_reset_wp --help
Usage: sg_reset_wp [--all] [--count=ZC] [--help] [--verbose]
[--version] [--zone=ID] DEVICE
...
This is still only a help check. It does not establish that the chosen account can safely operate the device, nor does it prove that the device supports RESET WRITE POINTER.
4. Reset one zone by its starting LBA
For a single zone, pass the zone's starting logical block address to --zone. The option calls the value a zone ID, but the value is specifically a zone start LBA, not an arbitrary block inside the zone:
$ sudo sg_reset_wp --zone=1048576 "$DEVICE"
$ status=$?
$ printf 'sg_reset_wp exit status: %s\n' "$status"
sg_reset_wp exit status: 0
A zero exit status means that sg_reset_wp completed successfully according to its documented exit status. It does not tell you that the LBA was the zone you intended, or that an application has stopped writing. The device's response and your subsequent zone report are the meaningful operational checks.
Hexadecimal is also accepted: prefix the value with 0x or add a trailing h. Use one notation consistently in a runbook:
$ sudo sg_reset_wp --zone=0x100000 "$DEVICE"
$ printf 'sg_reset_wp exit status: %s\n' "$?"
sg_reset_wp exit status: 0
Do not run both examples for the same maintenance event. Each successful command sends another reset request.
5. Reset all open and full zones only when required
The --all option sets the command's ALL field. It requests a reset operation for all open zones and full zones. That is a wider change than resetting one identified zone:
$ sudo sg_reset_wp --all "$DEVICE"
$ printf 'sg_reset_wp exit status: %s\n' "$?"
sg_reset_wp exit status: 0
When --all is present, any --zone=ID value is ignored. Keep the command simple so a review cannot miss its scope. Do not use --all as a diagnostic probe, and do not put it in an automated recovery loop unless the storage design explicitly requires that behaviour.
6. Understand the zone count and diagnostic options
--count=ZC places a zone count in the command. The accepted range is 0 through 65535 inclusive. The installed help reports a default of 0. The local manual describes where the value is placed, but does not define a safe policy for choosing a non-zero count for your device, so do not add it merely because it is available:
$ sudo sg_reset_wp --zone=1048576 --count=1 "$DEVICE"
$ printf 'sg_reset_wp exit status: %s\n' "$?"
sg_reset_wp exit status: 0
Use a non-zero count only when the device or storage procedure documents the required command semantics. --verbose increases diagnostic output and can help when investigating a failure, but it does not make a failed command safe to repeat:
$ sudo sg_reset_wp --verbose --zone=1048576 "$DEVICE"
$ printf 'sg_reset_wp exit status: %s\n' "$?"
sg_reset_wp exit status: 0
7. Verify the result and recover from failure
After the command returns, use the device's zone-reporting procedure to inspect the affected zone or zones. Confirm the write pointer and zone condition against the storage standard, vendor documentation or the output of the appropriate sg3-utils reporting utility. A successful process exit alone is not enough for a production recovery record.
If the command returns non-zero, preserve the diagnostic output and stop competing writers. Do not immediately retry with --all, a different LBA or a larger count. Check that the device is the intended zoned target, that the account can access its SCSI pass-through interface, and that the device supports the command. The manpage directs readers to sg3_utils(8) for the detailed exit-status conventions; the exact sense data from the device is relevant to diagnosis.
There is no undo command in sg_reset_wp. Recovery means following the storage device's documented procedure, restoring the application or filesystem's consistent state from its own recovery method, and checking the zone report before allowing writers to resume. Keep the original diagnostics with the maintenance record.
Done means
- The installed command and package version were confirmed.
- The device path was matched to the intended serial number, slot and logical unit.
- Competing writers were stopped before the state-changing command.
- Either one verified zone start LBA or the deliberately chosen
--allscope was used. - The exit status and post-command zone report were recorded.
- A failure was investigated without blindly retrying or widening the reset scope.