From 081c39036fa0e714169cb518c3065723b7623c3d Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 13 Jul 2007 15:02:20 +0000 Subject: [PATCH] Patch from Nathan Bullock. We are using OFED target machines to export a large number of disks, many of which are just NULLIO disks, but we have noticed that VPD numbers have a significant tendency to conflict. For example if we name one disk abc12 and another abc21 they will end up with the same VPD. We are using a quick, slightly hackish way to solve this, by just creating a random hash for each ascii value and then rotating that hash based on the position of the character in the name. If you would like here is our changes. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@149 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/README | 2 + scst/src/dev_handlers/scst_vdisk.c | 74 +++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/scst/README b/scst/README index ae5b524d2..9917ca1f2 100644 --- a/scst/README +++ b/scst/README @@ -635,4 +635,6 @@ Thanks to: * Alessandro Premoli for fixes + * Nathan Bullock for fixes. + Vladislav Bolkhovitin , http://scst.sourceforge.net diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 03a79fcaa..81d5940b1 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -95,6 +95,73 @@ static struct scst_proc_log vdisk_proc_local_trace_tbl[] = #define VDISK_PROC_HELP "help" +static unsigned int random_values[256] = { + 9862592UL, 3744545211UL, 2348289082UL, 4036111983UL, + 435574201UL, 3110343764UL, 2383055570UL, 1826499182UL, + 4076766377UL, 1549935812UL, 3696752161UL, 1200276050UL, + 3878162706UL, 1783530428UL, 2291072214UL, 125807985UL, + 3407668966UL, 547437109UL, 3961389597UL, 969093968UL, + 56006179UL, 2591023451UL, 1849465UL, 1614540336UL, + 3699757935UL, 479961779UL, 3768703953UL, 2529621525UL, + 4157893312UL, 3673555386UL, 4091110867UL, 2193909423UL, + 2800464448UL, 3052113233UL, 450394455UL, 3424338713UL, + 2113709130UL, 4082064373UL, 3708640918UL, 3841182218UL, + 3141803315UL, 1032476030UL, 1166423150UL, 1169646901UL, + 2686611738UL, 575517645UL, 2829331065UL, 1351103339UL, + 2856560215UL, 2402488288UL, 867847666UL, 8524618UL, + 704790297UL, 2228765657UL, 231508411UL, 1425523814UL, + 2146764591UL, 1287631730UL, 4142687914UL, 3879884598UL, + 729945311UL, 310596427UL, 2263511876UL, 1983091134UL, + 3500916580UL, 1642490324UL, 3858376049UL, 695342182UL, + 780528366UL, 1372613640UL, 1100993200UL, 1314818946UL, + 572029783UL, 3775573540UL, 776262915UL, 2684520905UL, + 1007252738UL, 3505856396UL, 1974886670UL, 3115856627UL, + 4194842288UL, 2135793908UL, 3566210707UL, 7929775UL, + 1321130213UL, 2627281746UL, 3587067247UL, 2025159890UL, + 2587032000UL, 3098513342UL, 3289360258UL, 130594898UL, + 2258149812UL, 2275857755UL, 3966929942UL, 1521739999UL, + 4191192765UL, 958953550UL, 4153558347UL, 1011030335UL, + 524382185UL, 4099757640UL, 498828115UL, 2396978754UL, + 328688935UL, 826399828UL, 3174103611UL, 3921966365UL, + 2187456284UL, 2631406787UL, 3930669674UL, 4282803915UL, + 1776755417UL, 374959755UL, 2483763076UL, 844956392UL, + 2209187588UL, 3647277868UL, 291047860UL, 3485867047UL, + 2223103546UL, 2526736133UL, 3153407604UL, 3828961796UL, + 3355731910UL, 2322269798UL, 2752144379UL, 519897942UL, + 3430536488UL, 1801511593UL, 1953975728UL, 3286944283UL, + 1511612621UL, 1050133852UL, 409321604UL, 1037601109UL, + 3352316843UL, 4198371381UL, 617863284UL, 994672213UL, + 1540735436UL, 2337363549UL, 1242368492UL, 665473059UL, + 2330728163UL, 3443103219UL, 2291025133UL, 3420108120UL, + 2663305280UL, 1608969839UL, 2278959931UL, 1389747794UL, + 2226946970UL, 2131266900UL, 3856979144UL, 1894169043UL, + 2692697628UL, 3797290626UL, 3248126844UL, 3922786277UL, + 343705271UL, 3739749888UL, 2191310783UL, 2962488787UL, + 4119364141UL, 1403351302UL, 2984008923UL, 3822407178UL, + 1932139782UL, 2323869332UL, 2793574182UL, 1852626483UL, + 2722460269UL, 1136097522UL, 1005121083UL, 1805201184UL, + 2212824936UL, 2979547931UL, 4133075915UL, 2585731003UL, + 2431626071UL, 134370235UL, 3763236829UL, 1171434827UL, + 2251806994UL, 1289341038UL, 3616320525UL, 392218563UL, + 1544502546UL, 2993937212UL, 1957503701UL, 3579140080UL, + 4270846116UL, 2030149142UL, 1792286022UL, 366604999UL, + 2625579499UL, 790898158UL, 770833822UL, 815540197UL, + 2747711781UL, 3570468835UL, 3976195842UL, 1257621341UL, + 1198342980UL, 1860626190UL, 3247856686UL, 351473955UL, + 993440563UL, 340807146UL, 1041994520UL, 3573925241UL, + 480246395UL, 2104806831UL, 1020782793UL, 3362132583UL, + 2272911358UL, 3440096248UL, 2356596804UL, 259492703UL, + 3899500740UL, 252071876UL, 2177024041UL, 4284810959UL, + 2775999888UL, 2653420445UL, 2876046047UL, 1025771859UL, + 1994475651UL, 3564987377UL, 4112956647UL, 1821511719UL, + 3113447247UL, 455315102UL, 1585273189UL, 2311494568UL, + 774051541UL, 1898115372UL, 2637499516UL, 247231365UL, + 1475014417UL, 803585727UL, 3911097303UL, 1714292230UL, + 476579326UL, 2496900974UL, 3397613314UL, 341202244UL, + 807790202UL, 4221326173UL, 499979741UL, 1301488547UL, + 1056807896UL, 3525009458UL, 1174811641UL, 3049738746UL, +}; + struct scst_vdisk_dev { uint32_t block_size; uint64_t nblocks; @@ -995,7 +1062,12 @@ static void vdisk_exec_inquiry(struct scst_cmd *cmd) char dev_id_str[6]; for (dev_id_num = 0, i = 0; i < (int)strlen(virt_dev->name); i++) { - dev_id_num += virt_dev->name[i]; + unsigned int rv = random_values[(int)(virt_dev->name[i])]; + /* + * Device name maximum length = 16, + * do some rotating of the bits. + */ + dev_id_num ^= ((rv << i) | (rv >> (32 - i))); } len = scnprintf(dev_id_str, 6, "%d", dev_id_num); TRACE_DBG("num %d, str <%s>, len %d",