Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2010263imm; Tue, 10 Jul 2018 11:32:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfyEoZQDf8NDkS18fXrOyrhJR+8MNVo5rriCDoAeqBiAuOOAA22nFrBQSuIKPxAgF0MFqTx X-Received: by 2002:a63:1b5c:: with SMTP id b28-v6mr21608251pgm.204.1531247547590; Tue, 10 Jul 2018 11:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247547; cv=none; d=google.com; s=arc-20160816; b=Oft8srUBciH5lVssslm9TGcF9e9YEhID7pDoUJClIYfZABllnGbMeBndrAJmjyZeqi 7Ty8f1ihX7GggzoUYZ5eW8Y6T/VttgroM6SWSEuDNC0/VdsSHkLFZ85Nd45SBdY0EElj JzF/L/mKOXGT7qF9JHa5YWbjIq/20Juj6sN1T2p7v1JwRd9JM/f9nHDnZYrspbj0Xte5 hayXzNjuOUosfYapZ2PLYhKGMOzBMDY2uHUNd1pTKVlghS8FgqMkhpYz3XljT/QqMZTD N5Dy0+ZbnPcfFyp4BUmqmzIZNfN0GuW3pDbnIEHhVpEKazqgXn5EJOIc8iV2kfOg/r+f MY9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YRivvwFbR0qDCOjxEENmqgdtxPke+8CVOBUDTCbY2JE=; b=B+mys56LSLI7Gk8HPMZqANEOsWxRI61KJ5L22UGIX5J/d8B4qEzBx+EvTjroGrZtCD yQGJQx8DYk8F3V/IXqxfV4644TGQlVg1rmHDptewTWMl+eGybno2mLVovRfrtzZf/XR2 5DKGEiVplEBNHz59RGn3YuyJrVpO3dS4Jyx7G66JSQk0jQlfX+7PPz0n5HMFmy4S6KVv bUDOA7X+p4Vt/qPVcNBNQKsXDt5SoTpVq9q0kNxzokUj46WpXGt3uZ3QOuU3PPv12LpN PTqqCWdTh2akR8rluPc2eopuafxwSYic9ReyClsPE1NnuPI9dMZucWDtp3Kxx/c2ntMo eCsA== 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 1-v6si16676894pgj.128.2018.07.10.11.32.12; Tue, 10 Jul 2018 11:32:27 -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 S2388285AbeGJSbK (ORCPT + 99 others); Tue, 10 Jul 2018 14:31:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45736 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732920AbeGJSbJ (ORCPT ); Tue, 10 Jul 2018 14:31:09 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 861CFEC6; Tue, 10 Jul 2018 18:30:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 4.9 45/52] dm bufio: drop the lock when doing GFP_NOIO allocation Date: Tue, 10 Jul 2018 20:25:13 +0200 Message-Id: <20180710182453.538712725@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable 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 Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-bufio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -819,6 +819,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 @@ -843,6 +844,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);