~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.raring-precise.backport

« back to all changes in this revision

Viewing changes to modules/linux/vmci/common/vmciHashtable.c

  • Committer: Package Import Robot
  • Author(s): Nate Muench
  • Date: 2012-01-23 16:09:45 UTC
  • mfrom: (1.4.6) (2.4.26 sid)
  • Revision ID: package-import@ubuntu.com-20120123160945-b6s0r1vkcovucpf3
Tags: 2011.12.20-562307-0ubuntu1
* Merge latest upstream git tag. Fixes building on Precise
  (LP: #898289, LP: #905612)

* Items merged from Debian unstable:
  - debian/control:
    + open-vm-tools recommends open-vm-dkms. (LP: #598933)
    + open-vm-tools now suggests open-vm-toolbox. (LP: #604998)
  (From 2011.08.21-471295-1 release)
  - Updating maintainer and uploaders fields.
  - Removing vcs fields.
  - Removing references to Daniel's old email address.
  - Updating years in copyright file.
  - Updating to standards version 3.9.2.
  - Updating to debhelper version 8.
  - Switching to source format 3.0 (quilt).
  - Removing manual chrpath setting.
  - Removing exclusion from plugins from debhelper shlibs.
  - Rediffing kvers.patch.
  (From 2011.09.23-491607-1 release)
  - Marking binary architecture-dependend packages as linux and kfreebsd
  only.
  - Removing liburiparser-dev from build-depends as upstream dropped
  unity support.
  - Building with libproc-dev on amd64 again.
  - Dropping disabling of dnet support.
  (From 2011.09.23-491607-2 release)
  - Adding doxygen to build-depends for api documentation.
  - Adding libcunit1-dev to build-depends for test suites.
  - Minimizing rules file.
  - Adding open-vm-tools-dev package, containing only the api
    documentation for now.
  (From 2011.09.23-491607-3 release)
  - Sorting overrides in rules alphabetically.
  - Compacting copyright file.
  - Adding udev rule to set timeout for vmware scsi devices
  (From 2011.12.20-562307-1 release)
  - Adding patch to correct typo in upstreams dkms configuration

* Remaining Changes:
  - Remove Stable part of version numbering.
  - debian folder:
    + Re-added open-vm-dkms.postinst & open-vm-dkms.prerm.
      * Allows dkms modules to compile upon installation.
  - debian/control:
    + Re-add open-vm-source and make into a transitional package
      for open-vm-toolbox.
    + Return dependancies that were moved to open-vm-tools back to
      open-vm-toolbox.
  - debian/rules and debian/open-vm-toolbox.lintian-overrides:
    + Make vmware-user-suid-wrapper suid-root
  - debian/rules:
    + Added CFLAGS field with -Wno-deprecated-declarations
      * Will suppress issues with glib 2.31 or later.
    + Add line to copy vmware-xdg-detect-de into place.
    + Install vmware-user.desktop through toolbox package.
  - debian/open-vm-tools.init:
    + Re-add 'modprobe [-r] vmblock'.
    + Add 'modprobe [-r] vmxnet'.
      * Incase it's not loaded during boot.
    + Remove and re-add pcnet32 module
      * Will be done before (remove) and after (readd) vmxnet module
        is added.
      * If vmxnet doesn't exist (aka modules fail to build), pcnet32 can be
        still used for network connectivity.
      * Workaround until a better fix can be done.
  - Re-add gnome-session to debian/local/xautostart.conf
  - Manpages removed (from debian/manpages):
    + vmmemctl.9
    + vmxnet3.9
    + Remove references to manpages that have been removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
#define LGPFX "VMCIHashTable: "
41
41
 
42
 
#if defined(VMKERNEL)
43
 
   /* VMK doesn't need BH locks, so use lower ranks. */
44
 
#  define VMCIHashTableInitLock(_l, _n) \
45
 
   VMCI_InitLock(_l, _n, VMCI_LOCK_RANK_HIGHEST)
46
 
#  define VMCIHashTableGrabLock(_l, _f)      VMCI_GrabLock(_l, _f)
47
 
#  define VMCIHashTableReleaseLock(_l, _f)   VMCI_ReleaseLock(_l, _f)
48
 
#else // VMKERNEL
49
 
#  define VMCIHashTableInitLock(_l, _n) \
50
 
   VMCI_InitLock(_l, _n, VMCI_LOCK_RANK_HIGH_BH)
51
 
#  define VMCIHashTableGrabLock(_l, _f)      VMCI_GrabLock_BH(_l, _f)
52
 
#  define VMCIHashTableReleaseLock(_l, _f)   VMCI_ReleaseLock_BH(_l, _f)
53
 
#endif // VMKERNEL
54
 
 
55
42
#define VMCI_HASHTABLE_HASH(_h, _sz) \
56
43
   VMCI_HashId(VMCI_HANDLE_TO_RESOURCE_ID(_h), (_sz))
57
44
 
58
 
 
59
45
static int HashTableUnlinkEntry(VMCIHashTable *table, VMCIHashEntry *entry);
60
46
static Bool VMCIHashTableEntryExistsLocked(VMCIHashTable *table,
61
47
                                           VMCIHandle handle);
66
52
 *
67
53
 *  VMCIHashTable_Create --
68
54
 *     XXX Factor out the hashtable code to be shared amongst host and guest.
69
 
 * 
 
55
 *
70
56
 *  Result:
71
57
 *     None.
72
 
 *     
 
58
 *
73
59
 *------------------------------------------------------------------------------
74
60
 */
75
61
 
90
76
   }
91
77
   memset(table->entries, 0, sizeof *table->entries * size);
92
78
   table->size = size;
93
 
 
94
 
   if (VMCIHashTableInitLock(&table->lock, "VMCIHashTableLock") < VMCI_SUCCESS) {
 
79
   if (VMCI_InitLock(&table->lock, "VMCIHashTableLock",
 
80
                     VMCI_LOCK_RANK_HASHTABLE) < VMCI_SUCCESS) {
95
81
      VMCI_FreeKernelMem(table->entries, sizeof *table->entries * size);
96
82
      VMCI_FreeKernelMem(table, sizeof *table);
97
83
      return NULL;
109
95
 *     We rely on the module ref count to insure that no one is accessing any
110
96
 *     hash table entries at this point in time. Hence we should be able to just
111
97
 *     remove all entries from the hash table.
112
 
 * 
 
98
 *
113
99
 *  Result:
114
100
 *     None.
115
 
 *     
 
101
 *
116
102
 *------------------------------------------------------------------------------
117
103
 */
118
104
 
127
113
 
128
114
   ASSERT(table);
129
115
 
130
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
116
   VMCI_GrabLock_BH(&table->lock, &flags);
131
117
#if 0
132
118
#ifdef VMX86_DEBUG
133
119
   for (i = 0; i < table->size; i++) {
145
131
#endif
146
132
   VMCI_FreeKernelMem(table->entries, sizeof *table->entries * table->size);
147
133
   table->entries = NULL;
148
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
134
   VMCI_ReleaseLock_BH(&table->lock, flags);
149
135
   VMCI_CleanupLock(&table->lock);
150
136
   VMCI_FreeKernelMem(table, sizeof *table);
151
137
}
156
142
 *
157
143
 *  VMCIHashTable_InitEntry --
158
144
 *     Initializes a hash entry;
159
 
 * 
 
145
 *
160
146
 *  Result:
161
147
 *     None.
162
 
 *     
 
148
 *
163
149
 *------------------------------------------------------------------------------
164
150
 */
165
151
void
194
180
   ASSERT(entry);
195
181
   ASSERT(table);
196
182
 
197
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
183
   VMCI_GrabLock_BH(&table->lock, &flags);
198
184
 
199
185
   /* Check if creation of a new hashtable entry is allowed. */
200
186
   if (!VMCI_CanCreate()) {
201
 
      VMCIHashTableReleaseLock(&table->lock, flags);
 
187
      VMCI_ReleaseLock_BH(&table->lock, flags);
202
188
      return VMCI_ERROR_UNAVAILABLE;
203
189
   }
204
190
 
205
191
   if (VMCIHashTableEntryExistsLocked(table, entry->handle)) {
206
192
      VMCI_DEBUG_LOG(4, (LGPFX"Entry (handle=0x%x:0x%x) already exists.\n",
207
193
                         entry->handle.context, entry->handle.resource));
208
 
      VMCIHashTableReleaseLock(&table->lock, flags);
 
194
      VMCI_ReleaseLock_BH(&table->lock, flags);
209
195
      return VMCI_ERROR_DUPLICATE_ENTRY;
210
196
   }
211
197
 
216
202
   entry->refCount++;
217
203
   entry->next = table->entries[idx];
218
204
   table->entries[idx] = entry;
219
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
205
   VMCI_ReleaseLock_BH(&table->lock, flags);
220
206
 
221
207
   return VMCI_SUCCESS;
222
208
}
226
212
 *------------------------------------------------------------------------------
227
213
 *
228
214
 *  VMCIHashTable_RemoveEntry --
229
 
 *     XXX Factor out the hashtable code to shared amongst API and perhaps 
 
215
 *     XXX Factor out the hashtable code to shared amongst API and perhaps
230
216
 *     host and guest.
231
217
 *
232
218
 *  Result:
233
219
 *     None.
234
 
 *     
 
220
 *
235
221
 *------------------------------------------------------------------------------
236
222
 */
237
223
 
245
231
   ASSERT(table);
246
232
   ASSERT(entry);
247
233
 
248
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
234
   VMCI_GrabLock_BH(&table->lock, &flags);
249
235
 
250
236
   /* First unlink the entry. */
251
237
   result = HashTableUnlinkEntry(table, entry);
262
248
   }
263
249
 
264
250
  done:
265
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
251
   VMCI_ReleaseLock_BH(&table->lock, flags);
266
252
 
267
253
   return result;
268
254
}
272
258
 *------------------------------------------------------------------------------
273
259
 *
274
260
 *  VMCIHashTableGetEntryLocked --
275
 
 *     
 
261
 *
276
262
 *       Looks up an entry in the hash table, that is already locked.
277
263
 *
278
264
 *  Result:
281
267
 *
282
268
 *  Side effects:
283
269
 *       The reference count of the returned element is increased.
284
 
 *     
 
270
 *
285
271
 *------------------------------------------------------------------------------
286
272
 */
287
273
 
323
309
 *------------------------------------------------------------------------------
324
310
 *
325
311
 *  VMCIHashTable_GetEntry --
326
 
 *     XXX Factor out the hashtable code to shared amongst API and perhaps 
 
312
 *     XXX Factor out the hashtable code to shared amongst API and perhaps
327
313
 *     host and guest.
328
314
 *
329
315
 *  Result:
330
316
 *     None.
331
 
 *     
 
317
 *
332
318
 *------------------------------------------------------------------------------
333
319
 */
334
320
 
345
331
 
346
332
   ASSERT(table);
347
333
 
348
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
334
   VMCI_GrabLock_BH(&table->lock, &flags);
349
335
   entry = VMCIHashTableGetEntryLocked(table, handle);
350
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
336
   VMCI_ReleaseLock_BH(&table->lock, flags);
351
337
 
352
338
   return entry;
353
339
}
380
366
   ASSERT(table);
