Tracing Reservation Keys

The following script can be used to trace reservation keys sent in the PERSISTENT RESERVE OUT command to any path associated with a particular LU.

#!/usr/sbin/dtrace -qs
/*
 * Explanation of predicate expressions:
 *  * 0x5f is an opcode of PERSISTENT RESERVE OUT
 *  * tracing on pHCI level only, i.e. addr_path must be set
 *  * DATA OUT buffer must be mapped to a kernel virtual memory
 *  * Sanity check for the data buffer size
 *  * Specification of the logical unit GUID
 */
scsi:::cmd-request
/(args[1]->cdb_data[0] == 0x5f) &&
 (args[0]->addr_path != "NULL") &&
 args[2]->data_mapped &&
 (args[2]->data_size >= 16) &&
 (args[0]->addr_dev == "g600144f0ecf10e000000562915af0001")/
{
      printf("%s#%d:%s\n", args[0]->addr_ctrl,
          args[0]->addr_ctrl_inst, args[0]->addr_path);

      printf("Service Action: %02x\n",
          args[1]->cdb_data[1] & 0x1f);

      printf("Reservation Key: ");
          tracemem(&args[2]->data_ptr[0], 8);

      printf("SA Reservation Key: ");
          tracemem(&args[2]->data_ptr[8], 8);

          printf("\n\n");
}