Ticket #726: 0001-Add-persistent-option-p-to-wcreorder-on-off.patch

File 0001-Add-persistent-option-p-to-wcreorder-on-off.patch, 5.7 KB (added by Song Liu, 8 years ago)
  • trunk/smartmontools/ataprint.cpp

    From 33a848aa2dcda073e0b07a315eae9e4a121727a7 Mon Sep 17 00:00:00 2001
    From: Song Liu <songliubraving@fb.com>
    Date: Thu, 11 Aug 2016 16:34:17 -0700
    Subject: [PATCH] Add persistent option ",p" to wcreorder,on|off
    
    Similar to wcache-sct, we can make wcreorder setting persistent
    through SCT Feature Control.
    ---
     trunk/smartmontools/ataprint.cpp  | 5 +++--
     trunk/smartmontools/ataprint.h    | 2 ++
     trunk/smartmontools/smartctl.8.in | 4 ++--
     trunk/smartmontools/smartctl.cpp  | 8 +++++---
     4 files changed, 12 insertions(+), 7 deletions(-)
    
    diff --git a/trunk/smartmontools/ataprint.cpp b/trunk/smartmontools/ataprint.cpp
    index aa81cf0..134635b 100644
    a b int ataPrintMain (ata_device * device, const ata_print_options & options)  
    29412941      pout("Write cache reordering %sable failed: SCT not supported if ATA Security is LOCKED\n",
    29422942        (enable ? "en" : "dis"));
    29432943    else if (ataGetSetSCTWriteCacheReordering(device,
    2944                enable, false /*persistent*/, true /*set*/) < 0) {
     2944               enable, options.sct_wcache_reorder_set_pers, true /*set*/) < 0) {
    29452945      pout("Write cache reordering %sable failed: %s\n", (enable ? "en" : "dis"), device->get_errmsg());
    29462946      returnval |= FAILSMART;
    29472947    }
    29482948    else
    2949       pout("Write cache reordering %sabled\n", (enable ? "en" : "dis"));
     2949      pout("Write cache reordering %sabled (%s)\n", (enable ? "en" : "dis"),
     2950           (options.sct_wcache_reorder_set_pers ? "persistent" : "volatile"));
    29502951  }
    29512952
    29522953  // Enable/Disable write cache in SCT
  • trunk/smartmontools/ataprint.h

    diff --git a/trunk/smartmontools/ataprint.h b/trunk/smartmontools/ataprint.h
    index 230ce22..d3459db 100644
    a b struct ata_print_options  
    108108  int set_wcache; // disable(-1), enable(1) write cache
    109109  bool sct_wcache_reorder_get; // print write cache reordering status
    110110  int sct_wcache_reorder_set; // disable(-1), enable(1) write cache reordering
     111  bool sct_wcache_reorder_set_pers;
    111112  bool sct_wcache_sct_get; // print SCT Feature Control of write cache status
    112113  int sct_wcache_sct_set; // determined by ata set features command(1), force enable(2), force disable(3)
    113114  bool sct_wcache_sct_set_pers; // persistent or volatile
    struct ata_print_options  
    149150      get_security(false), set_security_freeze(false),
    150151      get_wcache(false), set_wcache(0),
    151152      sct_wcache_reorder_get(false), sct_wcache_reorder_set(0),
     153      sct_wcache_reorder_set_pers(false),
    152154      sct_wcache_sct_get(false), sct_wcache_sct_set(0),
    153155      sct_wcache_sct_set_pers(false)
    154156    { }
  • trunk/smartmontools/smartctl.8.in

    diff --git a/trunk/smartmontools/smartctl.8.in b/trunk/smartmontools/smartctl.8.in
    index 372f331..34db906 100644
    a b the setting of wcache[,on|off] is ignored by the drive. SCT Feature Control  
    957957usually sets write cache as "Controlled by ATA" by default. If ´,p´ is
    958958specified, the setting is preserved across power cycles.
    959959
    960 .I wcreorder[,on|off]
     960.I wcreorder[,on|off[,p]]
    961961\- [ATA only] Gets/sets Write Cache Reordering.
    962962If it is disabled (off), disk write scheduling is executed on a
    963963first-in-first-out (FIFO) basis. If Write Cache Reordering is enabled (on),
    then disk write scheduling may be reordered by the drive. If write cache is  
    965965disabled, the current Write Cache Reordering state is remembered but has
    966966no effect on non-cached writes, which are always written in the order received.
    967967The state of Write Cache Reordering has no effect on either NCQ or LCQ queued
    968 commands.
     968commands. If ´,p´ is specified, the setting is preserved across power cycles.
    969969
    970970.I rcache[,on|off]
    971971\- [SCSI only] Gets/sets the \'Read Cache Disable\' (RCE) bit.
  • trunk/smartmontools/smartctl.cpp

    diff --git a/trunk/smartmontools/smartctl.cpp b/trunk/smartmontools/smartctl.cpp
    index 7660b9c..129b041 100644
    a b static void Usage()  
    123123"  -s NAME[,VALUE], --set=NAME[,VALUE]\n"
    124124"        Enable/disable/change device setting: aam,[N|off], apm,[N|off],\n"
    125125"        lookahead,[on|off], security-freeze, standby,[N|off|now],\n"
    126 "        wcache,[on|off], rcache,[on|off], wcreorder,[on|off]\n"
     126"        wcache,[on|off], rcache,[on|off], wcreorder,[on|off[,p]]\n"
    127127"        wcache-sct,[ata|on|off[,p]]\n\n"
    128128  );
    129129  printf(
    static std::string getvalidarglist(int opt)  
    225225    return "aam, apm, lookahead, security, wcache, rcache, wcreorder, wcache-sct";
    226226  case opt_set:
    227227    return "aam,[N|off], apm,[N|off], lookahead,[on|off], security-freeze, "
    228            "standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off], "
     228           "standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off[,p]], "
    229229           "wcache-sct,[ata|on|off[,p]]";
    230230  case 's':
    231231    return getvalidarglist(opt_smart)+", "+getvalidarglist(opt_set);
    static const char * parse_options(int argc, char** argv,  
    872872              len2 = strlen(optarg+n2) - 2;
    873873
    874874              // the ,p option only works for set of SCT Feature Control command
    875               if (strcmp(name, "wcache-sct") != 0)
     875              if (strcmp(name, "wcache-sct") != 0 &&
     876                  strcmp(name, "wcreorder") != 0)
    876877                badarg = true;
    877878            }
    878879            on  = !strncmp(optarg+n2, "on", len2);
    static const char * parse_options(int argc, char** argv,  
    924925              badarg = true;
    925926          }
    926927          else if (!strcmp(name, "wcreorder")) {
     928            ataopts.sct_wcache_reorder_set_pers = persistent;
    927929            if (get) {
    928930              ataopts.sct_wcache_reorder_get = true;
    929931            }