From patchwork Thu Jan 18 19:46:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13523132 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73F6F1F60B for ; Thu, 18 Jan 2024 19:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607157; cv=none; b=Kjpw/DzksXoq0YTKOdmHUbrDmuxEJO1yNRwrOkxeTgud98Tb8n14JD43EITDNJF2W1mcOlgjjrNghXw0FmipIypyr2puIv4NCoLKaALp+XcRxfILGIV4lNFoUgHEtZF4u8P4E0aqwt5P1YCWBcmCuoDowj5lpG0TX2FUHXmL9Vo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607157; c=relaxed/simple; bh=vxyWSzU0gwOUfz9Z4jBSE2xgGhm8X7CngfpbrnQM2t4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=olsYYDolw/m/vIz8xr6FUH0COBo+JnBOLfzHwANVqi4Xab7RWrMf/7e1PtVxGjyoDnNc+WxzO+96J3OaLov0QEM3Hy2LrRxNYvXwqRRqCzydeJZFaKKuFU4H9JDdgeo2vym5F3AgovCI2NnjiY5TXLmI7ah23wuFiCj7H6cAXiQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=dhTjeJMJ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NGd1QOKZ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=dhTjeJMJ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NGd1QOKZ; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="dhTjeJMJ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NGd1QOKZ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="dhTjeJMJ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NGd1QOKZ" Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 798ED21F11; Thu, 18 Jan 2024 19:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2obv1KZdvwObIEbwSR24IeaLWASP1pCuoUYN8krtqu8=; b=dhTjeJMJRNvakG9dnLXXarhla/9CAggsqhf8xXTMdiWcjO1lFKFPjOOqPbe8TicG5RrEEQ V0cWD/Z7LwU4PgYcsukxFSocG4isA1ragu/p1JxWD26MVLwalWBy35ozrB1EMHRd0ZYeBl 8xnD192zJqqb5Opi/hjMp+eE2EDG+UY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2obv1KZdvwObIEbwSR24IeaLWASP1pCuoUYN8krtqu8=; b=NGd1QOKZW5l2+OY5dx2eFTAdEanMRDJ1J1kf95XXz6TOCAbIEcj67mhbYQKQPWxsYTh5Ep nA74frS1xTpkcVAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2obv1KZdvwObIEbwSR24IeaLWASP1pCuoUYN8krtqu8=; b=dhTjeJMJRNvakG9dnLXXarhla/9CAggsqhf8xXTMdiWcjO1lFKFPjOOqPbe8TicG5RrEEQ V0cWD/Z7LwU4PgYcsukxFSocG4isA1ragu/p1JxWD26MVLwalWBy35ozrB1EMHRd0ZYeBl 8xnD192zJqqb5Opi/hjMp+eE2EDG+UY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607153; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2obv1KZdvwObIEbwSR24IeaLWASP1pCuoUYN8krtqu8=; b=NGd1QOKZW5l2+OY5dx2eFTAdEanMRDJ1J1kf95XXz6TOCAbIEcj67mhbYQKQPWxsYTh5Ep nA74frS1xTpkcVAQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 25CB81377F; Thu, 18 Jan 2024 19:45:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id d0aeAPF/qWW5BQAAn2gu4w (envelope-from ); Thu, 18 Jan 2024 19:45:53 +0000 From: Goldwyn Rodrigues To: linux-btrfs@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PATCH 1/4] btrfs: Use IS_ERR() instead of checking folio for NULL Date: Thu, 18 Jan 2024 13:46:37 -0600 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: ** X-Spamd-Bar: ++ Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=dhTjeJMJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=NGd1QOKZ X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [2.49 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[26.89%] X-Spam-Score: 2.49 X-Rspamd-Queue-Id: 798ED21F11 X-Spam-Flag: NO From: Goldwyn Rodrigues __filemap_get_folio() returns an error instead of a NULL pointer. Use IS_ERR() to check if folio is not returned. As we are fixing this, use set_folio_extent_mapped() instead of set_page_extent_mapped(). Fixes: f8809b1f6a3e btrfs: page to folio conversion in btrfs_truncate_block() Signed-off-by: Goldwyn Rodrigues Reviewed-by: Boris Burkov --- fs/btrfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7199670599d9..25090d23834b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4714,7 +4714,7 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len, again: folio = __filemap_get_folio(mapping, index, FGP_LOCK | FGP_ACCESSED | FGP_CREAT, mask); - if (!folio) { + if (IS_ERR(folio)) { btrfs_delalloc_release_space(inode, data_reserved, block_start, blocksize, true); btrfs_delalloc_release_extents(inode, blocksize); @@ -4742,7 +4742,7 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len, * folio private, but left the page in the mapping. Set the page mapped * here to make sure it's properly set for the subpage stuff. */ - ret = set_page_extent_mapped(&folio->page); + ret = set_folio_extent_mapped(folio); if (ret < 0) goto out_unlock; From patchwork Thu Jan 18 19:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13523134 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B1FF2E636 for ; Thu, 18 Jan 2024 19:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607167; cv=none; b=MFyu/eDHQukqAW4+dwxi6bs7WoL/aTKJa4s5ulRxkU5IUyD8HJHDzkDb4nEWa1abZv9NMv/83ELMcmA7QqLjAU+e9gUaoxbqctPt9vkJiAfqLswF3AOEqlIEzWv6dmj6rwb1lno7mHmgADojV4aRe/T7I5uHSg5WCK8ZxxiFkzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607167; c=relaxed/simple; bh=YW3UAvSHFC2Q+0/W0QxQ4yNw4EzKhPiH8V8nNQNyCeM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kXtrJHEOQkWAisw4qDyIUN85sSto6jEMcYkjwMwP6QHJkfKU1KeSUNB0fMFw0n0oSO3WeHwKV1Wq4tx8BIU7btujJZ42X12bzYiq2sFOVOsYGKGrZ6nfqYT+PPfRPjvUepVoC8OVaUqg88PRYzyVaS7qH3rgBer6Vgx2SSBZvMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=obGBS5L2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M4qz+HCZ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=obGBS5L2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=M4qz+HCZ; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="obGBS5L2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M4qz+HCZ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="obGBS5L2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="M4qz+HCZ" Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 443091F7B1; Thu, 18 Jan 2024 19:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgPjuXDEbzhkctXiSBhikWu3zqZDImzfP3ch9OKJ/Uw=; b=obGBS5L2/WlXDX4qOmSSmsfL9xusBL2+/3Ec2J0guqngDSy2wL9TT6xM2S76uDygdoMbiX ekmoEuYwkiwRuVjH8G+3Ivhqy8n0Fjfk0Z/8uUqhEtI840NnAxz0eB+0rtlr+OYh7C7OeT STCL9Td9VeKLFtdsiH/cZW0AYGHewFM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgPjuXDEbzhkctXiSBhikWu3zqZDImzfP3ch9OKJ/Uw=; b=M4qz+HCZkstZyIzGqQU9p4I2S2Yo4qq9U6RIdD39z3LbKSZXfocxsWP3pHhGBhzX065iLF ukxHHSTtQvPLvCDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgPjuXDEbzhkctXiSBhikWu3zqZDImzfP3ch9OKJ/Uw=; b=obGBS5L2/WlXDX4qOmSSmsfL9xusBL2+/3Ec2J0guqngDSy2wL9TT6xM2S76uDygdoMbiX ekmoEuYwkiwRuVjH8G+3Ivhqy8n0Fjfk0Z/8uUqhEtI840NnAxz0eB+0rtlr+OYh7C7OeT STCL9Td9VeKLFtdsiH/cZW0AYGHewFM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgPjuXDEbzhkctXiSBhikWu3zqZDImzfP3ch9OKJ/Uw=; b=M4qz+HCZkstZyIzGqQU9p4I2S2Yo4qq9U6RIdD39z3LbKSZXfocxsWP3pHhGBhzX065iLF ukxHHSTtQvPLvCDw== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id E97271377F; Thu, 18 Jan 2024 19:45:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id tz8BKPN/qWXBBQAAn2gu4w (envelope-from ); Thu, 18 Jan 2024 19:45:55 +0000 From: Goldwyn Rodrigues To: linux-btrfs@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PATCH 2/4] btrfs: page to folio conversion: prealloc_file_extent_cluster() Date: Thu, 18 Jan 2024 13:46:38 -0600 Message-ID: <55f236028fe97c2119ad8aa51cc6e5fe0cb04d0b.1705605787.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [3.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[24.58%] X-Spam-Level: *** X-Spam-Score: 3.90 X-Spam-Flag: NO From: Goldwyn Rodrigues Convert usage of page to folio in prealloc_file_extent_cluster(). This converts all page-based function calls to folio-based. Signed-off-by: Goldwyn Rodrigues Reviewed-by: Boris Burkov Reviewed-by: David Sterba --- fs/btrfs/relocation.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index abe594f77f99..c365bfc60652 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2858,7 +2858,7 @@ static noinline_for_stack int prealloc_file_extent_cluster( struct address_space *mapping = inode->vfs_inode.i_mapping; struct btrfs_fs_info *fs_info = inode->root->fs_info; const u32 sectorsize = fs_info->sectorsize; - struct page *page; + struct folio *folio; ASSERT(sectorsize < PAGE_SIZE); ASSERT(IS_ALIGNED(i_size, sectorsize)); @@ -2889,16 +2889,16 @@ static noinline_for_stack int prealloc_file_extent_cluster( clear_extent_bits(&inode->io_tree, i_size, round_up(i_size, PAGE_SIZE) - 1, EXTENT_UPTODATE); - page = find_lock_page(mapping, i_size >> PAGE_SHIFT); + folio = filemap_lock_folio(mapping, i_size >> PAGE_SHIFT); /* * If page is freed we don't need to do anything then, as we * will re-read the whole page anyway. */ - if (page) { - btrfs_subpage_clear_uptodate(fs_info, page_folio(page), i_size, + if (!IS_ERR(folio)) { + btrfs_subpage_clear_uptodate(fs_info, folio, i_size, round_up(i_size, PAGE_SIZE) - i_size); - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); } } From patchwork Thu Jan 18 19:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13523133 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8683B1F60B for ; Thu, 18 Jan 2024 19:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607162; cv=none; b=LCIU0frgBYOdr7nECioThSIjHr8nCbxalYF4zlc2KR2fLWr9tTeTh6Y1DRRRPw8Sbd74++ouhYP4k7B3vLNYRc98SBMzo59N9taYQUn7KHhZMwMYpo3TBgpgGYRwXHFKmHTh+A6QYYTV0boOLn7NnfHtsIbulrO+v5ZGEGxDafU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607162; c=relaxed/simple; bh=Y7W+V9Nj6SkQqmIf24Nu/6ougagE2xvegXb0+Y/4uyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CCUCLSUSnlE1f2grVqGQSuzbpD4epxBAhZHOax6Mr15m8uu9GzgPRYmlHLhfv+qOtJBohYDaMZEpqDZtQzap52A1aTUKBDXLKFyv5mB2aa8t8l21xYLCZqyIYcUuovCUYxOMbY+lZB+gaXH+3q5je/DIdH5FFESBeIvl/v/Cy5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=CV42lht2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=R6h6ZvUv; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=CV42lht2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=R6h6ZvUv; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="CV42lht2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="R6h6ZvUv"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="CV42lht2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="R6h6ZvUv" Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A89D521F11; Thu, 18 Jan 2024 19:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607158; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtudMYi1LPxzoCq/0dlekeCdYlVJYaXuyMraM8ChY94=; b=CV42lht2tgVGqML7oymYToZ8Tk6e6mVTAWKx81ZqdwKjw3wwq9h89MZ3aVAXZWN20kkLkW a6M+f0Q+ljQ1D2/flWNSD3+x+Vl2nR/mRLTYuS6MaUPoS4Kv/z/+G4sdb1QY5hbX/O9DN0 BQUxLOFPNpypSo+andzSVPY2aRPVo5A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607158; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtudMYi1LPxzoCq/0dlekeCdYlVJYaXuyMraM8ChY94=; b=R6h6ZvUvImZGZ6rkYjAMURY7K0fYSk4zhoEOs0Kp/LeGhBUHu6di12eo4xZixnxO8x8gqI yugrcZZoAcsX5BCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607158; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtudMYi1LPxzoCq/0dlekeCdYlVJYaXuyMraM8ChY94=; b=CV42lht2tgVGqML7oymYToZ8Tk6e6mVTAWKx81ZqdwKjw3wwq9h89MZ3aVAXZWN20kkLkW a6M+f0Q+ljQ1D2/flWNSD3+x+Vl2nR/mRLTYuS6MaUPoS4Kv/z/+G4sdb1QY5hbX/O9DN0 BQUxLOFPNpypSo+andzSVPY2aRPVo5A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607158; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HtudMYi1LPxzoCq/0dlekeCdYlVJYaXuyMraM8ChY94=; b=R6h6ZvUvImZGZ6rkYjAMURY7K0fYSk4zhoEOs0Kp/LeGhBUHu6di12eo4xZixnxO8x8gqI yugrcZZoAcsX5BCg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 4D7971377F; Thu, 18 Jan 2024 19:45:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id lgzSA/Z/qWXEBQAAn2gu4w (envelope-from ); Thu, 18 Jan 2024 19:45:58 +0000 From: Goldwyn Rodrigues To: linux-btrfs@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PATCH 3/4] btrfs: convert relocate_one_page() to relocate_one_folio() Date: Thu, 18 Jan 2024 13:46:39 -0600 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=CV42lht2; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=R6h6ZvUv X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-0.51 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_TWO(0.00)[2]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -0.51 X-Rspamd-Queue-Id: A89D521F11 X-Spam-Flag: NO From: Goldwyn Rodrigues Convert page references to folios and call the respective folio functions. Since find_or_create_page() takes a mask argument, call __filemap_get_folio() instead of filemap_grab_folio(). Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/relocation.c | 87 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index c365bfc60652..f4fd4257adae 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2849,7 +2849,7 @@ static noinline_for_stack int prealloc_file_extent_cluster( * btrfs_do_readpage() call of previously relocated file cluster. * * If the current cluster starts in the above range, btrfs_do_readpage() - * will skip the read, and relocate_one_page() will later writeback + * will skip the read, and relocate_one_folio() will later writeback * the padding zeros as new data, causing data corruption. * * Here we have to manually invalidate the range (i_size, PAGE_END + 1). @@ -2983,68 +2983,69 @@ static u64 get_cluster_boundary_end(const struct file_extent_cluster *cluster, return cluster->boundary[cluster_nr + 1] - 1; } -static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, +static int relocate_one_folio(struct inode *inode, struct file_ra_state *ra, const struct file_extent_cluster *cluster, - int *cluster_nr, unsigned long page_index) + int *cluster_nr, unsigned long index) { struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); u64 offset = BTRFS_I(inode)->index_cnt; const unsigned long last_index = (cluster->end - offset) >> PAGE_SHIFT; gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping); - struct page *page; - u64 page_start; - u64 page_end; + struct folio *folio; + u64 start; + u64 end; u64 cur; int ret; - ASSERT(page_index <= last_index); - page = find_lock_page(inode->i_mapping, page_index); - if (!page) { + ASSERT(index <= last_index); + folio = filemap_lock_folio(inode->i_mapping, index); + if (IS_ERR(folio)) { page_cache_sync_readahead(inode->i_mapping, ra, NULL, - page_index, last_index + 1 - page_index); - page = find_or_create_page(inode->i_mapping, page_index, mask); - if (!page) - return -ENOMEM; + index, last_index + 1 - index); + folio = __filemap_get_folio(inode->i_mapping, index, + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, mask); + if (IS_ERR(folio)) + return PTR_ERR(folio); } - if (PageReadahead(page)) + if (folio_test_readahead(folio)) page_cache_async_readahead(inode->i_mapping, ra, NULL, - page_folio(page), page_index, - last_index + 1 - page_index); + folio, index, + last_index + 1 - index); - if (!PageUptodate(page)) { - btrfs_read_folio(NULL, page_folio(page)); - lock_page(page); - if (!PageUptodate(page)) { + if (!folio_test_uptodate(folio)) { + btrfs_read_folio(NULL, folio); + folio_lock(folio); + if (!folio_test_uptodate(folio)) { ret = -EIO; - goto release_page; + goto release; } } /* - * We could have lost page private when we dropped the lock to read the - * page above, make sure we set_page_extent_mapped here so we have any + * We could have lost folio private when we dropped the lock to read the + * folio above, make sure we set_page_extent_mapped here so we have any * of the subpage blocksize stuff we need in place. */ - ret = set_page_extent_mapped(page); + ret = set_folio_extent_mapped(folio); if (ret < 0) - goto release_page; + goto release; - page_start = page_offset(page); - page_end = page_start + PAGE_SIZE - 1; + start = folio_pos(folio); + end = start + PAGE_SIZE - 1; /* * Start from the cluster, as for subpage case, the cluster can start - * inside the page. + * inside the folio. */ - cur = max(page_start, cluster->boundary[*cluster_nr] - offset); - while (cur <= page_end) { + cur = max(start, cluster->boundary[*cluster_nr] - offset); + while (cur <= end) { struct extent_state *cached_state = NULL; u64 extent_start = cluster->boundary[*cluster_nr] - offset; u64 extent_end = get_cluster_boundary_end(cluster, *cluster_nr) - offset; - u64 clamped_start = max(page_start, extent_start); - u64 clamped_end = min(page_end, extent_end); + u64 clamped_start = max(start, extent_start); + u64 clamped_end = min(end, extent_end); u32 clamped_len = clamped_end + 1 - clamped_start; /* Reserve metadata for this range */ @@ -3052,7 +3053,7 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, clamped_len, clamped_len, false); if (ret) - goto release_page; + goto release; /* Mark the range delalloc and dirty for later writeback */ lock_extent(&BTRFS_I(inode)->io_tree, clamped_start, clamped_end, @@ -3068,20 +3069,20 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, clamped_len, true); btrfs_delalloc_release_extents(BTRFS_I(inode), clamped_len); - goto release_page; + goto release; } - btrfs_folio_set_dirty(fs_info, page_folio(page), + btrfs_folio_set_dirty(fs_info, folio, clamped_start, clamped_len); /* - * Set the boundary if it's inside the page. + * Set the boundary if it's inside the folio. * Data relocation requires the destination extents to have the * same size as the source. * EXTENT_BOUNDARY bit prevents current extent from being merged * with previous extent. */ if (in_range(cluster->boundary[*cluster_nr] - offset, - page_start, PAGE_SIZE)) { + start, PAGE_SIZE)) { u64 boundary_start = cluster->boundary[*cluster_nr] - offset; u64 boundary_end = boundary_start + @@ -3104,8 +3105,8 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, break; } } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); balance_dirty_pages_ratelimited(inode->i_mapping); btrfs_throttle(fs_info); @@ -3113,9 +3114,9 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra, ret = -ECANCELED; return ret; -release_page: - unlock_page(page); - put_page(page); +release: + folio_unlock(folio); + folio_put(folio); return ret; } @@ -3150,7 +3151,7 @@ static int relocate_file_extent_cluster(struct inode *inode, last_index = (cluster->end - offset) >> PAGE_SHIFT; for (index = (cluster->start - offset) >> PAGE_SHIFT; index <= last_index && !ret; index++) - ret = relocate_one_page(inode, ra, cluster, &cluster_nr, index); + ret = relocate_one_folio(inode, ra, cluster, &cluster_nr, index); if (ret == 0) WARN_ON(cluster_nr != cluster->nr); out: From patchwork Thu Jan 18 19:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 13523135 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66E732E63A for ; Thu, 18 Jan 2024 19:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607169; cv=none; b=oW1oiU7CczKJbeV+azmGKSoqKM01QMlILXQhAJDtk8qWzBZLJ8zrEvBhms74TYOXJQKtLEIlg0ZMHOZ7nsGJrTLlyxgT6vGrDVtw+Le6vsQR4+fDKnJg9pygh8syvZqbHX1q/7e+Kpxd+VE9ELw2+2ANZvM2pJEx+UF2OOqAX48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705607169; c=relaxed/simple; bh=i4q4xaM1FKLb5VI7Teirkw4YMH05Ce4E99vvNFeKp7c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RTgTN67ib+XLeM9EX6tlhbBYQr7UmNB7jiXMk/V384JkL0L7pvSua9bkzj9CrX0z0q3KhI7OjtzJb0nRiY0eXLwfqcaLo5805Py/HEKhrB+dtesI+lLaRxWcvYZvD2hgdIdoIcHuATOpPjpFLD3Ugr0NRHeSbWmtX04xtsiPmDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=RZhg3WfZ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=VhplqZ38; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=RZhg3WfZ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=VhplqZ38; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RZhg3WfZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="VhplqZ38"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RZhg3WfZ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="VhplqZ38" Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4BB761F7B2; Thu, 18 Jan 2024 19:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607161; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xDT3Sy2ogE8OdnJMJ5ptjroZAUL2KlFRubUbBU5ERzY=; b=RZhg3WfZcDjodSnA0OxbuWt/hn2qb3TGTRXEqW2BGB7eWo6AaMe0a/7hVWLqu7yY6nYzcv iImYOJVJ1gF3dMTvT+vFd4wv3zNr5qwODF7vnlSr1NWc9JCIFG1WXfXw0YjjxOMOvYh46N z15W3GXtFY1JCuyTywLg4VfuTiqDV5Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607161; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xDT3Sy2ogE8OdnJMJ5ptjroZAUL2KlFRubUbBU5ERzY=; b=VhplqZ380nL5i45GLqhwDnV2LbC856nF2dXVQsx2B+6CfYtOV0iBdxESyg3G6IogxLAPvo 0NPDbB6eSJNib9Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705607161; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xDT3Sy2ogE8OdnJMJ5ptjroZAUL2KlFRubUbBU5ERzY=; b=RZhg3WfZcDjodSnA0OxbuWt/hn2qb3TGTRXEqW2BGB7eWo6AaMe0a/7hVWLqu7yY6nYzcv iImYOJVJ1gF3dMTvT+vFd4wv3zNr5qwODF7vnlSr1NWc9JCIFG1WXfXw0YjjxOMOvYh46N z15W3GXtFY1JCuyTywLg4VfuTiqDV5Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705607161; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xDT3Sy2ogE8OdnJMJ5ptjroZAUL2KlFRubUbBU5ERzY=; b=VhplqZ380nL5i45GLqhwDnV2LbC856nF2dXVQsx2B+6CfYtOV0iBdxESyg3G6IogxLAPvo 0NPDbB6eSJNib9Ag== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id DB9A81377F; Thu, 18 Jan 2024 19:46:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id RS8sJ/h/qWXIBQAAn2gu4w (envelope-from ); Thu, 18 Jan 2024 19:46:00 +0000 From: Goldwyn Rodrigues To: linux-btrfs@vger.kernel.org Cc: Goldwyn Rodrigues Subject: [PATCH 4/4] btrfs: page to folio conversion in put_file_data() Date: Thu, 18 Jan 2024 13:46:40 -0600 Message-ID: <861fb1618d04ccb56c00ac78b4c6ca81dc9a59e4.1705605787.git.rgoldwyn@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=RZhg3WfZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=VhplqZ38 X-Spamd-Result: default: False [3.69 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_TWO(0.00)[2]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 3.69 X-Rspamd-Queue-Id: 4BB761F7B2 X-Spam-Level: *** X-Spam-Flag: NO X-Spamd-Bar: +++ From: Goldwyn Rodrigues Use folio instead of page in put_file_data(). This converts usage of all page based functions to folio-based. Signed-off-by: Goldwyn Rodrigues Reviewed-by: Boris Burkov --- fs/btrfs/send.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 7902298c1f25..0de3d4163f6b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -5257,10 +5257,11 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len) { struct btrfs_root *root = sctx->send_root; struct btrfs_fs_info *fs_info = root->fs_info; - struct page *page; + struct folio *folio; pgoff_t index = offset >> PAGE_SHIFT; pgoff_t last_index; unsigned pg_offset = offset_in_page(offset); + struct address_space *mapping = sctx->cur_inode->i_mapping; int ret; ret = put_data_header(sctx, len); @@ -5273,44 +5274,43 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len) unsigned cur_len = min_t(unsigned, len, PAGE_SIZE - pg_offset); - page = find_lock_page(sctx->cur_inode->i_mapping, index); - if (!page) { - page_cache_sync_readahead(sctx->cur_inode->i_mapping, + folio = filemap_lock_folio(mapping, index); + if (IS_ERR(folio)) { + page_cache_sync_readahead(mapping, &sctx->ra, NULL, index, last_index + 1 - index); - page = find_or_create_page(sctx->cur_inode->i_mapping, - index, GFP_KERNEL); - if (!page) { - ret = -ENOMEM; + folio = filemap_grab_folio(mapping, index); + if (IS_ERR(folio)) { + ret = PTR_ERR(folio); break; } } - if (PageReadahead(page)) - page_cache_async_readahead(sctx->cur_inode->i_mapping, - &sctx->ra, NULL, page_folio(page), + if (folio_test_readahead(folio)) + page_cache_async_readahead(mapping, + &sctx->ra, NULL, folio, index, last_index + 1 - index); - if (!PageUptodate(page)) { - btrfs_read_folio(NULL, page_folio(page)); - lock_page(page); - if (!PageUptodate(page)) { - unlock_page(page); + if (!folio_test_uptodate(folio)) { + btrfs_read_folio(NULL, folio); + folio_lock(folio); + if (!folio_test_uptodate(folio)) { + folio_unlock(folio); btrfs_err(fs_info, "send: IO error at offset %llu for inode %llu root %llu", - page_offset(page), sctx->cur_ino, + folio_pos(folio), sctx->cur_ino, sctx->send_root->root_key.objectid); - put_page(page); + folio_put(folio); ret = -EIO; break; } } - memcpy_from_page(sctx->send_buf + sctx->send_size, page, + memcpy_from_folio(sctx->send_buf + sctx->send_size, folio, pg_offset, cur_len); - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); index++; pg_offset = 0; len -= cur_len;