Month: March 2019

How to Disable Disk Write Caching in Ubuntu To Prevent Data Loss | UbuntuHandbook

Disk write cache is a feature provided by drive vendors to improve the performance of the disks.
This feature can result in data loss if there are sudden power outages.
It depends on the application to decide whether to enable disk write cache or not.
For SATA SSD drives the following commands can be used to enable and disable write caching.

To know write caching is enabled/disabled
hdparm -W /dev/sda

To enable write cache
hdparm -W 1 /dev/sda

To disable write cache
hdparm -W 0 /dev/sda

where, /dev/sda is example SATA SSD used.

You can get the details of the drive susing lsscsi command.

Source: How to Disable Disk Write Caching in Ubuntu To Prevent Data Loss | UbuntuHandbook

What are SCSI Reservations and SCSI Persistent Reservations?

SCSI reservations are used to gain access to a LUN by denying access to other initiators.

SCSI-2 reservation
Allows an initiator to reserve and release a SCSI device.
Done with SCSI reserve and release commands.
The release can happen when there is a SCSI bus reset. During error recoevry also SCSI Bus reset is performed..
Only works with single path.
SPC-2 supports both SCSI-2 and SCSI-3 reservations in a mutually exclusive way.
All subsequent SCSI persistent and SCSI-2 reservations will fail when already reserved via SCSI-2 reservation command.
SPC-3 deprecates classic reserve and release machanism over SCSI-3 method.

SCSI-3 reservation named persistent reservations.
Reservation is persistent across SCSI bus reset.
Done via SCSI Persist reserve OUT and IN commands.
supports reservations with multipath and multiple nodes accessing the same SCSI device.
uses the concept of registration and reservation.
Persistent reservations allow multiple clients(initiators) to communicate with a tracking multiple
initiator to target relationship called I_T nexus.
Actions performed are
-Initiator will register to target and creates a new registration key
-Initiator will read the existing registrations and reservations .
-Intiator can alter existing registrations.
-Initiator issues reserve actions to lock on a specific LUN
-Initiator releases the lock when done and releases the regostration also inf no more required.

How to reslve SCSI-2 reservation conflicts from a host?
Host can clear with a lun reset or target reset.

Warning: A target reset will abort all commands on all LUNs mapped to the initiator that issued this command.
It will also abort commands from other initiators to the LUNs that are accessed by the initiator from which
the abort was initiated.

Source: What are SCSI Reservations and SCSI Persistent Reservations?