From patchwork Thu Oct 17 15:16: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: 13840218 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 75ABC1DED56; Thu, 17 Oct 2024 15:17:15 +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=1729178241; cv=none; b=fTsLpToZPiTS4uaqRhCA7OvtFq3EkFOxMkqnC8gWCuIktvIkYeiafvddvvY5LMrUQDZTr27wt7bHuuSEf9W706kZUQ1pPsUbPCfXEXV/p2hYIBYgiN4vjGPyC1x4Hu2N53+VcnZQWkMkk53DJbzhbrkrEQj5pe5F9bJP0sYQR4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729178241; c=relaxed/simple; bh=O23Gy//oeLZ55SVeNW28SgBcNWSa8ozwd5Oo71wrXH8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fmhJ2QAxCdW/i8NlziF9bjuLYrlXDaGuks4ufiYKuMiqQcAuyjs17oXj4Y3+I4MULDOs3t2H/kwnHWHFieBsNqyn5p8ZCSpxai2nGPerXg7Jobbojdmg0qyeLRLD3/pQJ8kyXnInJirVjQ1tUuPopq4cLKMVxs96aL9AI9UKBG4= 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=rzZ20EUx; 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="rzZ20EUx" 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=QvXLg6hq5jvQb9bvdZtTJRsSaVrN4g0Ygii5MFDj5NA=; b=rzZ20EUxGJWQ0Z22D6+KH7C0zx jhhNgAGMl0joCw7WPq5c5SOZoq8yEourvRLxPw7aS3WJm2G9gXGXdxxDXUItpZzNt4UAjrEma3iem txi9d1QzJ3DGt1zbK5g0q+hgiBKxfnjR5x1T32pTFU8zjgrX9hPpIqxX+rVkrmO+iTs8QKS2yxB9H O4YGsG4inPA4OKOKBIdJsHbHhGrNK2Qe3wT/kaPq+fMUkeocr+3nEX7Ok5ZoA0TvBXTC9+lXB4cdx KpzP+nM0dNNbaTnTHM78YZO2wRLA+SCFmR9deIbJTgSmhax7eaha3RQNC9lYoX3tbJFEGT2fvREUA IrY0TWYg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1SFS-0000000BNnF-3Kx4; Thu, 17 Oct 2024 15:17:10 +0000 From: "Matthew Wilcox (Oracle)" To: Tyler Hicks Cc: "Matthew Wilcox (Oracle)" , ecryptfs@vger.kernel.org, Christian Brauner , linux-fsdevel@vger.kernel.org Subject: [PATCH 01/10] ecryptfs: Convert ecryptfs_writepage() to ecryptfs_writepages() Date: Thu, 17 Oct 2024 16:16:56 +0100 Message-ID: <20241017151709.2713048-2-willy@infradead.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241017151709.2713048-1-willy@infradead.org> References: <20241017151709.2713048-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 By adding a ->migrate_folio implementation, theree is no need to keep the ->writepage implementation. The new writepages removes the unnecessary call to SetPageUptodate(); the folio should already be uptodate at this point. Signed-off-by: Matthew Wilcox (Oracle) --- fs/ecryptfs/mmap.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index ceda5555971a..92ea39d907de 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c @@ -38,32 +38,30 @@ struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index) return page; } -/** - * ecryptfs_writepage - * @page: Page that is locked before this call is made - * @wbc: Write-back control structure - * - * Returns zero on success; non-zero otherwise - * +/* * This is where we encrypt the data and pass the encrypted data to * the lower filesystem. In OpenPGP-compatible mode, we operate on * entire underlying packets. */ -static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc) +static int ecryptfs_writepages(struct address_space *mapping, + struct writeback_control *wbc) { - int rc; - - rc = ecryptfs_encrypt_page(page); - if (rc) { - ecryptfs_printk(KERN_WARNING, "Error encrypting " - "page (upper index [0x%.16lx])\n", page->index); - ClearPageUptodate(page); - goto out; + struct folio *folio = NULL; + int error; + + while ((folio = writeback_iter(mapping, wbc, folio, &error))) { + error = ecryptfs_encrypt_page(&folio->page); + if (error) { + ecryptfs_printk(KERN_WARNING, + "Error encrypting folio (index [0x%.16lx])\n", + folio->index); + folio_clear_uptodate(folio); + mapping_set_error(mapping, error); + } + folio_unlock(folio); } - SetPageUptodate(page); -out: - unlock_page(page); - return rc; + + return error; } static void strip_xattr_flag(char *page_virt, @@ -548,9 +546,10 @@ const struct address_space_operations ecryptfs_aops = { .dirty_folio = block_dirty_folio, .invalidate_folio = block_invalidate_folio, #endif - .writepage = ecryptfs_writepage, + .writepages = ecryptfs_writepages, .read_folio = ecryptfs_read_folio, .write_begin = ecryptfs_write_begin, .write_end = ecryptfs_write_end, + .migrate_folio = filemap_migrate_folio, .bmap = ecryptfs_bmap, };