]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Merge https://github.com/linux-nvme/nvme-cli
authorJeff Lien <jeff.lien@wdc.com>
Fri, 13 Sep 2019 19:12:17 +0000 (14:12 -0500)
committerJeff Lien <jeff.lien@wdc.com>
Fri, 13 Sep 2019 19:12:17 +0000 (14:12 -0500)
1  2 
plugins/wdc/wdc-nvme.c

index dd5393cb2d3b78ff73dfeca541bb2e794e8c3ed3,e6bda6c2f9d2be13f50b333e11fafa5ce5505a0f..71eb522a57d1c3a814a2653feb0ee965391d500e
@@@ -1417,49 -1384,20 +1417,49 @@@ static int wdc_do_cap_dui(int fd, char 
                                fprintf(stderr, "%s: Failed to open output file %s: %s!\n",
                                                __func__, file, strerror(errno));
                                ret = output;
 -                              goto out;
 +                              goto free_mem;
                        }
  
 -                      /* write the telemetry and log headers into the dump_file */
 -                      err = write(output, (void *)log_hdr, WDC_NVME_CAP_DUI_HEADER_SIZE);
 -                      if (err != WDC_NVME_CAP_DUI_HEADER_SIZE) {
 -                              fprintf(stderr, "%s:  Failed to flush header data to file!\n", __func__);
 -                              goto free_mem;
 +                      if (file_size == 0) {
 +                              /* write the telemetry and log headers into the dump_file */
 +                              err = write(output, (void *)log_hdr, WDC_NVME_CAP_DUI_HEADER_SIZE);
 +                              if (err != WDC_NVME_CAP_DUI_HEADER_SIZE) {
 +                                      fprintf(stderr, "%s:  Failed to flush header data to file!\n", __func__);
 +                                      goto free_mem;
 +                              }
 +
 +                              log_size -= WDC_NVME_CAP_DUI_HEADER_SIZE;
 +                              curr_data_offset = WDC_NVME_CAP_DUI_HEADER_SIZE;
 +                      } else {
 +                              /* Write the DUI data based on the passed in file size */
 +                              if ((offset + file_size) > total_size)
 +                                      log_size = min((total_size - offset), file_size);
 +                              else
 +                                      log_size = min(total_size, file_size);
 +
 +                              if (verbose)
 +                                      fprintf(stderr, "%s: INFO : WDC : Offset 0x%llx, file size 0x%llx, total size 0x%llx, log size 0x%llx\n",
 +                                              __func__, offset, file_size, total_size, log_size);
 +
 +                              curr_data_offset = 0;
 +
 +                              if (offset == 0) {
 +                                      /* write the telemetry and log headers into the dump_file */
 +                                      err = write(output, (void *)log_hdr, WDC_NVME_CAP_DUI_HEADER_SIZE);
 +                                      if (err != WDC_NVME_CAP_DUI_HEADER_SIZE) {
 +                                              fprintf(stderr, "%s:  Failed to flush header data to file!\n", __func__);
 +                                              goto free_mem;
 +                                      }
 +
 +                                      log_size -= WDC_NVME_CAP_DUI_HEADER_SIZE;
 +                                      curr_data_offset = WDC_NVME_CAP_DUI_HEADER_SIZE;
 +                              } else {
 +                                      curr_data_offset = offset;
 +                              }
                        }
  
 -                      log_size -= WDC_NVME_CAP_DUI_HEADER_SIZE;
 -                      curr_data_offset = WDC_NVME_CAP_DUI_HEADER_SIZE;
                        i = 0;
-                       buffer_addr = (__u64)(uintptr_t)dump_data;
+                       buffer_addr = dump_data;
  
                        for(; log_size > 0; log_size -= xfer_size_long) {
                                xfer_size_long = min(xfer_size_long, log_size);