381
367
   ASSERT(entry);
382
368
 
383
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
369
   VMCI_GrabLock_BH(&table->lock, &flags);
384
370
   entry->refCount++;
385
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
371
   VMCI_ReleaseLock_BH(&table->lock, flags);
386
372
}
387
373
 
388
374
 
439
425
 *------------------------------------------------------------------------------
440
426
 *
441
427
 *  VMCIHashTable_ReleaseEntry --
442
 
 *     XXX Factor out the hashtable code to shared amongst API and perhaps 
 
428
 *     XXX Factor out the hashtable code to shared amongst API and perhaps
443
429
 *     host and guest.
444
430
 *
445
431
 *  Result:
446
432
 *     None.
447
 
 *     
 
433
 *
448
434
 *------------------------------------------------------------------------------
449
435
 */
450
436
 
456
442
   int result;
457
443
 
458
444
   ASSERT(table);
459
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
445
   VMCI_GrabLock_BH(&table->lock, &flags);
460
446
   result = VMCIHashTableReleaseEntryLocked(table, entry);
461
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
447
   VMCI_ReleaseLock_BH(&table->lock, flags);
462
448
 
463
449
   return result;
464
450
}
489
475
 
490
476
   ASSERT(table);
491
477
 
492
 
   VMCIHashTableGrabLock(&table->lock, &flags);
 
