Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3328728imu; Sun, 11 Nov 2018 12:29:27 -0800 (PST) X-Google-Smtp-Source: AJdET5cv+HbyZ/nm9Q62tOPzduSzVBRAoJbw2wFaBzLmIO6nJGG8zB3NmDbdMnwQakxNE1fdpADG X-Received: by 2002:a17:902:2849:: with SMTP id e67-v6mr17398846plb.269.1541968167236; Sun, 11 Nov 2018 12:29:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968167; cv=none; d=google.com; s=arc-20160816; b=G/GKrgqbeoxTqHGWRJShhZ89jyfr41LN8Mt3FhSUPQTibdyiGs2l+UnOspPNtutIuc eAvCoU5i0XlNo1lK8NrcbjYK+AWPbAc4+HJCSKP75mhcJxV9xmiYEhT/uYHjnn8x7cT3 sT+YK1fKOHOzZLbqy17lBKWMn/6up9MkoqSxDmVA0dLSIT/vugXbogkrdEex7PeecGsO eMPE/flbkQHw5gSSBZ5L3sbGmngwPPhSe6EcU6pk6w3bJzeMYSBvhCmiMXkYDICYvqFx mGoXl87NaXwRSEMrL1wGNgW5EdQwrWRA95k1hcg2yms4e1wsbdIZE1Wzak1dO+VqHMcm w+Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=YIsc/gpS4uDs7cKgHHBi8+J5Wbo+X+FZnHf00dmwfk0=; b=IoFyjCKE0HQOxFnB5A/xosR9rBod3iqIcrJfo2+nySOCsx6PJNW506eeIuZxOBP8Gg vAeeC7osydvcXvOZM6/r07BnSk9R0zSYtalmsp6SBUoo4EFWoZWbmhQO04lQTxYxAiQu NJRkxnW9EbhOXv0WSRHluedhAZbWtUDn4QUxE7T9a/5290hdzpJqEJUaQTxIxCfQya1y haJr2SMAgHSlXlEhD+hVrhppDmPUSl32uKEEkPtE2dKfbqnkmSXsNqdEzIetInaYdgI8 HHeOL5xuivgJv1D1DffkUAxIaSpb3aDsjAv2veN6SF2guw/+/fakD+fFoVVremmFujwJ iFnw== 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 p126si11836880pgp.529.2018.11.11.12.29.12; Sun, 11 Nov 2018 12:29:27 -0800 (PST) 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 S1731229AbeKLGSQ (ORCPT + 99 others); Mon, 12 Nov 2018 01:18:16 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50584 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730391AbeKLFsX (ORCPT ); Mon, 12 Nov 2018 00:48:23 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsi-0000l7-NC; Sun, 11 Nov 2018 19:58:52 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsZ-0001qZ-SR; Sun, 11 Nov 2018 19:58:43 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Mike Snitzer" , "Mikulas Patocka" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 329/366] dm bufio: drop the lock when doing GFP_NOIO allocation In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mikulas Patocka commit 41c73a49df31151f4ff868f28fe4f129f113fa2c upstream. If the first allocation attempt using GFP_NOWAIT fails, drop the lock and retry using GFP_NOIO allocation (lock is dropped because the allocation can take some time). Note that we won't do GFP_NOIO allocation when we loop for the second time, because the lock shouldn't be dropped between __wait_for_free_buffer and __get_unclaimed_buffer. Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Cc: Mikulas Patocka Signed-off-by: Ben Hutchings --- drivers/md/dm-bufio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -773,6 +773,7 @@ enum new_flag { static struct dm_buffer *__alloc_buffer_wait_no_callback(struct dm_bufio_client *c, enum new_flag nf) { struct dm_buffer *b; + bool tried_noio_alloc = false; /* * dm-bufio is resistant to allocation failures (it just keeps @@ -797,6 +798,15 @@ static struct dm_buffer *__alloc_buffer_ if (nf == NF_PREFETCH) return NULL; + if (dm_bufio_cache_size_latch != 1 && !tried_noio_alloc) { + dm_bufio_unlock(c); + b = alloc_buffer(c, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); + dm_bufio_lock(c); + if (b) + return b; + tried_noio_alloc = true; + } + if (!list_empty(&c->reserved_buffers)) { b = list_entry(c->reserved_buffers.next, struct dm_buffer, lru_list);