Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1364932rwe; Fri, 14 Apr 2023 20:30:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YGa+7opuEupNO/+1eCwpO9klea8Xuyeyk4mj/7YFoo9/5UjtBroaYnghVQ6mehxhaeI9xo X-Received: by 2002:a17:903:41d1:b0:1a6:6b5d:8381 with SMTP id u17-20020a17090341d100b001a66b5d8381mr5639563ple.21.1681529453489; Fri, 14 Apr 2023 20:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681529453; cv=none; d=google.com; s=arc-20160816; b=Xkh1/DkGRv3tEBpCPwFPj7f99kQKGVqRXFGz0KEcF4TYjMo+QxJo228Wl18jVa3Fy2 FIpnFqNw1wrFefCgbj/wVqW2Y2FXhZMqQR0rMO0ApqMUOEGYsdAfGb+OT45TopEMQPYy oqxbOndjqh2IBCVk698cjZ+jXVU0XkfTb8ZPWqtus9Ltk6oCf/r01kFStfjwZs/FMmMS ++0S/sYcaCxAFdLeFv2tYpf6kbmxNwoPWM7kurDdzK12tpl6REi0/o5xWzfgBvq+lu6Y rarZdiMItgeMFtc3n8VYlDJgpu9Q+7u6xbqvjJH7ZHpcQ8e4eyD9lYIUVVRP5zhf35OB QkpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ieHtrQuR9xDvhidDNkbr97KSetebKREK0D1RgGN+8Kw=; b=QLqizA+i/GYNrtrJXnW+aSH1nMkDYd85ff4NoV26PV20IFXDnMIeadRlulvgouDsxV quRh/fXnDNTddKafrr/VyPhoiVUDAaCShW67lr8H+3tlHACVnEQ1g2pH02Jv8ipZTEZG GrPpvUzzdqsHD+SSDSd3n/PVLT5YAett0gsbEmIyQG9B+rFn/K0EECWkNvmEmmijMQ5Q p9aEyLQ5FlWlumtFymRNJhSI3OxcF6zZNsOqxU3WVHDcQsKbdhGsdGKaqimTfvPTkwkw ih5dQhns59aVEbhdE0qzYV7OQlA6T3zZ+0FRz/hs0XTRY61nmgZ5AQOrx4Ys4qMG8Pkn mcCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=nWIxEB2W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a170902d90200b001a1cbc5c04fsi5985763plz.341.2023.04.14.20.30.36; Fri, 14 Apr 2023 20:30:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=nWIxEB2W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbjDODZJ (ORCPT + 99 others); Fri, 14 Apr 2023 23:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjDODZH (ORCPT ); Fri, 14 Apr 2023 23:25:07 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6504ECB; Fri, 14 Apr 2023 20:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ieHtrQuR9xDvhidDNkbr97KSetebKREK0D1RgGN+8Kw=; b=nWIxEB2WTi0n5vRquZCmT201yR LteCJWdrJj+NyEvujqTn/vJP4mZ73RtA90E6jffxBqzZ4OTH+kCoxWavP4vBVj+UEa4wVBLieQEbO /S3fzZ2mJudG8cfl08Qk/ztSjUUTXeG8Lw1SYzO9a1/9vlul0/tbP6GUBrgZv8akf52dM4KbKNXcA G3Ku2uDRaSGy/vftY9g1dO1E24BQmBPHrCSHA3oidqqI7LR19esa01Ofb9xErkO2EMvE5XeJ1tccP Rfs3hbXcBAM3vaMaGmSVY6NVn/EUszDj4tkPMBgb4W2n1nZPHr13HIMvichh1KNo2rTHTnCCv2djg vMan+UeA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pnWX2-00BBD1-1b; Sat, 15 Apr 2023 03:24:56 +0000 Date: Fri, 14 Apr 2023 20:24:56 -0700 From: Luis Chamberlain To: Matthew Wilcox Cc: Hannes Reinecke , Pankaj Raghav , brauner@kernel.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, gost.dev@samsung.com Subject: Re: [RFC 0/4] convert create_page_buffers to create_folio_buffers Message-ID: References: <20230414110821.21548-1-p.raghav@samsung.com> <1e68a118-d177-a218-5139-c8f13793dbbf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 15, 2023 at 03:31:54AM +0100, Matthew Wilcox wrote: > On Fri, Apr 14, 2023 at 06:01:16PM -0700, Luis Chamberlain wrote: > > a) dynamically allocate those now > > b) do a cursory review of the users of that and prepare them > > to grok buffer heads which are blocksize based rather than > > PAGE_SIZE based. So we just try to kill MAX_BUF_PER_PAGE. > > > > Without a) I think buffers after PAGE_SIZE won't get submit_bh() or lock for > > bs > PAGE_SIZE right now. > > Worse, we'll overflow the array and corrupt the stack. > > This one is a simple fix ... > > +++ b/fs/buffer.c > @@ -2282,7 +2282,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) > { > struct inode *inode = folio->mapping->host; > sector_t iblock, lblock; > - struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; > + struct buffer_head *bh, *head; > unsigned int blocksize, bbits; > int nr, i; > int fully_mapped = 1; > @@ -2335,7 +2335,6 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) > if (buffer_uptodate(bh)) > continue; > } > - arr[nr++] = bh; > } while (i++, iblock++, (bh = bh->b_this_page) != head); > > if (fully_mapped) > @@ -2353,24 +2352,27 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) > } > > /* Stage two: lock the buffers */ > - for (i = 0; i < nr; i++) { > - bh = arr[i]; > + bh = head; > + do { > lock_buffer(bh); > mark_buffer_async_read(bh); > - } > + bh = bh->b_this_page; > + } while (bh != head); > > /* > * Stage 3: start the IO. Check for uptodateness > * inside the buffer lock in case another process reading > * the underlying blockdev brought it uptodate (the sct fix). > */ > - for (i = 0; i < nr; i++) { > - bh = arr[i]; > + bh = head; > + do { > if (buffer_uptodate(bh)) > end_buffer_async_read(bh, 1); > else > submit_bh(REQ_OP_READ, bh); > - } > + bh = bh->b_this_page; > + } while (bh != head); > + > return 0; I thought of that but I saw that the loop that assigns the arr only pegs a bh if we don't "continue" for certain conditions, which made me believe that we only wanted to keep on the array as non-null items which meet the initial loop's criteria. If that is not accurate then yes, the simplication is nice! Luis