From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795190052; b=oIoSsngQD01GR2iIN8JF+eQBGjXnQtEm6ISslIWClfNEKgI9ZX2jYztucN4FKjEvLqEI vbd3+D0wrphxRPKbBxslIlMwGd2x6rLmFWpouhpzfHmDl9u67BJ74dpL/O9zMwaFD4QKo W2M00TtoBCuhmsBqroPwmVMakRJ6ZeB9If5m+F1DLXOI38/1hHehvRNNiPyCDjQIpKbpq H0mTnXOTvULazdKyq8wpF+DH9Ia3Dkxw4CnZOZtKnlYR4BAzmePKwM4XeFO12hHrEO8wv K4NA7pBZzShztQpUhMP3UQVx/0AdDywFDYKsF2xRjFQtSgql4Qc16ZWLMyk9KsRaJuw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795190052; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=BEmjN19hVihStrPjxDxF4Brn9KqV1jRr6JDxOnO7/64=; b=ZohPKtJrKWG86+5xp87rc9qCsYzYvPweOQwTm5kOHNfvSQgvDEyDCoY3SD5Mpy3fCKO2 aFERztS2ro5xn2wpvoNA5aDfgvVaE664EAi0v0mwJK8BpUrBeMk+Flr7YhnqF2RBcwU3n 3hJhU/FRFYYLbgljRVz/rSQB3hFEZpvhwYC6KWr5gnI5GhUxrmmxhfPhOJoFPDav87Zht 5GMcWhDJL/h++r1iFTQUu6M3VAad2gWN56o5R3732hW87pGV2+94Lr9iXb0R3Vc1SnuPh zLfe98S+ZXSxKy0Jqt4JFQB6HhRbDsCniHw3B42UCHa1p+WAjOBpH6GYyYwj6zsvwuw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NFyuL0n6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D722E60A3825; Fri, 20 Nov 2026 15:54:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NFyuL0n6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 223B51F000E6; Fri, 20 Nov 2026 15:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795190052; bh=BEmjN19hVihStrPjxDxF4Brn9KqV1jRr6JDxOnO7/64=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NFyuL0n6C5AKQ1hhHIL4sFZTGr18tmSQegcbBIUOje0i5mXgT+UfzmsyIhuJCusiR RgE+ChanDc8RW+v72LSkGSA23gjX8ng7z9/sYmiF2DCodV38Lt2pWE9mwngDk+LudQ E9UnERvSBd64MHOWQ+mqhzoUOhAxv07KOQtyO5PxcH7k8duGCC6326MCBQxRi3VpoJ EAXLufJC/CGD78QUHttpIWTBQgxYP/OjusozlHg7hgXKTWBdYujbgP68YOASsplCBS uAiY4HSXzvTsMD8iRIjYWx+KQJMTlf+xQeHpveKjp3xgc6R5iijOMufRB1MDuGCgM6 K1mTSRuilnMDQ== From: Andrey Albershteyn To: "fsdevel" , "fsverity" , "linux-ext4" , "linux-btrfs" , "linux-f2fs" , "linux-xfs" , dsterba@suse.com, "Eric Biggers" , "Christian Brauner" Cc: Andrey Albershteyn , tytso@mit.edu, chao@kernel.org, jaegeuk@kernel.org, viro@zeniv.linux.org.uk, Christoph Hellwig Subject: [PATCH v3 6/7] ext4: use I_VERITY_BUILDING instead of private flags Date: Fri, 20 Nov 2026 16:50:28 +0100 Message-ID: <20261120155032.187246-7-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261120155032.187246-1-aalbersh@kernel.org> References: <20261120155032.187246-1-aalbersh@kernel.org> X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that the VFS tracks an inode whose Merkle tree is under construction via I_VERITY_BUILDING and handles the concurrent-enable guard in the generic fs-verity enable path, drop the per-filesystem runtime flags that duplicated this state. Replace ext4 own helper ext4_verity_in_progress() with fsverity_is_building(), and remove the EXT4_STATE_VERITY_IN_PROGRESS flags. The IS_ENABLED() guard is fine to remove now as fsverity_is_building() has stub for disabled fsverity. Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/ext4/ext4.h | 7 ------- fs/ext4/file.c | 2 +- fs/ext4/inode.c | 17 +++++++++-------- fs/ext4/ioctl.c | 3 +-- fs/ext4/verity.c | 19 ++++++------------- 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index bf0325ecbec7..c918fe9ae268 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2050,7 +2050,6 @@ enum { EXT4_STATE_MAY_INLINE_DATA, /* may have in-inode data */ EXT4_STATE_EXT_PRECACHED, /* extents have been precached */ EXT4_STATE_LUSTRE_EA_INODE, /* Lustre-style ea_inode */ - EXT4_STATE_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */ EXT4_STATE_FC_COMMITTING, /* Fast commit ongoing */ EXT4_STATE_FC_FLUSHING_DATA, /* Fast commit flushing data */ EXT4_STATE_ORPHAN_FILE, /* Inode orphaned in orphan file */ @@ -2129,12 +2128,6 @@ static inline int ext4_inode_state_wait_bit(int bit) #define EXT4_SB(sb) (sb) #endif -static inline bool ext4_verity_in_progress(struct inode *inode) -{ - return IS_ENABLED(CONFIG_FS_VERITY) && - ext4_test_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); -} - #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime /* diff --git a/fs/ext4/file.c b/fs/ext4/file.c index ad8985c529c6..a3bd2fe8e7f4 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -318,7 +318,7 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) * partial block that beyond the existing EOF, as it may contains * stale data written through mmap. */ - if (iocb->ki_pos > old_size && !ext4_verity_in_progress(inode)) { + if (iocb->ki_pos > old_size && !fsverity_is_building(inode)) { if (iocb->ki_flags & IOCB_NOWAIT) return -EAGAIN; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e3129353d4ed..13035eda826e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "ext4_jbd2.h" #include "ext4_extents.h" @@ -506,7 +507,7 @@ void ext4_check_map_extents_env(struct inode *inode) is_special_ino(inode->i_sb, inode->i_ino) || (inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) || ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE) || - ext4_verity_in_progress(inode)) + fsverity_is_building(inode)) return; WARN_ON_ONCE(!inode_is_locked(inode) && @@ -1493,7 +1494,7 @@ static int ext4_write_begin(const struct kiocb *iocb, if (ret) { bool extended = (pos + len > inode->i_size) && - !ext4_verity_in_progress(inode); + !fsverity_is_building(inode); folio_unlock(folio); /* @@ -1560,7 +1561,7 @@ static int ext4_write_end(const struct kiocb *iocb, loff_t old_size = inode->i_size; int ret = 0, ret2; int i_size_changed = 0; - bool verity = ext4_verity_in_progress(inode); + bool verity = fsverity_is_building(inode); trace_ext4_write_end(inode, pos, len, copied); @@ -1665,7 +1666,7 @@ static int ext4_journalled_write_end(const struct kiocb *iocb, int partial = 0; unsigned from, to; int size_changed = 0; - bool verity = ext4_verity_in_progress(inode); + bool verity = fsverity_is_building(inode); trace_ext4_journalled_write_end(inode, pos, len, copied); from = pos & (PAGE_SIZE - 1); @@ -2210,7 +2211,7 @@ static void mpage_submit_folio(struct mpage_da_data *mpd, struct folio *folio) size = i_size_read(mpd->inode); len = folio_size(folio); if (folio_pos(folio) + len > size && - !ext4_verity_in_progress(mpd->inode)) + !fsverity_is_building(mpd->inode)) len = size & (len - 1); ext4_bio_write_folio(&mpd->io_submit, folio, len); } @@ -2300,7 +2301,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd, ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1) >> inode->i_blkbits; - if (ext4_verity_in_progress(inode)) + if (fsverity_is_building(inode)) blocks = EXT_MAX_BLOCKS; do { @@ -2706,7 +2707,7 @@ static int mpage_journal_page_buffers(handle_t *handle, mpd->wbc->nr_to_write -= folio_nr_pages(folio); if (folio_pos(folio) + len > size && - !ext4_verity_in_progress(inode)) + !fsverity_is_building(inode)) len = size & (len - 1); return ext4_journal_folio_buffers(handle, folio, len); @@ -3271,7 +3272,7 @@ static int ext4_da_write_begin(const struct kiocb *iocb, index = pos >> PAGE_SHIFT; - if (ext4_nonda_switch(inode->i_sb) || ext4_verity_in_progress(inode)) { + if (ext4_nonda_switch(inode->i_sb) || fsverity_is_building(inode)) { *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; return ext4_write_begin(iocb, mapping, pos, len, foliop, fsdata); diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index e8e579498c99..d3db2e77ebda 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -575,8 +575,7 @@ static bool dax_compatible(struct inode *inode, unsigned int oldflags, if (flags & EXT4_DAX_FL) { if ((oldflags & EXT4_DAX_MUT_EXCL) || - ext4_test_inode_state(inode, - EXT4_STATE_VERITY_IN_PROGRESS)) { + fsverity_is_building(inode)) { return false; } } diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index 56fe3e5b33e0..0c8f5cc92d97 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -83,9 +83,6 @@ static int ext4_begin_enable_verity(struct file *filp) if (IS_DAX(inode) || ext4_test_inode_flag(inode, EXT4_INODE_DAX)) return -EINVAL; - if (ext4_verity_in_progress(inode)) - return -EBUSY; - /* * Since the file was opened readonly, we have to initialize the jbd * inode and quotas here and not rely on ->open() doing it. This must @@ -123,8 +120,6 @@ static int ext4_begin_enable_verity(struct file *filp) return PTR_ERR(handle); err = ext4_orphan_add(handle, inode); - if (err == 0) - ext4_set_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); ext4_journal_stop(handle); return err; @@ -185,10 +180,10 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc, goto cleanup; /* - * Write all pages (both data and verity metadata). Note that this must - * happen before clearing EXT4_STATE_VERITY_IN_PROGRESS; otherwise pages - * beyond i_size won't be written properly. For crash consistency, this - * also must happen before the verity inode flag gets persisted. + * Write all pages (both data and verity metadata). Note that this must + * happen before I_VERITY_BUILDING is cleared; otherwise pages beyond + * i_size won't be written properly. For crash consistency, this also + * must happen before the verity inode flag gets persisted. */ err = filemap_write_and_wait(inode->i_mapping); if (err) @@ -224,7 +219,6 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc, /* Now that rollback is no longer possible, set S_VERITY. */ ext4_set_inode_flags(inode, false); - ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); return 0; stop_and_cleanup: @@ -234,13 +228,12 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc, /* * Verity failed to be enabled, so clean up by truncating any verity * metadata that was written beyond i_size (both from cache and from - * disk), removing the inode from the orphan list (if it wasn't done - * already), and clearing EXT4_STATE_VERITY_IN_PROGRESS. + * disk) and removing the inode from the orphan list (if it wasn't done + * already). */ truncate_inode_pages(inode->i_mapping, inode->i_size); ext4_truncate(inode); ext4_orphan_del(NULL, inode); - ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); return err; } -- 2.54.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD64B606A32A for ; Fri, 20 Nov 2026 15:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.a=rsa-sha256 header.s=beta header.b=Gwh1VBHO; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.a=rsa-sha256 header.s=x header.b=P51D+0M6; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.a=rsa-sha256 header.s=x header.b=HM1iTScZ; dkim=neutral header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NFyuL0n6 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=C8TteSI5VLHmh3Vvxl5WjXZVkhVssEx4rnlsOkYdTlc=; b=Gwh1VBHOvsV1+ywkHiQ/jSsOQr ahkdIX9GqHHIirVXUxAc9gx0qLBshIoDUaE0VbLGaZRbjc1Z/NfodB9HSgRVC3Y9oIvqt+PHaGhQp H5oqthSWCNpU/nzWDDC9JoAGEcWjocLZ40bELkXfdRb0A7Weqw4fPww6JKrfrBatSODI=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xUQwO-000000004HB-1pNL; Fri, 20 Nov 2026 15:54:20 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xUQwN-000000004H1-0yKj for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Nov 2026 15:54:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=BEmjN19hVihStrPjxDxF4Brn9KqV1jRr6JDxOnO7/64=; b=P51D+0M6tTXTtkAaNPgxNynOlC XWZU3HkK+ikFhQi2zaolDMQ/FwAvnXkM+u2zzvBfK0iZHpy61juJ67HZbPCZxqp/vkfGJ5VaSWXz5 t4C2prrEDk2g49FD9hh1G7n7vGjZLfb7udX4KxSC7i8Kk2IDSbNchAjYV05u9j7ckbGk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BEmjN19hVihStrPjxDxF4Brn9KqV1jRr6JDxOnO7/64=; b=HM1iTScZ8SJLog14N8DuGMaCij 2uiElt3a4TrWbrIlAiAXoxTmaSKFZ2CKnwg1SrnjPoqt4dA6T9SGGDa8Dcef0GyHj3RP8GrICVt0n KdkJ9hl38U4/dGQnZip2Djlr2kCq/I2QcxAAAUPY6Pe154p3jKXBRjoDoANCWJ4YvODQ=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xUQwL-000000003yV-3Rf2 for linux-f2fs-devel@lists.sourceforge.net; Fri, 20 Nov 2026 15:54:19 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 8129D4574C; Fri, 20 Nov 2026 15:54:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 223B51F000E6; Fri, 20 Nov 2026 15:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795190052; bh=BEmjN19hVihStrPjxDxF4Brn9KqV1jRr6JDxOnO7/64=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NFyuL0n6C5AKQ1hhHIL4sFZTGr18tmSQegcbBIUOje0i5mXgT+UfzmsyIhuJCusiR RgE+ChanDc8RW+v72LSkGSA23gjX8ng7z9/sYmiF2DCodV38Lt2pWE9mwngDk+LudQ E9UnERvSBd64MHOWQ+mqhzoUOhAxv07KOQtyO5PxcH7k8duGCC6326MCBQxRi3VpoJ EAXLufJC/CGD78QUHttpIWTBQgxYP/OjusozlHg7hgXKTWBdYujbgP68YOASsplCBS uAiY4HSXzvTsMD8iRIjYWx+KQJMTlf+xQeHpveKjp3xgc6R5iijOMufRB1MDuGCgM6 K1mTSRuilnMDQ== To: "fsdevel" , "fsverity" , "linux-ext4" , "linux-btrfs" , "linux-f2fs" , "linux-xfs" , dsterba@suse.com, "Eric Biggers" , "Christian Brauner" Date: Fri, 20 Nov 2026 16:50:28 +0100 Message-ID: <20261120155032.187246-7-aalbersh@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261120155032.187246-1-aalbersh@kernel.org> References: <20261120155032.187246-1-aalbersh@kernel.org> X-Archived-By: MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Headers-End: 1xUQwL-000000003yV-3Rf2 Subject: [f2fs-dev] [PATCH v3 6/7] ext4: use I_VERITY_BUILDING instead of private flags X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrey Albershteyn via Linux-f2fs-devel Reply-To: Andrey Albershteyn Cc: tytso@mit.edu, viro@zeniv.linux.org.uk, jaegeuk@kernel.org, Andrey Albershteyn , Christoph Hellwig Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Now that the VFS tracks an inode whose Merkle tree is under construction via I_VERITY_BUILDING and handles the concurrent-enable guard in the generic fs-verity enable path, drop the per-filesystem runtime flags that duplicated this state. Replace ext4 own helper ext4_verity_in_progress() with fsverity_is_building(), and remove the EXT4_STATE_VERITY_IN_PROGRESS flags. The IS_ENABLED() guard is fine to remove now as fsverity_is_building() has stub for disabled fsverity. Signed-off-by: Andrey Albershteyn Reviewed-by: Christoph Hellwig --- fs/ext4/ext4.h | 7 ------- fs/ext4/file.c | 2 +- fs/ext4/inode.c | 17 +++++++++-------- fs/ext4/ioctl.c | 3 +-- fs/ext4/verity.c | 19 ++++++------------- 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index bf0325ecbec7..c918fe9ae268 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2050,7 +2050,6 @@ enum { EXT4_STATE_MAY_INLINE_DATA, /* may have in-inode data */ EXT4_STATE_EXT_PRECACHED, /* extents have been precached */ EXT4_STATE_LUSTRE_EA_INODE, /* Lustre-style ea_inode */ - EXT4_STATE_VERITY_IN_PROGRESS, /* building fs-verity Merkle tree */ EXT4_STATE_FC_COMMITTING, /* Fast commit ongoing */ EXT4_STATE_FC_FLUSHING_DATA, /* Fast commit flushing data */ EXT4_STATE_ORPHAN_FILE, /* Inode orphaned in orphan file */ @@ -2129,12 +2128,6 @@ static inline int ext4_inode_state_wait_bit(int bit) #define EXT4_SB(sb) (sb) #endif -static inline bool ext4_verity_in_progress(struct inode *inode) -{ - return IS_ENABLED(CONFIG_FS_VERITY) && - ext4_test_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); -} - #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime /* diff --git a/fs/ext4/file.c b/fs/ext4/file.c index ad8985c529c6..a3bd2fe8e7f4 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -318,7 +318,7 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from) * partial block that beyond the existing EOF, as it may contains * stale data written through mmap. */ - if (iocb->ki_pos > old_size && !ext4_verity_in_progress(inode)) { + if (iocb->ki_pos > old_size && !fsverity_is_building(inode)) { if (iocb->ki_flags & IOCB_NOWAIT) return -EAGAIN; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e3129353d4ed..13035eda826e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "ext4_jbd2.h" #include "ext4_extents.h" @@ -506,7 +507,7 @@ void ext4_check_map_extents_env(struct inode *inode) is_special_ino(inode->i_sb, inode->i_ino) || (inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE | I_NEW)) || ext4_test_inode_flag(inode, EXT4_INODE_EA_INODE) || - ext4_verity_in_progress(inode)) + fsverity_is_building(inode)) return; WARN_ON_ONCE(!inode_is_locked(inode) && @@ -1493,7 +1494,7 @@ static int ext4_write_begin(const struct kiocb *iocb, if (ret) { bool extended = (pos + len > inode->i_size) && - !ext4_verity_in_progress(inode); + !fsverity_is_building(inode); folio_unlock(folio); /* @@ -1560,7 +1561,7 @@ static int ext4_write_end(const struct kiocb *iocb, loff_t old_size = inode->i_size; int ret = 0, ret2; int i_size_changed = 0; - bool verity = ext4_verity_in_progress(inode); + bool verity = fsverity_is_building(inode); trace_ext4_write_end(inode, pos, len, copied); @@ -1665,7 +1666,7 @@ static int ext4_journalled_write_end(const struct kiocb *iocb, int partial = 0; unsigned from, to; int size_changed = 0; - bool verity = ext4_verity_in_progress(inode); + bool verity = fsverity_is_building(inode); trace_ext4_journalled_write_end(inode, pos, len, copied); from = pos & (PAGE_SIZE - 1); @@ -2210,7 +2211,7 @@ static void mpage_submit_folio(struct mpage_da_data *mpd, struct folio *folio) size = i_size_read(mpd->inode); len = folio_size(folio); if (folio_pos(folio) + len > size && - !ext4_verity_in_progress(mpd->inode)) + !fsverity_is_building(mpd->inode)) len = size & (len - 1); ext4_bio_write_folio(&mpd->io_submit, folio, len); } @@ -2300,7 +2301,7 @@ static int mpage_process_page_bufs(struct mpage_da_data *mpd, ext4_lblk_t blocks = (i_size_read(inode) + i_blocksize(inode) - 1) >> inode->i_blkbits; - if (ext4_verity_in_progress(inode)) + if (fsverity_is_building(inode)) blocks = EXT_MAX_BLOCKS; do { @@ -2706,7 +2707,7 @@ static int mpage_journal_page_buffers(handle_t *handle, mpd->wbc->nr_to_write -= folio_nr_pages(folio); if (folio_pos(folio) + len > size && - !ext4_verity_in_progress(inode)) + !fsverity_is_building(inode)) len = size & (len - 1); return ext4_journal_folio_buffers(handle, folio, len); @@ -3271,7 +3272,7 @@ static int ext4_da_write_begin(const struct kiocb *iocb, index = pos >> PAGE_SHIFT; - if (ext4_nonda_switch(inode->i_sb) || ext4_verity_in_progress(inode)) { + if (ext4_nonda_switch(inode->i_sb) || fsverity_is_building(inode)) { *fsdata = (void *)FALL_BACK_TO_NONDELALLOC; return ext4_write_begin(iocb, mapping, pos, len, foliop, fsdata); diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index e8e579498c99..d3db2e77ebda 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -575,8 +575,7 @@ static bool dax_compatible(struct inode *inode, unsigned int oldflags, if (flags & EXT4_DAX_FL) { if ((oldflags & EXT4_DAX_MUT_EXCL) || - ext4_test_inode_state(inode, - EXT4_STATE_VERITY_IN_PROGRESS)) { + fsverity_is_building(inode)) { return false; } } diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index 56fe3e5b33e0..0c8f5cc92d97 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -83,9 +83,6 @@ static int ext4_begin_enable_verity(struct file *filp) if (IS_DAX(inode) || ext4_test_inode_flag(inode, EXT4_INODE_DAX)) return -EINVAL; - if (ext4_verity_in_progress(inode)) - return -EBUSY; - /* * Since the file was opened readonly, we have to initialize the jbd * inode and quotas here and not rely on ->open() doing it. This must @@ -123,8 +120,6 @@ static int ext4_begin_enable_verity(struct file *filp) return PTR_ERR(handle); err = ext4_orphan_add(handle, inode); - if (err == 0) - ext4_set_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); ext4_journal_stop(handle); return err; @@ -185,10 +180,10 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc, goto cleanup; /* - * Write all pages (both data and verity metadata). Note that this must - * happen before clearing EXT4_STATE_VERITY_IN_PROGRESS; otherwise pages - * beyond i_size won't be written properly. For crash consistency, this - * also must happen before the verity inode flag gets persisted. + * Write all pages (both data and verity metadata). Note that this must + * happen before I_VERITY_BUILDING is cleared; otherwise pages beyond + * i_size won't be written properly. For crash consistency, this also + * must happen before the verity inode flag gets persisted. */ err = filemap_write_and_wait(inode->i_mapping); if (err) @@ -224,7 +219,6 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc, /* Now that rollback is no longer possible, set S_VERITY. */ ext4_set_inode_flags(inode, false); - ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); return 0; stop_and_cleanup: @@ -234,13 +228,12 @@ static int ext4_end_enable_verity(struct file *filp, const void *desc, /* * Verity failed to be enabled, so clean up by truncating any verity * metadata that was written beyond i_size (both from cache and from - * disk), removing the inode from the orphan list (if it wasn't done - * already), and clearing EXT4_STATE_VERITY_IN_PROGRESS. + * disk) and removing the inode from the orphan list (if it wasn't done + * already). */ truncate_inode_pages(inode->i_mapping, inode->i_size); ext4_truncate(inode); ext4_orphan_del(NULL, inode); - ext4_clear_inode_state(inode, EXT4_STATE_VERITY_IN_PROGRESS); return err; } -- 2.54.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel