Do not fail when called on an invalid device
When calling smartctl on bcache devices, we will get a non-zero return code. In this case, we fail safe and do not enable a potentially unavailable feature. Additionally, other possible failures with device identification will be caught and safely handled this way. Change-Id: Ie10fb24cbfedf98c8bb53b710b95962579d3284e Closes-Bug: #1819652
This commit is contained in:
parent
37b1e7548b
commit
1e18c645e6
|
@ -211,9 +211,13 @@ def should_enable_discard(devices):
|
|||
if (device.startswith("/dev/nvme") or
|
||||
device.startswith("/dev/vd")):
|
||||
continue
|
||||
try:
|
||||
sata_3_or_less = is_sata30orless(device)
|
||||
except subprocess.CalledProcessError:
|
||||
sata_3_or_less = True
|
||||
if (device.startswith("/dev/") and
|
||||
os.path.exists(device) and
|
||||
is_sata30orless(device)):
|
||||
sata_3_or_less):
|
||||
discard_enable = False
|
||||
log("SSD Discard autodetection: {} is forcing discard off"
|
||||
"(sata <= 3.0)".format(device), level=WARNING)
|
||||
|
|
Loading…
Reference in New Issue