Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp966555ybt; Fri, 19 Jun 2020 19:54:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6u2BFRtG+DN65Op9y1Zi6B/zCZhLd3bQIYq9VbWvvtb5VwIdhHxAAYfsH4SZvMXSnFiX1 X-Received: by 2002:aa7:cdc6:: with SMTP id h6mr5991309edw.191.1592621697948; Fri, 19 Jun 2020 19:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592621697; cv=none; d=google.com; s=arc-20160816; b=RL/4b+Li4BkGQVvEolP78kIk18zFsBMDir62QYQBrjtMrTP5mEDeME2KshVVMCHjDs Mtcwsg62oAGxmttlznKvJn8Ea5YNDj/U+EsY9XxxfpAgVbZBgnPUEP/Z2yh6qxI3uYc7 l+9rp2AE8DGJh9WhGb1kovRhhTj5h0UCFqth1nJ9GwNrhz2tTzXfCPfV5jQ16UxKniGH x5toX5qmKbrVn8SDq1DK3a9FG9dvhTkSEFR4xKhB1thyeCmlceiBtDUpI5yCwitMYK2H FRabnanfLGs84ljRLHPxGomDSqgqjMWsyywsF3+C7PbPvL3YgDOnE7s2kx5ANcAYVay6 mO0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o3KmxfubKhELNjPQQX8eN+UDW/sG1k42LleGWAgYACw=; b=bShdNQt+l03nrwrdI/SE4uxC7qC6bTq6yHm7xBktlwRwKY/nGppDFU7eCGFZsUAYi+ iA8XonqY6UEqNum4hgNLz5sqOlwYFZvmRTJvbsP90Ni8s6Z7RlwjxvuYHNB27yqHIjMZ AyaRPqLZqc62W+ePWEY68VHhvAtChAFPWx5/LOIJVbDTDrGlJKCPtTvzaL32CSjx4Apo AtGVssJivtgdZXFcLJenCQrEtI4tFvR+o72WmD3u02SOFu/inwq8ya7EJLv4GNdAys0A C7KKfarcusVH7Az/v4INWw9SLTvKUbcpaWnc4+oHsLMmcVhmKj+Lle/IipqixChbRv+O ux+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=W+tjV7N3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o25si4860555eja.361.2020.06.19.19.54.36; Fri, 19 Jun 2020 19:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=W+tjV7N3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394120AbgFSPub (ORCPT + 99 others); Fri, 19 Jun 2020 11:50:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:56344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393289AbgFSPYf (ORCPT ); Fri, 19 Jun 2020 11:24:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C764E21582; Fri, 19 Jun 2020 15:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580274; bh=lO4eUHWmNCZ+YKJkGjlVsdAeLu+g8LxUW8/i3uYUDzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+tjV7N3NHp9dbVXbG2npNpVleZPRxghP0o/aAa3f4qB9raZWjwFHE4mqCROWwH/6 FZ2LQ2fedftDD+ZBPSyXeWKYwK+r5sq7RwSosLTMnXwtM5a9F1GgYK22un7IxFRFRL 7dX8AqrlTdc6e+0dMInWT9UvThvAx+NAB/tzu2Vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Hocko , Coly Li , Song Liu , Sasha Levin Subject: [PATCH 5.7 188/376] raid5: remove gfp flags from scribble_alloc() Date: Fri, 19 Jun 2020 16:31:46 +0200 Message-Id: <20200619141719.247161329@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li [ Upstream commit ba54d4d4d2844c234f1b4692bd8c9e0f833c8a54 ] Using GFP_NOIO flag to call scribble_alloc() from resize_chunk() does not have the expected behavior. kvmalloc_array() inside scribble_alloc() which receives the GFP_NOIO flag will eventually call kmalloc_node() to allocate physically continuous pages. Now we have memalloc scope APIs in mddev_suspend()/mddev_resume() to prevent memory reclaim I/Os during raid array suspend context, calling to kvmalloc_array() with GFP_KERNEL flag may avoid deadlock of recursive I/O as expected. This patch removes the useless gfp flags from parameters list of scribble_alloc(), and call kvmalloc_array() with GFP_KERNEL flag. The incorrect GFP_NOIO flag does not exist anymore. Fixes: b330e6a49dc3 ("md: convert to kvmalloc") Suggested-by: Michal Hocko Signed-off-by: Coly Li Signed-off-by: Song Liu Signed-off-by: Sasha Levin --- drivers/md/raid5.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index ba00e9877f02..190dd70db514 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2228,14 +2228,19 @@ static int grow_stripes(struct r5conf *conf, int num) * of the P and Q blocks. */ static int scribble_alloc(struct raid5_percpu *percpu, - int num, int cnt, gfp_t flags) + int num, int cnt) { size_t obj_size = sizeof(struct page *) * (num+2) + sizeof(addr_conv_t) * (num+2); void *scribble; - scribble = kvmalloc_array(cnt, obj_size, flags); + /* + * If here is in raid array suspend context, it is in memalloc noio + * context as well, there is no potential recursive memory reclaim + * I/Os with the GFP_KERNEL flag. + */ + scribble = kvmalloc_array(cnt, obj_size, GFP_KERNEL); if (!scribble) return -ENOMEM; @@ -2267,8 +2272,7 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors) percpu = per_cpu_ptr(conf->percpu, cpu); err = scribble_alloc(percpu, new_disks, - new_sectors / STRIPE_SECTORS, - GFP_NOIO); + new_sectors / STRIPE_SECTORS); if (err) break; } @@ -6759,8 +6763,7 @@ static int alloc_scratch_buffer(struct r5conf *conf, struct raid5_percpu *percpu conf->previous_raid_disks), max(conf->chunk_sectors, conf->prev_chunk_sectors) - / STRIPE_SECTORS, - GFP_KERNEL)) { + / STRIPE_SECTORS)) { free_scratch_buffer(conf, percpu); return -ENOMEM; } -- 2.25.1