From patchwork Mon Apr 22 19:31:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638876 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A545B1553AD; Mon, 22 Apr 2024 19:32:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814333; cv=none; b=l+e5RyC3wx1kvE0HlHVTMzoWA8kRYCV0em2Aj2a+TGT8qxtXNN1OV+Mru6u5d8y3mtNqlPlxo6XTk0XeDfKeYLXVbXs5lBFxLkRBuZUAO4KoDnsPBLZpSGvOO5bmkPd0vk1k80USMn1uxfglkdtS+1gyKJVJE2PPEof+LH8kmZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814333; c=relaxed/simple; bh=SxSqw986WsWe51m5M0F8bbrXytz2xGOXLoYtvYrpa0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DIUljn6bwZLqfAmqyOBMMB9w+RSF3ZbEUtoccFGSKvtGRB/HY/pKydvtlUJN6T0Oa8SjgjMpng/xQVt17ZWAn4ubY+wwxqVgQ6KfpPgVWmXr91n1963kKtybFCn0MSL5WpurgbGUxG3/w/XmMb59tkbjRgSL2tg1VcKTFfsQDfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=OQxY1Vp8; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="OQxY1Vp8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=O5qCe9GV5hWp+SXsPtO2/rvY95DODsm8hr+fAkNqOEY=; b=OQxY1Vp8TmUivUTNk/hqZIlIto QkWu8Ij71nTrCv6M1bQ2gBajTHVUI+g+wwslbbPtMWJcWxMf0G+wz1Hgut+5pBFp1dyCwo7CBpdLh dPcq61GGgxoXPPCk1E2AaDNNQ/51HKx/cqK2d/BDrNJyIpsUEuproRAQZXgfOCLQ0ai0RevNFx94I 03WlPYRTSRliy9FY9q1HWIlZD6kJ+7J12jNyLOJq5zHoXu8m9afN0xUeoSvy7ldg6PyjeEuccL+CH 1j02yAFwcnfLiiJu9f/LwsQmMCB/yAMqCT27kNZKt2Ik6cfzsx3VvxCnt2NqwI3CtZPknAjkDLbxf geIoV53g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpO6-01eQ; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 01/11] ntfs3: Convert ntfs_read_folio to use a folio Date: Mon, 22 Apr 2024 20:31:51 +0100 Message-ID: <20240422193203.3534108-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove the struct page conversion, and use a folio throughout. We still convert back to a struct page for calling some internal functions, but those will change soon. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/inode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 30e69177f224..bdaea9c783ad 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -710,25 +710,24 @@ static sector_t ntfs_bmap(struct address_space *mapping, sector_t block) static int ntfs_read_folio(struct file *file, struct folio *folio) { - struct page *page = &folio->page; int err; - struct address_space *mapping = page->mapping; + struct address_space *mapping = folio->mapping; struct inode *inode = mapping->host; struct ntfs_inode *ni = ntfs_i(inode); if (is_resident(ni)) { ni_lock(ni); - err = attr_data_read_resident(ni, page); + err = attr_data_read_resident(ni, &folio->page); ni_unlock(ni); if (err != E_NTFS_NONRESIDENT) { - unlock_page(page); + folio_unlock(folio); return err; } } if (is_compressed(ni)) { ni_lock(ni); - err = ni_readpage_cmpr(ni, page); + err = ni_readpage_cmpr(ni, &folio->page); ni_unlock(ni); return err; } From patchwork Mon Apr 22 19:31:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638874 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3CC315532D; Mon, 22 Apr 2024 19:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; cv=none; b=AbiqRS2V8iWwU2KHWE5qwo2GyDxH2X+oqIoDTMS5RC/AoaHg5cSeWUTN+f+q9yzW4djI5nzbnJrfTAEAk1ScryfU4fywjo3KsvL4QdBaofiXgq4ZMTpcloEdIGGg3DI3DaC/j24J7x000eekca4h9ezb+M2zJa+TlEX3IyexKUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; c=relaxed/simple; bh=z43HQPlnbpQWzNfMMe6SGRFVI4CtmRZQWOv/Ybowqg0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ihU6VdxsMbLS5gGzm0s8gxHnigD3M7oCVVsaXhRSHU7GoEuNX4g1XEUs+EfwlS1wMkMH1DxtgcLsnp3PrTDfPlhPId/JYh1EJAjmzt/hLVmcwQlGAT1uyX5hE8kxHlz4GQOQ4d4A6SG0ukwzbIcVoK8iSVg5S1CAs48u9GqRSfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=fNZfG4W8; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="fNZfG4W8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=J2jUvJdcQN4gwLHeLivK6x8gzEN8L6yg8m4bc9uB1LM=; b=fNZfG4W8ZoeWhwN+3gMugZbLx8 vUrUmuIuIDYgISnA3tK8NcLGLdovzgTkdp6PxYrDOI7lBraKxfmCuJR4Tbv6H61WOMiEsLpNHxbrE 0pwJa6GYHQ0UrxnuwlfIPiyEeKXhFTCRlGegEBaPXV8vpqeYP1zf0JgVasYgbnnyybhagdLjubUSm mkF6W2Yyix8+jJHl08jes7GCD5Mmt6iizzDB2Gva5NdIqTuOyh+OK7GliRWcnRq7FM/x+QV+zUjxV bo51/STooleSfn7frEs5fD0WQMtdHQKb3pi9rAJLw3wqvFgbDwMZoLYpXRNtkU1eCNBovAEEhOGLw gwZpo+Yg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpO8-0JFG; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 02/11] ntfs3: Convert ntfs_write_begin to use a folio Date: Mon, 22 Apr 2024 20:31:52 +0100 Message-ID: <20240422193203.3534108-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Retrieve a folio from the page cache instead of a precise page. This function is now large folio safe, but its called function is not. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/inode.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index bdaea9c783ad..794d2aa3a5ab 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -913,24 +913,25 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping, *pagep = NULL; if (is_resident(ni)) { - struct page *page = - grab_cache_page_write_begin(mapping, pos >> PAGE_SHIFT); + struct folio *folio = __filemap_get_folio(mapping, + pos >> PAGE_SHIFT, FGP_WRITEBEGIN, + mapping_gfp_mask(mapping)); - if (!page) { - err = -ENOMEM; + if (IS_ERR(folio)) { + err = PTR_ERR(folio); goto out; } ni_lock(ni); - err = attr_data_read_resident(ni, page); + err = attr_data_read_resident(ni, &folio->page); ni_unlock(ni); if (!err) { - *pagep = page; + *pagep = &folio->page; goto out; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); if (err != E_NTFS_NONRESIDENT) goto out; From patchwork Mon Apr 22 19:31:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638866 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D0115532F; Mon, 22 Apr 2024 19:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; cv=none; b=C2jOud2bF6eLhie0IqlWlpoZO0mnEyS4U33bXAqb5JbWnuHlJIbkLR67FkUs7YCQk+j5jYyVqZ3VP4Xnq0W+3BEpD203xoTNL7FBOgaEC/2jqj8Rip/7uRx7VcXUMMILh+LJpYot/QOeZl6e4+Ak7ktRG8vDRdOXGKMnn2Tr9v4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; c=relaxed/simple; bh=iFPo8AzfRg4PHAOoob070kBSgoqO9Ua8EMmLoLzgVMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pc3FqZaSBXX/avXvI/FJg+rtEuAjK1EnX0a6Wt0Ie03bJnbyeCIg+F0D7CpiNpdGvs1uK00f4VStpaW0rIo4qX+1w5KOK8jjiic+wH0nxLRfhVlaxvrByZh/2h4TYj/kcTAED7CYXXCLgC+JEfMpO4fK0RRTlUBtYdLup7trpG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=oEKPcy2o; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="oEKPcy2o" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=ElyNk+czC1SsaG1zKgGROmJrTjnbDOZyYiye0Bn6G+M=; b=oEKPcy2oAX/8tBN8Hs6wwI3lH8 NEKZC1oXTdazvGVNoWx7mTuxTz1xwA1ZCr4gBMj75ji4CLS/PcGqNpWVjP+NAD6w6qpbmL4SeSSZj qSOATB/ao9oGy1dSN5c3a/keyNhrJDcnGuy7slUe58OF6bBII5KDgqyNGa7Ej4OIXYXR4MHpBqaAW dwwhChNUDIMvn64XRzFURwLMAL5tgdA8D/dFoKkXoikbcT1oYkhv0nDLjdMmGfZbCiQfbpBynNQHF Aab+n1/KtODGTGEn6zic95RIpHXdcG2DCy5Kkazb+5zlbtZZVVexVHmR2TW9eHEsVUTF60nR+nOG4 UFCfyw3A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOC-0mWq; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 03/11] ntfs3: Convert attr_data_read_resident() to take a folio Date: Mon, 22 Apr 2024 20:31:53 +0100 Message-ID: <20240422193203.3534108-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that all three callers have a folio, pass it in and use folio_fill_tail() to do the hard work of filling the folio. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/attrib.c | 27 +++++++++------------------ fs/ntfs3/inode.c | 6 +++--- fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index acee4644fd8d..676489b05a1f 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1240,11 +1240,12 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, goto out; } -int attr_data_read_resident(struct ntfs_inode *ni, struct page *page) +int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio) { u64 vbo; struct ATTRIB *attr; u32 data_size; + size_t len; attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL); if (!attr) @@ -1253,25 +1254,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page) if (attr->non_res) return E_NTFS_NONRESIDENT; - vbo = page->index << PAGE_SHIFT; + vbo = folio->index << PAGE_SHIFT; data_size = le32_to_cpu(attr->res.data_size); - if (vbo < data_size) { - const char *data = resident_data(attr); - char *kaddr = kmap_atomic(page); - u32 use = data_size - vbo; - - if (use > PAGE_SIZE) - use = PAGE_SIZE; + if (vbo > data_size) + len = 0; + else + len = min(data_size - vbo, folio_size(folio)); - memcpy(kaddr, data + vbo, use); - memset(kaddr + use, 0, PAGE_SIZE - use); - kunmap_atomic(kaddr); - flush_dcache_page(page); - SetPageUptodate(page); - } else if (!PageUptodate(page)) { - zero_user_segment(page, 0, PAGE_SIZE); - SetPageUptodate(page); - } + folio_fill_tail(folio, 0, resident_data(attr) + vbo, len); + folio_mark_uptodate(folio); return 0; } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 794d2aa3a5ab..b0299c7b59b4 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -583,7 +583,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo, err = 0; } else { ni_lock(ni); - err = attr_data_read_resident(ni, &folio->page); + err = attr_data_read_resident(ni, folio); ni_unlock(ni); if (!err) @@ -717,7 +717,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio) if (is_resident(ni)) { ni_lock(ni); - err = attr_data_read_resident(ni, &folio->page); + err = attr_data_read_resident(ni, folio); ni_unlock(ni); if (err != E_NTFS_NONRESIDENT) { folio_unlock(folio); @@ -923,7 +923,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping, } ni_lock(ni); - err = attr_data_read_resident(ni, &folio->page); + err = attr_data_read_resident(ni, folio); ni_unlock(ni); if (!err) { diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 7fd044fee635..bd8c9b520269 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -445,7 +445,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, struct ATTRIB **ret); int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, CLST *len, bool *new, bool zero); -int attr_data_read_resident(struct ntfs_inode *ni, struct page *page); +int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio); int attr_data_write_resident(struct ntfs_inode *ni, struct page *page); int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name, u8 name_len, struct runs_tree *run, From patchwork Mon Apr 22 19:31:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638867 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D4FC155330; Mon, 22 Apr 2024 19:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; cv=none; b=LIptU/ZXODrwC7RFco06gaiopKAETiAT1Y4Hzb0jvsLRIzl+uTwWbgao3ENTbmACW0Qm4PqiyZTtc90qFzUbM0NjUpVx8v8UUnv5uJNsNqDjW/C9G+WRWqHYl7oM7NLOHLzklHiuNSUWk5kAykaLxlmADPlb93atxltKbfpoiTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; c=relaxed/simple; bh=oQ12gdJfFeqwUZ/ihD+J+e4bcDDrIM++qc3jNtA0m6c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=njpmkXzZ8Y1AcUtrPAfO6Ay4MOQoQM//SfleSH8tG7hx1nQR+Y06++dJB0mmpqHVEH6/GnY/Guo7lf3BVPXw3D5tL6hEWtrU50Ihw1f5+pTRcYpAAIajdNnMaTaLOJIVXBdbwnZ1y5fk0UWb6qCgSPv9OJjekqZzgbHvsN/NOTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=QgM9avXo; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QgM9avXo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=UYRue+vvEySVdrtF5i8vTZmBSEewgkNCyDkAuih1QGI=; b=QgM9avXo3MAYLNih2v3JbRiEdt tggBplf75O/YlJw7M7QaRmboec2GJ2FMkbs5xLHXqVGd+I+lE7VBstoPSWccIl5g3X1G0R184ES4J EczyTYMNMulVYUX4z9M7LfFNyA4mNIB8P7B5JHGEcmA4QP2i51SbsZabVTsBjBgZ1YU2fWxJb0744 TUdiTH7ruzTao3SmbHeMNjsQ0HxtFckmW2qqwM41xNuKZutU0zM4otHi49XMqZIbwGsYaLeU0TShZ fxCF0ec3TA2k5pfNcK1rJaqpGdDeFg8GYukhSmExoWGPnpqlUeisDaqvksN6tF7KudSVUFK0sqJfy 5JuoTq9A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOL-1Iiq; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 04/11] ntfs3: Convert ntfs_write_end() to work on a folio Date: Mon, 22 Apr 2024 20:31:54 +0100 Message-ID: <20240422193203.3534108-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert the passed page back into a folio and use the folio APIs, saving a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/inode.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index b0299c7b59b4..e9c1cba44741 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -950,6 +950,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping, int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, u32 len, u32 copied, struct page *page, void *fsdata) { + struct folio *folio = page_folio(page); struct inode *inode = mapping->host; struct ntfs_inode *ni = ntfs_i(inode); u64 valid = ni->i_valid; @@ -961,23 +962,23 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, err = attr_data_write_resident(ni, page); ni_unlock(ni); if (!err) { + struct buffer_head *head = folio_buffers(folio); dirty = true; - /* Clear any buffers in page. */ - if (page_has_buffers(page)) { - struct buffer_head *head, *bh; + /* Clear any buffers in folio. */ + if (head) { + struct buffer_head *bh = head; - bh = head = page_buffers(page); do { clear_buffer_dirty(bh); clear_buffer_mapped(bh); set_buffer_uptodate(bh); } while (head != (bh = bh->b_this_page)); } - SetPageUptodate(page); + folio_mark_uptodate(folio); err = copied; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); } else { err = generic_write_end(file, mapping, pos, len, copied, page, fsdata); From patchwork Mon Apr 22 19:31:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638875 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AA63155331; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814332; cv=none; b=ST89FrhZZcTbWl76GR7Hq4ivN2/2UyiULcBBamlnau/RVkLBN+ALDvQ4wsxyeJC8xsV3JiMjmqaSv6B8+lvs923nJ0/rOnVeC1qXFQSl8ASoqDmCmER8YHMMh4X6lzYCPXWHzzBgKrhHKnWNfATujg8pkhnTDWA5BkVlOKIfNko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814332; c=relaxed/simple; bh=eDzZ4vNVsWAEW/IPJpi6Lz7Ek5AahfE9k2M4rt9/Go4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZYzh1q5wz2hQ9C0G7A0Z193hHnTz9BeB7RGFobUoqLrmomOWcMabcoHpth64ofix+RnTP5fA7SeHpoRESweyrqXNLQwrWrGsjXFdAVgumNOxUS1BYrPYBpcHOSwo0r1slzJ0M6gfDTOVcrlu3QSbW2FGjMYI+q60/D+mHUCvN+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=LlkytfL3; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LlkytfL3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=jA6DvimgocJNoFfxUx1rKqz4GwPAUGQUlfv1jnS2/+o=; b=LlkytfL3G8GwyCJwG6dhJ+oaav EzfUq8KRM1yIbNgoedol51GW7P4pRf0FVrkbb/GVgVh2NBT4tOC9Gb0dQPXmHpPaq8+qXoVFJypwu 8QBTPdGJlhPpHlWBcFGtwJWrMLL9sP3vWEP/+7TMvqRVf4KK1Pf4jKJaGtASkQJAxgovBknkfz2So vKfBzNnJnj9GdEsGCS4eGMSTQDJUQU74biYmc2hdtuQuqmuASfXN7HxI3hvWaTOqwCJJWEbduw5AU CDXM6YX7ZQnGySFFsFrQ6axY1Ud5wf2y8csY35uQ5zLtmepWtiLS268ikgbdL5B/06nDFGnOHqRG1 tm9/HPMw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOR-1pWB; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 05/11] ntfs3: Convert attr_data_write_resident to use a folio Date: Mon, 22 Apr 2024 20:31:55 +0100 Message-ID: <20240422193203.3534108-6-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that both callers of attr_data_write_resident() have a folio, pass it in and use memcpy_from_folio() to handle all the gnarly highmem multi-page problems. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/attrib.c | 12 ++++-------- fs/ntfs3/inode.c | 4 ++-- fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 676489b05a1f..02fa3245850a 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1267,7 +1267,7 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio) return 0; } -int attr_data_write_resident(struct ntfs_inode *ni, struct page *page) +int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio) { u64 vbo; struct mft_inode *mi; @@ -1283,17 +1283,13 @@ int attr_data_write_resident(struct ntfs_inode *ni, struct page *page) return E_NTFS_NONRESIDENT; } - vbo = page->index << PAGE_SHIFT; + vbo = folio->index << PAGE_SHIFT; data_size = le32_to_cpu(attr->res.data_size); if (vbo < data_size) { char *data = resident_data(attr); - char *kaddr = kmap_atomic(page); - u32 use = data_size - vbo; + size_t len = min(data_size - vbo, folio_size(folio)); - if (use > PAGE_SIZE) - use = PAGE_SIZE; - memcpy(data + vbo, kaddr, use); - kunmap_atomic(kaddr); + memcpy_from_folio(data + vbo, folio, 0, len); mi->dirty = true; } ni->i_valid = data_size; diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index e9c1cba44741..69dd51d7cf83 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -871,7 +871,7 @@ static int ntfs_resident_writepage(struct folio *folio, return -EIO; ni_lock(ni); - ret = attr_data_write_resident(ni, &folio->page); + ret = attr_data_write_resident(ni, folio); ni_unlock(ni); if (ret != E_NTFS_NONRESIDENT) @@ -959,7 +959,7 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos, if (is_resident(ni)) { ni_lock(ni); - err = attr_data_write_resident(ni, page); + err = attr_data_write_resident(ni, folio); ni_unlock(ni); if (!err) { struct buffer_head *head = folio_buffers(folio); diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index bd8c9b520269..275def366443 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -446,7 +446,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn, CLST *len, bool *new, bool zero); int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio); -int attr_data_write_resident(struct ntfs_inode *ni, struct page *page); +int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio); int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type, const __le16 *name, u8 name_len, struct runs_tree *run, CLST vcn); From patchwork Mon Apr 22 19:31:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638869 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42B78155335; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; cv=none; b=uLWehih8HjMR+s3H/zqkY0k6/kkTOPCpXuyWMusgx76a8rvJvIjKftpjxQYQMoWpx8bPwpaaHJXKK1oHR4fZy5TLob1cur4NHVbOGt2tscZ4WQH3/mvmSo01FyZFY6L+7FbWHhnIVUs5OrYpLPNXGauC439i8zO9SitkwRwBQQE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; c=relaxed/simple; bh=NnHDD4XZ2kCQ4d7HJke1yukYvowdpmKldE7q4gVSDOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FdwxVBX6FZIxNdnZOrnhKwlsbQcic1vGvrmtvCeNUpatRe8R9r4nSWz0ZeQ4phY66YF0sd/7TD0vlsiIQhsonCT4PqISZB4xLMIUSMtbdefpqN6Ro6r1utMYspDyiN3jrKlIXH5O6Q+lIAz1e9wEOPlOnDiWrKScTn1GJ7Zvyuc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ERBLU/Sw; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ERBLU/Sw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=d70RGPIKcgF9cV4nDWNd7glVkTC0Q68eNqTUdJA0Mv4=; b=ERBLU/Swu1L0F903yFoWFcPLKk 8nwwbTmesEcXZ/8SIVKFS/5zHM2wOnQdiBi6yFmoiGFAJtxzEKxIxzJTMMQGlxoOJff3NG46fG8N1 z4EeOPLpbTo2CzdlByvhPec0fm1OAG4HMbDFR2aO7ObkN7Iwp9tDz05Lgdn1yXQhbRljtyhE8BMls /zzO+4pddkvRfbA5CTlY4J0dXLtRtE7ZrWskty2SAtULVwv9rPOp/T+tDtmYxvj6YH8A9llqUFiQb KQCx4ED3X7fQ2o89NZloxf1CqK8RMeVeQ/c7FmflEZ/bQYbt3VGEsT9CU/5O4iv2iKbsm0N1o1YRE omcT12YQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOX-2ObQ; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 06/11] ntfs3: Convert attr_make_nonresident to use a folio Date: Mon, 22 Apr 2024 20:31:56 +0100 Message-ID: <20240422193203.3534108-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fetch a folio from the page cache instead of a page and operate on it. Take advantage of the new helpers to avoid handling highmem ourselves, and combine the uptodate + unlock operations into folio_end_read(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/attrib.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 02fa3245850a..d253840c26cf 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -302,22 +302,20 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr, if (err) goto out2; } else if (!page) { - char *kaddr; - - page = grab_cache_page(ni->vfs_inode.i_mapping, 0); - if (!page) { - err = -ENOMEM; + struct address_space *mapping = ni->vfs_inode.i_mapping; + struct folio *folio; + + folio = __filemap_get_folio(mapping, 0, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, + mapping_gfp_mask(mapping)); + if (IS_ERR(folio)) { + err = PTR_ERR(folio); goto out2; } - kaddr = kmap_atomic(page); - memcpy(kaddr, data, rsize); - memset(kaddr + rsize, 0, PAGE_SIZE - rsize); - kunmap_atomic(kaddr); - flush_dcache_page(page); - SetPageUptodate(page); - set_page_dirty(page); - unlock_page(page); - put_page(page); + folio_fill_tail(folio, 0, data, rsize); + folio_mark_dirty(folio); + folio_end_read(folio, true); + folio_put(folio); } } From patchwork Mon Apr 22 19:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638868 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42BBC155336; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; cv=none; b=k2B+FKVp8INOHPOWwTvD/yqfGpjg4neldCuquKrO4EwH9PoLeLk9FCQewBMiLJYoo6ACHhhvOCopGGcqnv/a3N9CZ0YmwQfbvw0HvwPNovYxxdZJOcm29Sj555sbIOlyxnop9xCG8UBkolkJ3TCZtWMT+SJkvuEdZ/VH2C9+1nM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; c=relaxed/simple; bh=lESpPvk5enNXOw39cgNoRM8fG/IcOuaqmOi+vaI3hnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W2NJ40Qjh9ZqrcckkVDmXgxuvSq9av4DYXTiaiVUYBtNqVwKOH/Yh69rc6dayCa/SwdVBFP8asLEUIs0VKnrwMIrBuq7qEdRw+W0WF1lSrk4Ed5QRfBJx8iERVHluFz2EywqoyddRh2F98v1Vz6vzrh4fJsHE4lWN6aatEgOhvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=lsED3wSO; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lsED3wSO" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=9c0Y84/1MmmK3Hj02j9ZeCOdjd0HyunQX9phSias8jQ=; b=lsED3wSOF6grGLCjU2CxzsM568 YCTI9dARTWjNoHZ/tJ59OJlHanh494JjQByLl5DH6og6V2zXkMqzaauuCXRX/aYqAvAdDWcUN7t1P Cbq87796lMIR9lgQwHmffLOL6o37tQSqoG6XicEknYHilxzHoTX265GDFpNMybKhvprz2zCz6cKc5 oLthdoTSo7x2PT23Cmd2yYDbP3C54upapgbKf6xw1H8aXieL6YB93OOaUo9B9MkmLXQsqI4PaC8dV Usw4gLs+1Lv7nxIau5bxTnml4CZmaTYlVme79z1FEzD8VOAfh6EHX5GH6wi+I45NfykV31QhfRzA7 3tjp0PdQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOd-2zav; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 07/11] ntfs3: Convert inode_read_data() to use folios Date: Mon, 22 Apr 2024 20:31:57 +0100 Message-ID: <20240422193203.3534108-8-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is now large folio safe, although we're not enabling large folios yet. It does eliminate a use of kmap(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/inode.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 69dd51d7cf83..4791a002500b 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -1103,25 +1103,23 @@ int ntfs_flush_inodes(struct super_block *sb, struct inode *i1, */ int inode_read_data(struct inode *inode, void *data, size_t bytes) { - pgoff_t idx; + pgoff_t idx = 0; struct address_space *mapping = inode->i_mapping; - for (idx = 0; bytes; idx++) { - size_t op = bytes > PAGE_SIZE ? PAGE_SIZE : bytes; - struct page *page = read_mapping_page(mapping, idx, NULL); - void *kaddr; + while (bytes) { + struct folio *folio = read_mapping_folio(mapping, idx, NULL); + size_t nr; - if (IS_ERR(page)) - return PTR_ERR(page); + if (IS_ERR(folio)) + return PTR_ERR(folio); - kaddr = kmap_atomic(page); - memcpy(data, kaddr, op); - kunmap_atomic(kaddr); - - put_page(page); + nr = min(bytes, folio_size(folio)); + memcpy_from_folio(data, folio, 0, nr); + data += folio_size(folio); + idx += folio_nr_pages(folio); + folio_put(folio); - bytes -= op; - data = Add2Ptr(data, PAGE_SIZE); + bytes -= nr; } return 0; } From patchwork Mon Apr 22 19:31:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638870 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 754AE155337; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; cv=none; b=STXJJPG3U/ar5kkNQG04kmHsvQ5jnTVAaWF8uygndbt12Jy/B0te/sR+C8cC01BvJsnixXyCHpLwZUUEDsKrseNdAuz51n8AA5mLHcSLRD+NNv+lFNmDvUf0Q16mVTlXPZJPOYHEcpGbSX7fkt3DhBWISYfnol2cj1EuMknTons= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814330; c=relaxed/simple; bh=tERkkz+OidP4hJG26tVfRmFrV25vThKw4AzSVjA4s3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z7tklOoZXW/Eap75lynnUyR+MQXVqrT9O74dTW+tSgqTy3xj5Diyc1g9dNVUTyCE0ahtjsyce57iAPzDUal9RyieoMSYLYcPmF0AuNYNyxpYim80t8YFTEpNwCFgkbhtbxpak0srt0FZ+2a3OYRR3UGZnJGPGl3ECR4NZqAUKsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=RudlPpTN; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RudlPpTN" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=Xhs9YsoqkfzNBPKy6dIZioGoUpWLhADU0Aa2P/wM/Pc=; b=RudlPpTNXlFaF5s/xfcZw6eFrV Ei/qgOADD0PsDE9CkTuPyqf2x2W3cSuqyE6H/LhrAoqqoU29pOJj4YLgA3e5FgkdVcu7XDf+tmctQ uTZo5KUaZrLJxuxccR38c6xznYizgLFAdHkiCwP5W5SneAXHmhxYQVIoR+fLnrZAVIRBeNkAgSp/W 46MqyBio9ikeyHCDaKjay/BQ2Sk+4zztp4aj7HikaaQsvDZOykkZYxFv7On8NbJbPpeDq5Hu/G8qc a4IkUxG+mxP4qu6jaetXPnUZc3+BjN3VG+P8DUKaebfs4SP1UOQsE2W4J3779aT1h4289yV4eTH0U ExeU/64A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOj-3S2V; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 08/11] ntfs3: Remove calls to set/clear the error flag Date: Mon, 22 Apr 2024 20:31:58 +0100 Message-ID: <20240422193203.3534108-9-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Nobody checks the error flag on ntfs3 folios, so stop setting and clearing it. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/frecord.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 0008670939a4..04a7509c749a 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -2143,9 +2143,6 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) err = ni_read_frame(ni, frame_vbo, pages, pages_per_frame); out1: - if (err) - SetPageError(page); - for (i = 0; i < pages_per_frame; i++) { pg = pages[i]; if (i == idx || !pg) @@ -2718,7 +2715,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, for (i = 0; i < pages_per_frame; i++) { pg = pages[i]; kunmap(pg); - ClearPageError(pg); SetPageUptodate(pg); } From patchwork Mon Apr 22 19:31:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638871 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88618155338; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; cv=none; b=SBgGhB8qw62/QM9dPK5gtlFAbeYmkouxI4uoLidQ0aeoTG91V0258tE474CFJPMPG12DbVuXn57ivztz5Ai1WEkW8ZkMkEOeSh9mWtuj4PCSbZfo9WogtYGy3vdTWsG5xQeAOsKQEysNu8iHHxBYFF1IW8+j+NK3IWL52co7dJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; c=relaxed/simple; bh=un/rh+jaMg2zCOO3wQpQ/Sq3RjFUSnYK1x53j/PaT40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CR8o6QZ6ZzqTdOzloQJq5fo1/kfn+yIZq3RpzCo0HmEGF6T6dAyQpV4Z35IjYA7S7BV78MAel4h6uo0Aj2w22aqVFN6umNUGNX7SP2oejYvI8FzitBv94Ex6MRRCtczvMVV7VNr5sFuvtpa4mFKVNgPGGoA3/A8kHfCOuMUqzgw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=dUfPNm9w; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="dUfPNm9w" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=Gose6lUnx3CFNSZPBuOPgtsBFwb0Mxan46iPwqLycDE=; b=dUfPNm9wOg53t5UlTzINa5VhEP YcN/Rcq6GIO3B1vlDWwkWl3hGglRF7zkRPMpHPCMQyB6WKbQfrW8FsivgxGrs75DVejfAUOQPP7jV kjzncZ8s7dRbp04bVpX2xaQSHncZ5DULBab+A28OphqE7Oxhv3HxLgziCvbJognjOR40+pP5cfYyC ch3xvBnctg/48DN62D9Hn+SxkE7H9yYAg2wJigpPFFxe7USECaPVBOLImEwmLw/FsDv8KUdY0ymse JIsRqP2a4bf2hD12sApSgEzTKieT+fgOoytHvjKVNfdxFeSbXFprDpL8oW/392mApB/kbYwmA4yKt VhA3GWfA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOZ-0000000EpOp-3um5; Mon, 22 Apr 2024 19:32:07 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 09/11] ntfs3: Convert attr_wof_frame_info() to use a folio Date: Mon, 22 Apr 2024 20:31:59 +0100 Message-ID: <20240422193203.3534108-10-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This involves converting all users of offs_page to offs_folio, but it's worth it because we get rid of a lot of hidden calls to compound_head(). We continue to use order-0 folios here, and convert back to a struct page to call ntfs_bio_pages(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/attrib.c | 29 +++++++++++++++-------------- fs/ntfs3/frecord.c | 12 ++++++------ fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index d253840c26cf..9ea19c834dff 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -1380,7 +1380,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, u32 voff; u8 bytes_per_off; char *addr; - struct page *page; + struct folio *folio; int i, err; __le32 *off32; __le64 *off64; @@ -1425,18 +1425,18 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, wof_size = le64_to_cpu(attr->nres.data_size); down_write(&ni->file.run_lock); - page = ni->file.offs_page; - if (!page) { - page = alloc_page(GFP_KERNEL); - if (!page) { + folio = ni->file.offs_folio; + if (!folio) { + folio = folio_alloc(GFP_KERNEL, 0); + if (!folio) { err = -ENOMEM; goto out; } - page->index = -1; - ni->file.offs_page = page; + folio->index = -1; + ni->file.offs_folio = folio; } - lock_page(page); - addr = page_address(page); + folio_lock(folio); + addr = folio_address(folio); if (vbo[1]) { voff = vbo[1] & (PAGE_SIZE - 1); @@ -1452,7 +1452,8 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, do { pgoff_t index = vbo[i] >> PAGE_SHIFT; - if (index != page->index) { + if (index != folio->index) { + struct page *page = &folio->page; u64 from = vbo[i] & ~(u64)(PAGE_SIZE - 1); u64 to = min(from + PAGE_SIZE, wof_size); @@ -1465,10 +1466,10 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, err = ntfs_bio_pages(sbi, run, &page, 1, from, to - from, REQ_OP_READ); if (err) { - page->index = -1; + folio->index = -1; goto out1; } - page->index = index; + folio->index = index; } if (i) { @@ -1506,7 +1507,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr, *ondisk_size = off[1] - off[0]; out1: - unlock_page(page); + folio_unlock(folio); out: up_write(&ni->file.run_lock); return err; @@ -2645,4 +2646,4 @@ bool attr_check(const struct ATTRIB *attr, struct ntfs_sb_info *sbi, ntfs_set_state(sbi, NTFS_DIRTY_ERROR); return false; -} \ No newline at end of file +} diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 04a7509c749a..b9b3f1bf1bc4 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -122,10 +122,10 @@ void ni_clear(struct ntfs_inode *ni) else { run_close(&ni->file.run); #ifdef CONFIG_NTFS3_LZX_XPRESS - if (ni->file.offs_page) { + if (ni->file.offs_folio) { /* On-demand allocated page for offsets. */ - put_page(ni->file.offs_page); - ni->file.offs_page = NULL; + folio_put(ni->file.offs_folio); + ni->file.offs_folio = NULL; } #endif } @@ -2359,9 +2359,9 @@ int ni_decompress_file(struct ntfs_inode *ni) /* Clear cached flag. */ ni->ni_flags &= ~NI_FLAG_COMPRESSED_MASK; - if (ni->file.offs_page) { - put_page(ni->file.offs_page); - ni->file.offs_page = NULL; + if (ni->file.offs_folio) { + folio_put(ni->file.offs_folio); + ni->file.offs_folio = NULL; } mapping->a_ops = &ntfs_aops; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 275def366443..fbd14776bd28 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -394,7 +394,7 @@ struct ntfs_inode { struct rw_semaphore run_lock; struct runs_tree run; #ifdef CONFIG_NTFS3_LZX_XPRESS - struct page *offs_page; + struct folio *offs_folio; #endif } file; }; From patchwork Mon Apr 22 19:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638873 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEFD415533A; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; cv=none; b=PGKmL13Tu/BuGDgVHlzqTUGdFU9rhcCWOmQbmZS/p/BzDfE6xXILDjqphmf7dc/jrG4nL5yyEUEmPEtIM8XPPOm6BX7rlJZ/OtAO7sVT8V5xUzB5VIsAlpEvwTxV2z5oHidXDaGwn0DZRTinkAgE3tioWX0A8ws6maGcEw+AvdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; c=relaxed/simple; bh=uPDerVXe2UZggM4wJuFXw0DncMuTpdmYUfyGZ6A17Mw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=El14krWffGM8fN/kBLBcwqhYWVgu975V8B5lvGGJukChHJ9ENv4d8vNLaQ+pH2Z60V/prYH2iQu4pzJjy+UGhhmgJThDvNTxaXcFOkhmyEELpjXCgZgPhHdAWfbGDiHhRpv491E37yRdlkSniAJEtl5YeS8yD5Cbd3D32FLc4e4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=DL4BNm07; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="DL4BNm07" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=PJmvraMWuUCE1znYmS9Vz7eaEL+OTUYhdOXwfVsOtUU=; b=DL4BNm07bSN3bTA/2ka59ScY8S IedTvbDQbAEsar/hHdFAEW1radzoneH1CHvdscrDfyKs5s1j8BgT0MKvXfxNIY1cTk5DJzsQXxjW2 61F3gaopTvU9ebGPNb8MntSrEvXsC+Klc4VJOAJeP+E6RcK28W+ZNRgGdrxXVyzbLBXvCiCTp0r04 RJZ/81Gp+rYKEfoWkDz7GGX3G6fWYeXm9YEbq7ftiDHc+u4STrzj2Bydev/cnZnrDERkv9p3O/Pck zoKBxz9zQbihqbeAZPuFDStamwU9M1gYXFqc/S/+hguhKnC3J33ZHt6ksKUWq5Urzan00OEOp+cPI SFNLyAlg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOa-0000000EpOv-0HUV; Mon, 22 Apr 2024 19:32:08 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 10/11] ntfs3: Convert ntfs_get_frame_pages() to use a folio Date: Mon, 22 Apr 2024 20:32:00 +0100 Message-ID: <20240422193203.3534108-11-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The function still takes an array of pages, but use a folio internally. This function would deadlock against itself if used with large folios (as it locks each page), so we can be a little sloppy with the conversion back from folio to page for now. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/file.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 2f903b6ce157..40d3e7d0567a 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -824,23 +824,24 @@ static int ntfs_get_frame_pages(struct address_space *mapping, pgoff_t index, *frame_uptodate = true; for (npages = 0; npages < pages_per_frame; npages++, index++) { - struct page *page; + struct folio *folio; - page = find_or_create_page(mapping, index, gfp_mask); - if (!page) { + folio = __filemap_get_folio(mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp_mask); + if (IS_ERR(folio)) { while (npages--) { - page = pages[npages]; - unlock_page(page); - put_page(page); + folio = page_folio(pages[npages]); + folio_unlock(folio); + folio_put(folio); } return -ENOMEM; } - if (!PageUptodate(page)) + if (!folio_test_uptodate(folio)) *frame_uptodate = false; - pages[npages] = page; + pages[npages] = &folio->page; } return 0; From patchwork Mon Apr 22 19:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13638872 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD111155339; Mon, 22 Apr 2024 19:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; cv=none; b=QHAbt6H7Zw39ymHVPvv4PkbKc/DQszw3/ewcj90VIycPNDNRqYrJMsfKDgjkS25OuAVH/5rUwyWu58az0Yqaq+QA+ip+Cykz+Yc56iKiHlG5s2LFZFrBNV5eNDnkx3yzqVRVKyJcwkGz1NHum397lweax+0Lpsv3hUaFRDYInk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713814331; c=relaxed/simple; bh=LpZc72gzqE/Pv0ySlYm5ZvuYOTORD1siYYa8+QQwGGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DgyTlI9yiYHmC/eVOednC01sJaUoszVTb24z61GoRxHbqihdqsI8PfLa5jOJ3jyqetJuIJll/xwTnAAIU4oJ2sYsS6SQa2icWOr6Xn4BJzZDHNQaBOAIlu9kD8MvbhYNsfx8wdc63hzwxmgVTonumYlHVdCYp9yg1U61fkrLHbU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ee7aJteb; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ee7aJteb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=awc5S9zitEVRfBIVdnQPa9cbPN2/bjCfocFocfbIYXM=; b=ee7aJtebYNTdZtG9Ms6bpPAYGZ 2tAZ0gSYMm74xYOD9JbRvAWcSXfibUb1wReLuDEbF799EqW6i16diJth/NdL2k5PMnnup4UJq721y FI7pmf3XCUPFetDdg8zUElQ3MR6rSvwRRkmE9TEw5cvVB1hVeNwwIICbwxdy57UAsdOwir6z82eI6 RmqKoa+j32CH0lfFbbRfEGYAzfVp93eA7CiRdZZG3PP/2rltevyqHvTXOQykNv0dn3hG5k8Jsp8Ri NY2r410UZFuhmf+gzSBMM3AW97jHbVSmBxpPphN7/BjbO9qDdmgdiHVQP2bpBJ6h0JAgnjkwBJRiM 7ZwzDM/g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryzOa-0000000EpP1-0sNJ; Mon, 22 Apr 2024 19:32:08 +0000 From: "Matthew Wilcox (Oracle)" To: Konstantin Komarov Cc: "Matthew Wilcox (Oracle)" , ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 11/11] ntfs3: Convert ni_readpage_cmpr() to take a folio Date: Mon, 22 Apr 2024 20:32:01 +0100 Message-ID: <20240422193203.3534108-12-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422193203.3534108-1-willy@infradead.org> References: <20240422193203.3534108-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We still use an array of pages for the decompression, but this removes a few calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/ntfs3/frecord.c | 13 +++++++------ fs/ntfs3/inode.c | 2 +- fs/ntfs3/ntfs_fs.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index b9b3f1bf1bc4..8b1139fd5359 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -2085,12 +2085,12 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, * When decompressing, we typically obtain more than one page per reference. * We inject the additional pages into the page cache. */ -int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) +int ni_readpage_cmpr(struct ntfs_inode *ni, struct folio *folio) { int err; struct ntfs_sb_info *sbi = ni->mi.sbi; - struct address_space *mapping = page->mapping; - pgoff_t index = page->index; + struct address_space *mapping = folio->mapping; + pgoff_t index = folio->index; u64 frame_vbo, vbo = (u64)index << PAGE_SHIFT; struct page **pages = NULL; /* Array of at most 16 pages. stack? */ u8 frame_bits; @@ -2100,7 +2100,8 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) struct page *pg; if (vbo >= i_size_read(&ni->vfs_inode)) { - SetPageUptodate(page); + folio_zero_range(folio, 0, folio_size(folio)); + folio_mark_uptodate(folio); err = 0; goto out; } @@ -2124,7 +2125,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) goto out; } - pages[idx] = page; + pages[idx] = &folio->page; index = frame_vbo >> PAGE_SHIFT; gfp_mask = mapping_gfp_mask(mapping); @@ -2154,7 +2155,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page) out: /* At this point, err contains 0 or -EIO depending on the "critical" page. */ kfree(pages); - unlock_page(page); + folio_unlock(folio); return err; } diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index 4791a002500b..ef32be41b860 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -727,7 +727,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio) if (is_compressed(ni)) { ni_lock(ni); - err = ni_readpage_cmpr(ni, &folio->page); + err = ni_readpage_cmpr(ni, folio); ni_unlock(ni); return err; } diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index fbd14776bd28..3b50c4357a46 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -577,7 +577,7 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint); #define _ni_write_inode(i, w) ni_write_inode(i, w, __func__) int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, __u64 vbo, __u64 len); -int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page); +int ni_readpage_cmpr(struct ntfs_inode *ni, struct folio *folio); int ni_decompress_file(struct ntfs_inode *ni); int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, u32 pages_per_frame);