Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1382501ybz; Thu, 16 Apr 2020 08:13:06 -0700 (PDT) X-Google-Smtp-Source: APiQypJRIfFVEHXESdjkrveHkBP8YeQqPwYgoCV6kWSlvUFBian4OSeYV+r7GzRTM/sUvPmNTXrf X-Received: by 2002:a05:6402:c94:: with SMTP id cm20mr11868982edb.101.1587049986494; Thu, 16 Apr 2020 08:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587049986; cv=none; d=google.com; s=arc-20160816; b=fHj2PPGq06ERaj1CrchdZ6pHCaXDlGatXjmaDl8pcjN+FFCb5/xOI4UoQitT8wF7IA jmTWdNLkgXiHYU+VumvQzKgR8gABaDqGl21b+ZL1sempRkXgfrZUCR/+eyKV7mVfJVGd PtEdwxYRiio0q+bN31VEBjH/pIfUAAQVw9IIcL1vsNydmqBB8hIF5e8HoU3W783Hf9nm ebBm6VfKXRzbYo+XZrO3efqCw0r942lB2CM4CQqm7aL6WejHQS0Q5k5wtPiChugW2+tj 0EIn37AAXtiMNdKI8ZP32ZLK+uJ3W/ez7JuV6Wm8ATWglaGFZfGYHQkIShhxCbdJgSb+ 6RbQ== 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=FoV6XSdP19Aeb1Dtv6HY3Ci7Bi8vwB2D6gSuUgRRGlc=; b=LATUveu4V9dvZX23xV5/RQl2JDRIlo54sTipw8UgeicuaRj+PJxzSMRkD+v0swfyGw dS11mm647vXHczIajVBMhLAMp33L20vi+LzVSO4FNHMvPVX89yKInurts7g9YmiCBLAU Ndi4nCFk03TY6SyuerHRGyZWPscM61wnqi+lqBLKROoqpYyD3Q2n6N2V1i59REqaHU4T 3XTAd+39FkDh0AOe9GsDcXgfmkEQZXff2zOhczMH8xqBClvClYn06RHhA0DEVl8gW1If VJgBmLV20VN7kqavfVfjFi2IzHoq3yLJB+1kDYT8dL1khytrP9pRWdQukj5EZkpCgNBk Y0Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uHqTpV/m"; 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 j3si12547430ejb.482.2020.04.16.08.12.43; Thu, 16 Apr 2020 08:13:06 -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="uHqTpV/m"; 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 S2394993AbgDPPJy (ORCPT + 99 others); Thu, 16 Apr 2020 11:09:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:36746 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439253AbgDPNut (ORCPT ); Thu, 16 Apr 2020 09:50:49 -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 2D1102078B; Thu, 16 Apr 2020 13:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587045045; bh=T9Q/+8y+10RHMimFMocEtiqH524D6C047MMtaJaMqCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uHqTpV/mTujhXKQdg0w76UzIK5LUStMAfC6e47Ejhub8J/zLp1M2veX665x+fcsp7 JwKFnUl9cYnNo5sC7PevneR6HPCsVoMdvE9HGugvLa1VBENzHlHY36mb7EdopJ9Dtk 4dCmnW+7vbYCbgUKwFF9AWdrvR31s50N3NY4j0MI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 5.4 206/232] xen/blkfront: fix memory allocation flags in blkfront_setup_indirect() Date: Thu, 16 Apr 2020 15:25:00 +0200 Message-Id: <20200416131341.101292091@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131316.640996080@linuxfoundation.org> References: <20200416131316.640996080@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: Juergen Gross commit 3a169c0be75b59dd85d159493634870cdec6d3c4 upstream. Commit 1d5c76e664333 ("xen-blkfront: switch kcalloc to kvcalloc for large array allocation") didn't fix the issue it was meant to, as the flags for allocating the memory are GFP_NOIO, which will lead the memory allocation falling back to kmalloc(). So instead of GFP_NOIO use GFP_KERNEL and do all the memory allocation in blkfront_setup_indirect() in a memalloc_noio_{save,restore} section. Fixes: 1d5c76e664333 ("xen-blkfront: switch kcalloc to kvcalloc for large array allocation") Cc: stable@vger.kernel.org Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Acked-by: Roger Pau Monné Link: https://lore.kernel.org/r/20200403090034.8753-1-jgross@suse.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkfront.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -2188,10 +2189,12 @@ static void blkfront_setup_discard(struc static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) { - unsigned int psegs, grants; + unsigned int psegs, grants, memflags; int err, i; struct blkfront_info *info = rinfo->dev_info; + memflags = memalloc_noio_save(); + if (info->max_indirect_segments == 0) { if (!HAS_EXTRA_REQ) grants = BLKIF_MAX_SEGMENTS_PER_REQUEST; @@ -2223,7 +2226,7 @@ static int blkfront_setup_indirect(struc BUG_ON(!list_empty(&rinfo->indirect_pages)); for (i = 0; i < num; i++) { - struct page *indirect_page = alloc_page(GFP_NOIO); + struct page *indirect_page = alloc_page(GFP_KERNEL); if (!indirect_page) goto out_of_memory; list_add(&indirect_page->lru, &rinfo->indirect_pages); @@ -2234,15 +2237,15 @@ static int blkfront_setup_indirect(struc rinfo->shadow[i].grants_used = kvcalloc(grants, sizeof(rinfo->shadow[i].grants_used[0]), - GFP_NOIO); + GFP_KERNEL); rinfo->shadow[i].sg = kvcalloc(psegs, sizeof(rinfo->shadow[i].sg[0]), - GFP_NOIO); + GFP_KERNEL); if (info->max_indirect_segments) rinfo->shadow[i].indirect_grants = kvcalloc(INDIRECT_GREFS(grants), sizeof(rinfo->shadow[i].indirect_grants[0]), - GFP_NOIO); + GFP_KERNEL); if ((rinfo->shadow[i].grants_used == NULL) || (rinfo->shadow[i].sg == NULL) || (info->max_indirect_segments && @@ -2251,6 +2254,7 @@ static int blkfront_setup_indirect(struc sg_init_table(rinfo->shadow[i].sg, psegs); } + memalloc_noio_restore(memflags); return 0; @@ -2270,6 +2274,9 @@ out_of_memory: __free_page(indirect_page); } } + + memalloc_noio_restore(memflags); + return -ENOMEM; }