Received: by 10.213.65.68 with SMTP id h4csp1085210imn; Tue, 27 Mar 2018 14:35:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/sQ8C2B57VE8s1Ho2P2bMff4t6OcducyAb6VbgaCUGZwildclztdYIMIxzheuoIoF/sLV4 X-Received: by 10.101.86.141 with SMTP id v13mr621107pgs.353.1522186538993; Tue, 27 Mar 2018 14:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522186538; cv=none; d=google.com; s=arc-20160816; b=aoNrpfqFKXmOKcRg8xYrAQ6+6BjERKUpCfb8fcz4D6eUJzf8vzKFEGXVJAbdSk/B2/ EJXqzJWiKT+GwgVi7XOUdfC6rC0hiQVxYT2e5TOzS6/4/QFofMDDjudNYBSu6lV8feN2 H8GqB426yRygfys8F9FgM7SQipZP/VvZeGkrR0s98b3kN78eh1Sjoz1zkgUTRsSD3S7Z +Rtb1IeOtmCwbR63zZiLBF7th/+Xb01UW0XmbTf9DAsilkssXxMe0ZmLLnUbmeSBDIFB ZVRBmUdKl4qGiVUpW2srkwpNRGxHu+soBrmlAtMxQAGaKLKFvvf+XQtgAIEGWqhFhtH4 omkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:references :in-reply-to:subject:cc:date:to:from:arc-authentication-results; bh=rFuRJTCQITqEK9+X6qlq/FnSD199RflR6q+3/hsKsoE=; b=B4hcVVwXCbgx3/b4XUBCKZlhJgGtY9VXniDkmfv19hcE0V12zm/ecy4Ib0hyIuFQE6 BsxNxGwnBhB4DafWct9IF97WHmPoWJ/41emlINNKCXfUNEspXufWIcrsW/2QtVsVJ6tw EsMY2cfL3i9dH4tN3T9QWblWjyFOauoZyUoYopomyosFob5gHGokXb7PfProPh85AHmE s0U+QxRw3RbinNbBJUPNAMVnNQJ8wsEstN6afVq+mxpLJrUgDVD08w4O7MduJV6GKDry tacnx1H/WJUAHLcolbarMU9ZUS7F6ebOxxlnqo63qrNjL0LXvb7GbDwc2Rh3ZpPzu8Q/ 6SvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h188si1439572pgc.330.2018.03.27.14.35.23; Tue, 27 Mar 2018 14:35:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752008AbeC0Veb (ORCPT + 99 others); Tue, 27 Mar 2018 17:34:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:54022 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbeC0Ve3 (ORCPT ); Tue, 27 Mar 2018 17:34:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6049DACCD; Tue, 27 Mar 2018 21:34:28 +0000 (UTC) From: NeilBrown To: Herbert Xu Date: Wed, 28 Mar 2018 08:34:19 +1100 Cc: Thomas Graf , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 5/6] rhashtable: support guaranteed successful insertion. In-Reply-To: <20180327155610.GD14001@gondor.apana.org.au> References: <152210688405.11435.13010923693146415942.stgit@noble> <152210718434.11435.6551477417902631683.stgit@noble> <20180327155610.GD14001@gondor.apana.org.au> Message-ID: <87y3id42zo.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Tue, Mar 27 2018, Herbert Xu wrote: > 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). >>=20 >> 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. It is easy to get an -EBUSY insertion failure when .disable_count is enabled, and I did get that. Blindly propagating that up caused lustre to get terribly confused - not too surprising really. Even if I didn't seem errors in practive, if the interface can return an error, then I need to check for the error and really should test that handling each error works correctly. It is much easier to write reliable code when errors cannot happen, so I'd rather have that option. Thanks, NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlq6uNsACgkQOeye3VZi gbkoRA/9FR1eT6z4NUj1YbDVyUfZUKROfMiIk3s5TFS0yrgk6LSxqvpJshjgEw5z SwBj4s0u7Rb6cwJzYDLrF6bGN6Plh3gMgeftofjyn7u0DjS70JsgN6gOe6QGEX9R f7285QHAH1m3YFJn402Y+J0BdgSPL8ZZLZ1QY4bIfPKBOd3I/JTBCfMUwjy2/Utk 78/ul8cdFyt0xzNCb4zs0GZTB8VdCk3rLzaYm/IyUGP8BVGw4HAqOhCmnMu0lcNv 4/8NzMOoc2IJOh+kF8B5fMs8bDknvqoiX3DYWuAQuRJJGDm2YQoS2lhQXk2DFdhc PXdqLPtQAdM3nywIKWWXgc3SwuHkCSiSw+irYVmFpuJ7wwS8rToWOH+9bgdk1Htu F+8shb/MVq/GqlkSLMsiIm3XbuC1uXsHzJK2kjA/fUufXEAVtKdPVDjS4TQKTRjM XaHYiH9DNXoQc4E6MRRhawgen2vMkbtEwdD/SjqBjNo2uln/mRFfhy/ya9uI36Rl l/sOYn4ymSkT63VyV46LfT+rMALoqv3IA9KS1Hx1BPpW1PT69Ry8zlbsorK/f50a I0AFsurfKxRRBDU72VpTUwgP3tpVgs4xHQcrbqI53uIMyg3s5rDerYw7WSteLnyk sf0Vo/edHOMGP0W5eLn5XheVxcUgGkEfgkSF+ENKHGbfkJuVTb0= =5Aze -----END PGP SIGNATURE----- --=-=-=--