From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B4F4C433DF for ; Fri, 29 May 2020 02:59:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 015032075F for ; Fri, 29 May 2020 02:59:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="uKVHCVe9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 015032075F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C787B800C7; Thu, 28 May 2020 22:58:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17BE3800CD; Thu, 28 May 2020 22:58:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB210800BD; Thu, 28 May 2020 22:58:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id F081D800BC for ; Thu, 28 May 2020 22:58:29 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B40454DC5 for ; Fri, 29 May 2020 02:58:29 +0000 (UTC) X-FDA: 76868248338.15.stamp22_fe9012714637 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 8ABCE1814B0CA for ; Fri, 29 May 2020 02:58:29 +0000 (UTC) X-HE-Tag: stamp22_fe9012714637 X-Filterd-Recvd-Size: 4319 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 02:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=dD9nVOWGwAdtF5Vt0w+D5s2gKPxSD7JmOgMrMrHOmY4=; b=uKVHCVe93flhNmJ1jeLNO9WW/g jCb7bi1PKxpF2/A8nlkCTTz/aK7bO2nxPcpeSkiSQOOW87zwSF6vvRjdsGhrfmJxkiedvTbAGha7W i2uFs60cyVhcmVH2cTEGcrAmCtw8Oc0sQDe/cZjdtaQOaqrl5vHFjDz+cMwVGqaBjefu7XCf6kl9+ Ie8YEJCMgfzxayFm3wRKlgcfaAydnuXtBjIAO6LG4MsACWABMHbb5fgRpWNeuw6PNylexjHWhgjTq ivpsiVTm4+Yje2D4ESSuhEbD/bQ49A/wb7ptMH7jBktT3jeQ0BF+TuFPlCQudwol0qi3cp+OfhBxR 5e3Bd2kQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jeVE3-0008Qv-28; Fri, 29 May 2020 02:58:27 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 13/39] iomap: Support arbitrarily many blocks per page Date: Thu, 28 May 2020 19:57:58 -0700 Message-Id: <20200529025824.32296-14-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200529025824.32296-1-willy@infradead.org> References: <20200529025824.32296-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8ABCE1814B0CA X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: "Matthew Wilcox (Oracle)" Size the uptodate array dynamically. Now that this array is protected by a spinlock, we can use bitmap functions to set the bits in this array instead of a loop around set_bit(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/iomap/buffered-io.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 4bc37bf8d057..4a79061073eb 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -22,14 +22,14 @@ #include "../internal.h" =20 /* - * Structure allocated for each page when block size < PAGE_SIZE to trac= k + * Structure allocated for each page when block size < page size to trac= k * sub-page uptodate status and I/O completions. */ struct iomap_page { atomic_t read_count; atomic_t write_count; spinlock_t uptodate_lock; - DECLARE_BITMAP(uptodate, PAGE_SIZE / 512); + unsigned long uptodate[]; }; =20 static inline struct iomap_page *to_iomap_page(struct page *page) @@ -45,15 +45,14 @@ static struct iomap_page * iomap_page_create(struct inode *inode, struct page *page) { struct iomap_page *iop =3D to_iomap_page(page); + unsigned int nr_blocks =3D i_blocks_per_page(inode, page); =20 - if (iop || i_blocks_per_page(inode, page) <=3D 1) + if (iop || nr_blocks <=3D 1) return iop; =20 - iop =3D kmalloc(sizeof(*iop), GFP_NOFS | __GFP_NOFAIL); - atomic_set(&iop->read_count, 0); - atomic_set(&iop->write_count, 0); + iop =3D kzalloc(struct_size(iop, uptodate, BITS_TO_LONGS(nr_blocks)), + GFP_NOFS | __GFP_NOFAIL); spin_lock_init(&iop->uptodate_lock); - bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE); =20 /* * migrate_page_move_mapping() assumes that pages with private data hav= e @@ -146,20 +145,12 @@ iomap_iop_set_range_uptodate(struct page *page, uns= igned off, unsigned len) struct iomap_page *iop =3D to_iomap_page(page); struct inode *inode =3D page->mapping->host; unsigned first =3D off >> inode->i_blkbits; - unsigned last =3D (off + len - 1) >> inode->i_blkbits; - bool uptodate =3D true; + unsigned count =3D len >> inode->i_blkbits; unsigned long flags; - unsigned int i; =20 spin_lock_irqsave(&iop->uptodate_lock, flags); - for (i =3D 0; i < i_blocks_per_page(inode, page); i++) { - if (i >=3D first && i <=3D last) - set_bit(i, iop->uptodate); - else if (!test_bit(i, iop->uptodate)) - uptodate =3D false; - } - - if (uptodate) + bitmap_set(iop->uptodate, first, count); + if (bitmap_full(iop->uptodate, i_blocks_per_page(inode, page))) SetPageUptodate(page); spin_unlock_irqrestore(&iop->uptodate_lock, flags); } --=20 2.26.2