478
   VMCI_GrabLock_BH(&table->lock, &flags);
493
479
   exists = VMCIHashTableEntryExistsLocked(table, handle);
494
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
480
   VMCI_ReleaseLock_BH(&table->lock, flags);
495
481
 
496
482
   return exists;
497
483
}
501
487
 *------------------------------------------------------------------------------
502
488
 *
503
489
 *  VMCIHashTableEntryExistsLocked --
504
 
 *     
 
490
 *
505
491
 *     Unlocked version of VMCIHashTable_EntryExists.
506
492
 *
507
493
 *  Result:
547
533
 *------------------------------------------------------------------------------
548
534
 *
549
535
 *  HashTableUnlinkEntry --
550
 
 *     XXX Factor out the hashtable code to shared amongst API and perhaps 
 
536
 *     XXX Factor out the hashtable code to shared amongst API and perhaps
551
537
 *     host and guest.
552
538
 *     Assumes caller holds table lock.
553
539
 *
554
540
 *  Result:
555
541
 *     None.
556
 
 *     
 
542
 *
557
543
 *------------------------------------------------------------------------------
558
544
 */
559
545
 
560
546
static int
561
547
HashTableUnlinkEntry(VMCIHashTable *table, // IN
562
 
                     VMCIHashEntry *entry) // IN 
 
548
                     VMCIHashEntry *entry) // IN
563
549
{
564
550
   int result;
565
551
   VMCIHashEntry *prev, *cur;
616
602
{
617
603
   VMCILockFlags flags;
618
604
   ASSERT(table);
619
 
   VMCIHashTableGrabLock(&table->lock, &flags);
620
 
   VMCIHashTableReleaseLock(&table->lock, flags);
 
605
   VMCI_GrabLock_BH(&table->lock, &flags);
 
606
   VMCI_ReleaseLock_BH(&table->lock, flags);
621
607
}