From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751705AbdJEWFU (ORCPT ); Thu, 5 Oct 2017 18:05:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:57436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbdJEWFS (ORCPT ); Thu, 5 Oct 2017 18:05:18 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24AE321909 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shli@kernel.org Date: Thu, 5 Oct 2017 15:05:16 -0700 From: Shaohua Li To: Matthias Kaehlcke Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Michael Davidson , Guenter Roeck Subject: Re: [PATCH] md: raid10: remove VLAIS Message-ID: <20171005220516.busn6mn5ejmf4isj@kernel.org> References: <20171005182847.3368-1-mka@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171005182847.3368-1-mka@chromium.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 05, 2017 at 11:28:47AM -0700, Matthias Kaehlcke wrote: > The raid10 driver can't be built with clang since it uses a variable > length array in a structure (VLAIS): > > drivers/md/raid10.c:4583:17: error: fields must have a constant size: > 'variable length array in structure' extension will never be supported > > Allocate the r10bio struct with kmalloc instead of using the VLAIS > construct. > > Signed-off-by: Matthias Kaehlcke > --- > drivers/md/raid10.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 374df5796649..9616163eaf8c 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -4578,15 +4578,16 @@ static int handle_reshape_read_error(struct mddev *mddev, > /* Use sync reads to get the blocks from somewhere else */ > int sectors = r10_bio->sectors; > struct r10conf *conf = mddev->private; > - struct { > - struct r10bio r10_bio; > - struct r10dev devs[conf->copies]; > - } on_stack; > - struct r10bio *r10b = &on_stack.r10_bio; > + struct r10bio *r10b; > int slot = 0; > int idx = 0; > struct page **pages; > > + r10b = kmalloc(sizeof(*r10b) + > + sizeof(struct r10dev) * conf->copies, GFP_KERNEL); > + if (!r10b) > + return -ENOMEM; I'll apply this patch with 'set_bit(MD_RECOVERY_INTR, &mddev->recovery);' added here, thanks! > + > /* reshape IOs share pages from .devs[0].bio */ > pages = get_resync_pages(r10_bio->devs[0].bio)->pages; > > @@ -4635,11 +4636,13 @@ static int handle_reshape_read_error(struct mddev *mddev, > /* couldn't read this block, must give up */ > set_bit(MD_RECOVERY_INTR, > &mddev->recovery); > + kfree(r10b); > return -EIO; > } > sectors -= s; > idx++; > } > + kfree(r10b); > return 0; > } > > -- > 2.14.2.920.gcf0c67979c-goog >