Skip to content

Commit

Permalink
Merge pull request rockstor#2345 from phillxnet/2330_centralise_devic…
Browse files Browse the repository at this point in the history
…e_serial_rejection_system

Centralise device serial rejection system rockstor#2330
  • Loading branch information
phillxnet authored Jan 10, 2022
2 parents 66fc998 + 48e147b commit f10beb9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,12 @@ var Disk = Backbone.Model.extend({
isSerialUsable: function() {
// Simple disk serial validator to return true unless the given disk
// serial number looks fake or untrustworthy.
// In the case of a repeat or missing serial scan_disks() will use a
// For repeat, missing, or known fake serials scan_disks() will use a
// placeholder of fake-serial-<uuid4> so look for this signature text.
var diskSerial = this.get('serial');
if (diskSerial.substring(0, 12) == 'fake-serial-') {
return false;
}
// Observed in a 4 bay ORICO USB 3.0 enclosure that obfuscated all it's
// disk serial numbers and replaced them with '000000000000'.
// 152D00539000 pertains to USB ID 152d:0567 JMS567 based device
if (diskSerial == '000000000000' || diskSerial == '152D00539000') {
return false;
}
return true;
},
// Using the disk.role system we can filter drives on their usability.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
{{/if}}
</td>
<td>
{{#checkSerialStatus this.serial this.name}}
{{#checkSerialStatus this.serial}}
<div class="alert alert-danger"><h4>Warning! Disk unusable as pool member - serial number is not legitimate or unique.</h4>Disk names may change unfavourably upon reboot leading to inadvertent drive reallocation and potential data loss. This error is caused by the source of these disks such as your Hypervisor or SAN.
Please ensure that disks are provided with unique serial numbers before proceeding further.
See our <a href="http://rockstor.com/docs/quickstart.html#minimum-system-requirements" target="_blank">Minimum system requirements</a> for VMware config.</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,11 @@ AddPoolView = Backbone.View.extend({
function isSerialUsable(diskSerialNumber) {
// Simple disk serial validator to return true unless the given disk
// serial number looks fake or untrustworthy.
// In the case of a repeat or missing serial scan_disks() will use a
// For repeat, missing, or known fake serials scan_disks() will use a
// placeholder of fake-serial-<uuid4> so look for this signature text.
if (diskSerialNumber.substring(0, 12) == 'fake-serial-') {
return false;
}
// Observed in a 4 bay ORICO USB 3.0 enclosure that obfuscated all it's
// disk serial numbers and replaced them with '000000000000'.
// 152D00539000 pertains to USB ID 152d:0567 JMS567 based device
if (diskSerialNumber == '000000000000' || diskSerialNumber == '152D00539000') {
return false;
}
return true;
}

Expand Down
12 changes: 4 additions & 8 deletions src/rockstor/storageadmin/static/storageadmin/js/views/disks.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,11 @@ DisksView = RockstorLayoutView.extend({
return false;
});

Handlebars.registerHelper('checkSerialStatus', function (serial, diskName, opts) {
// We need to warn the user if any of the following exist as they
// are all unreliable. The fake-serial- is generated by scan_disks
Handlebars.registerHelper('checkSerialStatus', function (serial, opts) {
// Warn the user of unreliable device serial numbers.
// The "fake-serial-*" serial is generated by scan_disks
// and should have overwritten any null, empty or diskName serial.
// 152D00539000 pertains to USB ID 152d:0567 JMS567 based device
// @todo should be possible to remove null, '' and diskName soon.
if (serial == null || serial == '' || serial == diskName ||
serial.substring(0, 12) == 'fake-serial-' ||
serial == '000000000000' || serial == '152D00539000') {
if (serial.substring(0, 12) == 'fake-serial-') {
return opts.fn(this);
}
return opts.inverse(this);
Expand Down
28 changes: 26 additions & 2 deletions src/rockstor/system/osi.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@
"sunrpc",
]

# We watch for the following known fake serial numbers.
# When found we substitute for "fake-serial-uuid" where uuid is a random uuid4.
# Our Web-UI js then flags these drives as unusable.
#
# See "Device Management in Rockstor", subtitle: 'Rockstor's Serial Obsession'.
# https://forum.rockstor.com/t/device-management-in-rockstor/1768
#
# Known models of external enclosures that obfuscate 'real' drive serials with fakes.
# N.B. All host drives within these enclosures appear to have identical serials.
# 8 bay Orico unit (JMS567 controller) - forum member outicnz report.
# 4 bay ORICO USB 3.0 - forum member beaglenz report.
# 5 bay ORICO USB 3.0 - forum member Brett_Abela report.
# 4 bay Mediasonic USB 3.0 & eSATA (HFD1-SU3S2) - GitHub user azilber report.
# 5 bay no-name USB - forum member Miyuki report.

EXCLUDED_SERIAL_NUMS = [
"",
"000000000000", # Many reports of multiple Orico models.
"152D00539000", # USB ID 152d:0567 a JMS567 based device.
"0123456789ABCDEF", # No-name USB external multi-bay.
]

Disk = collections.namedtuple(
"Disk",
"name model serial size transport vendor "
Expand Down Expand Up @@ -550,9 +572,11 @@ def scan_disks(min_size, test_mode=False):
# reset the bdev_flag as we are only interested in devices
# listed directly after a bdev anyway.
bdev_flag = False
if dmap["SERIAL"] == "" or (dmap["SERIAL"] in serials_seen):
if (dmap["SERIAL"] in EXCLUDED_SERIAL_NUMS) or (
dmap["SERIAL"] in serials_seen
):
# No serial number still or its a repeat. Overwrite drive
# serial entry in dmap with fake-serial- + uuid4 See
# serial entry in dmap with fake-serial- + uuid4. See js/template/
# disk/disks_table.jst for a use of this flag mechanism.
# Previously we did dmap['SERIAL'] = dmap['NAME'] which is less
# robust as it can itself produce duplicate serial numbers.
Expand Down

0 comments on commit f10beb9

Please sign in to comment.