lkml.org 
[lkml]   [2018]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/6] rhashtable: support guaranteed successful insertion.
On Tue, Mar 27, 2018 at 10:33:04AM +1100, NeilBrown wrote:
> The current rhashtable will fail an insertion if the hashtable
> it "too full", one of:
> - table already has 2^31 elements (-E2BIG)
> - a max_size was specified and table already has that
> many elements (rounded up to power of 2) (-E2BIG)
> - a single chain has more than 16 elements (-EBUSY)
> - table has more elements than the current table size,
> and allocating a new table fails (-ENOMEM)
> - a new page needed to be allocated for a nested table,
> and the memory allocation failed (-ENOMEM).
>
> A traditional hash table does not have a concept of "too full", and
> insertion only fails if the key already exists. Many users of hash
> tables have separate means of limiting the total number of entries,
> and are not susceptible to an attack which could cause unusually large
> hash chains. For those users, the need to check for errors when
> inserting objects to an rhashtable is an unnecessary burden and hence
> a potential source of bugs (as these failures are likely to be rare).

Did you actually encounter an insertion failure? The current code
should never fail an insertion until you actually run ouf memory.
That is unless you're using rhashtable when you should be using
rhlist instead.

Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

\
 
 \ /
  Last update: 2018-03-27 17:56    [W:0.140 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site