Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2005706imm; Tue, 10 Jul 2018 11:27:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2yT0uKAREoevOjCjVwPVYNYQxBHTHVsQzq9UEAfONo5mdqPNVEN9a35QjROaYseALaRsb X-Received: by 2002:a17:902:7248:: with SMTP id c8-v6mr25942003pll.128.1531247251303; Tue, 10 Jul 2018 11:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247251; cv=none; d=google.com; s=arc-20160816; b=glcD7JZmOTEN45XaYpLKC9DDnwQ7ViDsFkus0Y93DgqNmT/+l0HYztYGwDrKN8S6ba EqR5A9uJM0IU/+G5ASK5Evcu7QNBKNovaAuLL6d7RjngpGSWgnpoAeirVOhyXQR0L/eo HAR8cmQ1A8emkO9dpW5zBrY0pzJmgolT/XuZ8oZtbRio4q+82/fQKnbCokztRjZ9gw/U 2mmc/mU6KiKq6kJGVmFeguxdqPvWRl58rJkn8hNuU2o+Scy9V/OmVHyR+mvnCDsilxmc R7x3kX8qGnUykH4wnvQ7Eotnw5iUlr4JvPzrB06zpKEdv4zkp1vEedHu2cYIY5b2XCpe qDNg== 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=EQpIa9GFbz3w+zYatef0ontbW0w0HeJNGIPksERVzmc=; b=FIiV+5w9Yz1zWwlSczRanmZaBUP3ZvCknzLeaq1SQ5fVwJVNI+MOA34N0I/KLudh/Y lm8xjXt7BGbuy1VJkO0ITAEkD9atovqnnzw/YFDwWOGBUzojlRZr3SGp0ZSYRu8mkid2 txy4ivp7tXW2+uEGLrVwiUNn1rh9p7ws6I7SR5KwBeB9ZvaGvHTwc7YUELDWtENQrf0c rtVFrb5CtVBagRZwwTEAyjko6zGkCs9fP64eWcTecGi3DeGxsYcQHLfsVtr6MFZmv96h eCed6DJtUX/1Ld2MxPK7Mi29/5mRuLZgNlapeMiBlf5FngwvellOOPCcYsQKOF6WgWeL nZXQ== 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 z15-v6si15458193pga.117.2018.07.10.11.27.16; Tue, 10 Jul 2018 11:27:31 -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 S1732746AbeGJS0X (ORCPT + 99 others); Tue, 10 Jul 2018 14:26:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43688 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732406AbeGJS0W (ORCPT ); Tue, 10 Jul 2018 14:26:22 -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 7F52BE7D; Tue, 10 Jul 2018 18:26:11 +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 3.18 18/23] dm bufio: drop the lock when doing GFP_NOIO allocation Date: Tue, 10 Jul 2018 20:24:51 +0200 Message-Id: <20180710182309.652294292@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182308.877332304@linuxfoundation.org> References: <20180710182308.877332304@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 3.18-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 @@ -761,6 +761,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 @@ -785,6 +786,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);