Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS
@ 2026-11-20 15:50 Andrey Albershteyn
  2026-11-20 15:50 ` [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro

Hi folks,

This patchset lifts two things from filesystems to VFS level:
- No-op'ing FS_VERITY_FL in FS_IOC_SETFLAGS ioctl()
- Runtime fsverity construction flag on inode

The second patch fixes BTRFS get-modify-set loop with
FS_IOC_GETFLAGS/SETFLAGS ioctl()s, as it does return fsverity flag but
not mask it out.

Testing, -g verity passes for all fs, except btrfs/277 and
btrfs+generic/574.

The btrfs/277 seems to fail due to difference between what kernel
and userspace versions support (btrfs-progs v7.1 doesn't seem to
support latest streams v3).

The generic/574 on BTRFS fails only for 1024 block size no matter
the change (fails on v7.3 too). I haven't checked why.

Based on v7.3-rc3.

Changes in v3:
- Add comment that I_VERITY_BUILDING is set over enable
- Revert comment changes in ext4 and f2fs
- Added I_VERITY_BUILDING to show_inode_state()
- Updated comment in begin_enable; dropped -EBUSY
- Added patch changing inode_state_read_once() to const
- Use fsverity_is_building() around ->begin_enable() call
- Use fsverity_is_building() in iomap
Changes in v2:
- Return ret in btrfs_begin_enable_verity()
- Include linux-fsdevel

Andrey Albershteyn (7):
  fs: constify inode argument of inode_state_read_once()
  fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS
  fs,fsverity: add I_VERITY_BUILDING inode state flag
  iomap: use fsverity_is_building() to check for fsverity IO
  btrfs: use I_VERITY_BUILDING instead of private flags
  ext4: use I_VERITY_BUILDING instead of private flags
  f2fs: use I_VERITY_BUILDING instead of private flags

 fs/btrfs/btrfs_inode.h           |  7 -------
 fs/btrfs/verity.c                | 12 ++----------
 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 ++++++-------------
 fs/f2fs/data.c                   | 10 +++++-----
 fs/f2fs/f2fs.h                   |  7 -------
 fs/f2fs/verity.c                 | 12 +++---------
 fs/file_attr.c                   | 10 ++++++++++
 fs/iomap/buffered-io.c           |  2 +-
 fs/verity/enable.c               | 22 +++++++++++++++++++---
 include/linux/fs.h               |  8 +++++++-
 include/linux/fsverity.h         | 26 ++++++++++++++++++++++++--
 include/trace/events/writeback.h |  3 ++-
 16 files changed, 90 insertions(+), 77 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once()
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 15:58   ` sashiko-bot
  2026-11-20 15:58   ` sashiko-bot
  2026-11-20 15:50 ` [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro, Jan Kara,
	Christoph Hellwig

Constify inode parameter so that callers can pass const inode. Callers
do not need a change.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5b3a100aba77..5c62a968fbde 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -878,7 +878,7 @@ struct inode {
  *
  * We hide all of it behind helpers so that we can validate consumers.
  */
-static inline enum inode_state_flags_enum inode_state_read_once(struct inode *inode)
+static inline enum inode_state_flags_enum inode_state_read_once(const struct inode *inode)
 {
 	return READ_ONCE(inode->i_state.__state);
 }
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
  2026-11-20 15:50 ` [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 16:00   ` sashiko-bot
  2026-11-20 16:02   ` sashiko-bot
  2026-11-20 15:50 ` [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro, Boris Burkov,
	Christoph Hellwig

The common use of FS_IOC_GETFLAGS/SETFLAGS is get-modify-set loop.
Filesystems could return verity status with GETFLAGS, attempting to then
pass FS_VERITY_FL to SETFLAGS is not allowed.

The ext4 and f2fs already treat FS_VERITY_FL in the set path as no-op,
however, BTRFS returns -EOPNOTSUPP. So, the modification of other flags
doesn't work on BTRFS for fsverity inodes.

Fix it for BTRFS and anyone else, the ext4 and f2fs masking becomes
no-op. The file_get/setattr() path is fine here as this flag is cleared
right before fileattr_set_prepare(). The future fsverity support in XFS
would also need it.

Cc: Boris Burkov <boris@bur.io>
Cc: David Sterba <dsterba@suse.com>
Fixes: 146054090b08 ("btrfs: initial fsverity support")
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/file_attr.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/file_attr.c b/fs/file_attr.c
index 833e03810b24..81bf55f9b255 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -199,6 +199,16 @@ static int fileattr_set_prepare(struct inode *inode,
 	if (err)
 		return err;
 
+	/*
+	 * FS_VERITY_FL is settable only via FS_IOC_ENABLE_VERITY; never through
+	 * fileattr
+	 *
+	 * Treat it as a no-op so the FS_IOC_GETFLAGS/SETFLAGS round-trip
+	 * doesn't break for other flags
+	 */
+	fa->flags &= ~FS_VERITY_FL;
+	fa->fsx_xflags &= ~FS_XFLAG_VERITY;
+
 	/*
 	 * Project Quota ID state is only allowed to change from within the init
 	 * namespace. Enforce that restriction only if we are trying to change
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
  2026-11-20 15:50 ` [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
  2026-11-20 15:50 ` [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 16:01   ` sashiko-bot
  2026-11-20 16:01   ` sashiko-bot
  2026-11-20 15:50 ` [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro, Christoph Hellwig

Every filesystem that supports fs-verity keeps a private runtime inode
flag meaning Merkle tree is currently being built *_VERITY_IN_PROGRESS.
They all serve the same two purposes: reject a concurrent enable with
-EBUSY and let the write paths recognize the special writes done while
the tree is under construction.

Hoist this flag into the VFS as a new inode state flag,
I_VERITY_BUILDING, and manage its lifetime in the generic fs-verity
enable path. The flag is set after ->begin_enable_verity() succeeds and
cleared after ->end_enable_verity() returns (both on the success and the
rollback paths). Add the concurrent-enable guard.

A new helper, fsverity_is_building(), is provided for filesystems to
query the flag. No filesystem uses it yet; the per-fs flags are
converted in following patches.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/verity/enable.c               | 22 +++++++++++++++++++---
 include/linux/fs.h               |  6 ++++++
 include/linux/fsverity.h         | 26 ++++++++++++++++++++++++--
 include/trace/events/writeback.h |  3 ++-
 4 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/fs/verity/enable.c b/fs/verity/enable.c
index fe8493280b77..d820c8d348ca 100644
--- a/fs/verity/enable.c
+++ b/fs/verity/enable.c
@@ -229,13 +229,23 @@ static int enable_verity(struct file *filp,
 
 	/*
 	 * Start enabling verity on this file, serialized by the inode lock.
-	 * Fail if verity is already enabled or is already being enabled.
+	 * Fail if verity is already enabled or is already being enabled. Set
+	 * I_VERITY_BUILDING inode runtime flag which will be cleared when
+	 * enablement succeeded or rolled back.
 	 */
 	inode_lock(inode);
-	if (IS_VERITY(inode))
+	if (IS_VERITY(inode)) {
 		err = -EEXIST;
-	else
+	} else if (fsverity_is_building(inode)) {
+		err = -EBUSY;
+	} else {
 		err = vops->begin_enable_verity(filp);
+		if (!err) {
+			spin_lock(&inode->i_lock);
+			inode_state_set(inode, I_VERITY_BUILDING);
+			spin_unlock(&inode->i_lock);
+		}
+	}
 	inode_unlock(inode);
 	if (err)
 		goto out;
@@ -291,6 +301,9 @@ static int enable_verity(struct file *filp,
 	 */
 	inode_lock(inode);
 	err = vops->end_enable_verity(filp, desc, desc_size, params.tree_size);
+	spin_lock(&inode->i_lock);
+	inode_state_clear(inode, I_VERITY_BUILDING);
+	spin_unlock(&inode->i_lock);
 	inode_unlock(inode);
 	if (err) {
 		fsverity_err(inode, "%ps() failed with err %d",
@@ -317,6 +330,9 @@ static int enable_verity(struct file *filp,
 rollback:
 	inode_lock(inode);
 	(void)vops->end_enable_verity(filp, NULL, 0, params.tree_size);
+	spin_lock(&inode->i_lock);
+	inode_state_clear(inode, I_VERITY_BUILDING);
+	spin_unlock(&inode->i_lock);
 	inode_unlock(inode);
 	goto out;
 }
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5c62a968fbde..3bf953351e11 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -708,6 +708,11 @@ is_uncached_acl(struct posix_acl *acl)
  * I_LRU_ISOLATING	Inode is pinned being isolated from LRU without holding
  *			i_count.
  *
+ * I_VERITY_BUILDING	fs-verity is being enabled on the inode: the Merkle
+ *			tree is under construction.  The file is effectively
+ *			read-only to userspace; the only writes happening are
+ *			for the fs-verity metadata.
+ *
  * Q: What is the difference between I_WILL_FREE and I_FREEING?
  *
  * __I_{SYNC,NEW,LRU_ISOLATING} are used to derive unique addresses to wait
@@ -742,6 +747,7 @@ enum inode_state_flags_enum {
 	I_SYNC_QUEUED		= (1U << 17),
 	I_PINNING_NETFS_WB	= (1U << 18),
 	I_METADATA_WRITEBACK	= (1U << 19),
+	I_VERITY_BUILDING	= (1U << 20),
 };
 
 #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h
index 61fe96ccdff6..e02f79682e33 100644
--- a/include/linux/fsverity.h
+++ b/include/linux/fsverity.h
@@ -36,11 +36,12 @@ struct fsverity_operations {
 	 * @filp: a readonly file descriptor for the file
 	 *
 	 * The filesystem must do any needed filesystem-specific preparations
-	 * for enabling verity, e.g. evicting inline data.  It also must return
-	 * -EBUSY if verity is already being enabled on the given file.
+	 * for enabling verity, e.g. evicting inline data.
 	 *
 	 * i_rwsem is held for write.
 	 *
+	 * I_VERITY_BUILDING is set on the inode for the duration of enabling.
+	 *
 	 * Return: 0 on success, -errno on failure
 	 */
 	int (*begin_enable_verity)(struct file *filp);
@@ -164,6 +165,22 @@ static inline bool fsverity_active(const struct inode *inode)
 	return false;
 }
 
+/**
+ * fsverity_is_building() - is fs-verity being enabled on the inode
+ * @inode: inode to check
+ *
+ * This checks whether the inode's Merkle tree is currently being built.
+ * While this is the case the file is read-only to userspace and the only writes
+ * allowed are for the fs-verity metadata. This becomes false when fsverity
+ * metadata is fully created and written to disk or building failed.
+ *
+ * Return: true if fs-verity is being enabled on the inode
+ */
+static inline bool fsverity_is_building(const struct inode *inode)
+{
+	return inode_state_read_once(inode) & I_VERITY_BUILDING;
+}
+
 struct fsverity_info *__fsverity_get_info(const struct inode *inode);
 /**
  * fsverity_get_info - get fsverity information for an inode
@@ -217,6 +234,11 @@ static inline bool fsverity_active(const struct inode *inode)
 	return false;
 }
 
+static inline bool fsverity_is_building(const struct inode *inode)
+{
+	return false;
+}
+
 static inline struct fsverity_info *fsverity_get_info(const struct inode *inode)
 {
 	return NULL;
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 13ee076ccd16..6d0473d0f270 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -28,7 +28,8 @@
 		{I_DONTCACHE,		"I_DONTCACHE"},		\
 		{I_SYNC_QUEUED,		"I_SYNC_QUEUED"},	\
 		{I_PINNING_NETFS_WB,	"I_PINNING_NETFS_WB"},	\
-		{I_LRU_ISOLATING,	"I_LRU_ISOLATING"}	\
+		{I_LRU_ISOLATING,	"I_LRU_ISOLATING"},	\
+		{I_VERITY_BUILDING,	"I_VERITY_BUILDING"}	\
 	)
 
 /* enums need to be exported to user space */
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
                   ` (2 preceding siblings ...)
  2026-11-20 15:50 ` [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 16:13   ` sashiko-bot
  2026-11-20 16:21   ` sashiko-bot
  2026-11-20 15:50 ` [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro

Recently, inode gained new I_VERITY_BUILDING flag. This flag indicates
that inode is undergoing fsverity metadata construction. Previously, it
was indicated by stale iomap flag on the IO, now we can check the inode
instead. As fsverity inodes are read-only, the only write IO happening
during I_VERITY_BUILDING is fsverity metadata.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
 fs/iomap/buffered-io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 6d843b168d5f..0a176741e7b0 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1930,7 +1930,7 @@ static bool iomap_writeback_handle_eof(struct folio *folio,
 	struct inode *inode = wpc->inode;
 	u64 isize = i_size_read(inode);
 
-	if (wpc->iomap.flags & IOMAP_F_FSVERITY) {
+	if (fsverity_is_building(inode)) {
 		WARN_ON_ONCE(folio_pos(folio) < isize);
 		return true;
 	}
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
                   ` (3 preceding siblings ...)
  2026-11-20 15:50 ` [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 15:58   ` sashiko-bot
  2026-11-20 15:59   ` sashiko-bot
  2026-11-20 15:50 ` [PATCH v3 6/7] ext4: " Andrey Albershteyn
  2026-11-20 15:50 ` [PATCH v3 7/7] f2fs: " Andrey Albershteyn
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro, Christoph Hellwig

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 inode runtime flags that
duplicated this.

btrfs only used BTRFS_INODE_VERITY_IN_PROGRESS internally, so remove it
outright.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/btrfs_inode.h |  7 -------
 fs/btrfs/verity.c      | 12 ++----------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 0782f917fccc..5c752b947b56 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -78,13 +78,6 @@ enum {
 	 * the file range, inode's io_tree).
 	 */
 	BTRFS_INODE_NO_DELALLOC_FLUSH,
-	/*
-	 * Set when we are working on enabling verity for a file. Computing and
-	 * writing the whole Merkle tree can take a while so we want to prevent
-	 * races where two separate tasks attempt to simultaneously start verity
-	 * on the same file.
-	 */
-	BTRFS_INODE_VERITY_IN_PROGRESS,
 	/* Set when this inode is a free space inode. */
 	BTRFS_INODE_FREE_SPACE_INODE,
 	/* Set when there are no capabilities in XATTs for the inode. */
diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
index 79ace98714ad..c7eec8886e49 100644
--- a/fs/btrfs/verity.c
+++ b/fs/btrfs/verity.c
@@ -461,7 +461,6 @@ static int rollback_verity(struct btrfs_inode *inode)
 
 	btrfs_assert_inode_locked(inode);
 	truncate_inode_pages(inode->vfs_inode.i_mapping, inode->vfs_inode.i_size);
-	clear_bit(BTRFS_INODE_VERITY_IN_PROGRESS, &inode->runtime_flags);
 	ret = btrfs_drop_verity_items(inode);
 	if (ret) {
 		btrfs_handle_fs_error(root->fs_info, ret,
@@ -513,7 +512,6 @@ static int rollback_verity(struct btrfs_inode *inode)
  * - mark the inode with the verity flag
  * - delete the orphan item
  * - mark the ro compat bit
- * - clear the in progress bit
  *
  * Returns 0 on success, negative error code on failure.
  */
@@ -555,7 +553,6 @@ static int finish_verity(struct btrfs_inode *inode, const void *desc,
 		goto end_trans;
 	/* Now that rollback is no longer possible, set S_VERITY. */
 	btrfs_sync_inode_flags_to_i_flags(inode);
-	clear_bit(BTRFS_INODE_VERITY_IN_PROGRESS, &inode->runtime_flags);
 	btrfs_set_fs_compat_ro(root->fs_info, VERITY);
 end_trans:
 	if (ret)
@@ -570,8 +567,8 @@ static int finish_verity(struct btrfs_inode *inode, const void *desc,
  *
  * @filp:  file to enable verity on
  *
- * Begin enabling fsverity for the file. We drop any existing verity items, add
- * an orphan and set the in progress bit.
+ * Begin enabling fsverity for the file. We drop any existing verity items and
+ * add an orphan.
  *
  * Returns 0 on success, negative error code on failure.
  */
@@ -587,9 +584,6 @@ static int btrfs_begin_enable_verity(struct file *filp)
 	if (IS_ENCRYPTED(&inode->vfs_inode))
 		return -EOPNOTSUPP;
 
-	if (test_bit(BTRFS_INODE_VERITY_IN_PROGRESS, &inode->runtime_flags))
-		return -EBUSY;
-
 	/*
 	 * This should almost never do anything, but theoretically, it's
 	 * possible that we failed to enable verity on a file, then were
@@ -606,8 +600,6 @@ static int btrfs_begin_enable_verity(struct file *filp)
 		return PTR_ERR(trans);
 
 	ret = btrfs_orphan_add(trans, inode);
-	if (!ret)
-		set_bit(BTRFS_INODE_VERITY_IN_PROGRESS, &inode->runtime_flags);
 	btrfs_end_transaction(trans);
 
 	return ret;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 6/7] ext4: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
                   ` (4 preceding siblings ...)
  2026-11-20 15:50 ` [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 16:00   ` sashiko-bot
  2026-11-20 16:01   ` sashiko-bot
  2026-11-20 15:50 ` [PATCH v3 7/7] f2fs: " Andrey Albershteyn
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro, Christoph Hellwig

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 <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 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 <linux/bitops.h>
 #include <linux/iomap.h>
 #include <linux/iversion.h>
+#include <linux/fsverity.h>
 
 #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


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 7/7] f2fs: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
                   ` (5 preceding siblings ...)
  2026-11-20 15:50 ` [PATCH v3 6/7] ext4: " Andrey Albershteyn
@ 2026-11-20 15:50 ` Andrey Albershteyn
  2026-11-20 15:58   ` sashiko-bot
  2026-11-20 16:01   ` sashiko-bot
  6 siblings, 2 replies; 22+ messages in thread
From: Andrey Albershteyn @ 2026-11-20 15:50 UTC (permalink / raw)
  To: fsdevel, fsverity, linux-ext4, linux-btrfs, linux-f2fs, linux-xfs,
	dsterba, Eric Biggers, Christian Brauner
  Cc: Andrey Albershteyn, tytso, chao, jaegeuk, viro

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 inode runtime flags that
duplicated this state.

Replace f2fs own helper f2fs_verity_in_progress() with
fsverity_is_building(), and remove the and FI_VERITY_IN_PROGRESS flags.
It's fine to remove IS_ENABLED() guard as fsverity_is_building() has
stub.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
 fs/f2fs/data.c   | 10 +++++-----
 fs/f2fs/f2fs.h   |  7 -------
 fs/f2fs/verity.c | 12 +++---------
 3 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7c5aa95b7da8..c75e61af21f7 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3356,7 +3356,7 @@ int f2fs_write_single_data_page(struct folio *folio, int *submitted,
 		goto redirty_out;
 
 	if (folio->index < end_index ||
-			f2fs_verity_in_progress(inode) ||
+			fsverity_is_building(inode) ||
 			compr_blocks)
 		goto write;
 
@@ -3889,7 +3889,7 @@ void f2fs_write_failed(struct inode *inode, loff_t to)
 		return;
 
 	/* In the fs-verity case, f2fs_end_enable_verity() does the truncate */
-	if (to > i_size && !f2fs_verity_in_progress(inode)) {
+	if (to > i_size && !fsverity_is_building(inode)) {
 		f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 		filemap_invalidate_lock(inode->i_mapping);
 
@@ -4205,7 +4205,7 @@ static int f2fs_write_begin(const struct kiocb *iocb,
 		return 0;
 
 	if (!(pos & (PAGE_SIZE - 1)) && (pos + len) >= i_size_read(inode) &&
-	    !f2fs_verity_in_progress(inode)) {
+	    !fsverity_is_building(inode)) {
 		folio_zero_segment(folio, len, folio_size(folio));
 		return 0;
 	}
@@ -4279,7 +4279,7 @@ static int f2fs_write_end(const struct kiocb *iocb,
 		f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 
 		if (pos + copied > i_size_read(inode) &&
-				!f2fs_verity_in_progress(inode))
+				!fsverity_is_building(inode))
 			f2fs_i_size_write(inode, pos + copied);
 		return copied;
 	}
@@ -4294,7 +4294,7 @@ static int f2fs_write_end(const struct kiocb *iocb,
 		folio_set_f2fs_atomic(folio);
 
 	if (pos + copied > i_size_read(inode) &&
-	    !f2fs_verity_in_progress(inode)) {
+	    !fsverity_is_building(inode)) {
 		f2fs_i_size_write(inode, pos + copied);
 		if (f2fs_is_atomic_file(inode))
 			f2fs_i_size_write(F2FS_I(inode)->cow_inode,
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6941891d7cae..c0fca6229170 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -926,7 +926,6 @@ enum {
 	FI_EXTRA_ATTR,		/* indicate file has extra attribute */
 	FI_PROJ_INHERIT,	/* indicate file inherits projectid */
 	FI_PIN_FILE,		/* indicate file should not be gced */
-	FI_VERITY_IN_PROGRESS,	/* building fs-verity Merkle tree */
 	FI_COMPRESSED_FILE,	/* indicate file's data can be compressed */
 	FI_COMPRESS_CORRUPT,	/* indicate compressed cluster is corrupted */
 	FI_MMAP_FILE,		/* indicate file was mmapped */
@@ -3536,12 +3535,6 @@ static inline void clear_inode_flag(struct inode *inode, int flag)
 	__mark_inode_dirty_flag(inode, flag, false);
 }
 
-static inline bool f2fs_verity_in_progress(struct inode *inode)
-{
-	return IS_ENABLED(CONFIG_FS_VERITY) &&
-	       is_inode_flag_set(inode, FI_VERITY_IN_PROGRESS);
-}
-
 static inline void set_acl_inode(struct inode *inode, umode_t mode)
 {
 	F2FS_I(inode)->i_acl_mode = mode;
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index 4a2cea4288f9..f31a71295e47 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -94,9 +94,6 @@ static int f2fs_begin_enable_verity(struct file *filp)
 	struct inode *inode = file_inode(filp);
 	int err;
 
-	if (f2fs_verity_in_progress(inode))
-		return -EBUSY;
-
 	if (f2fs_is_atomic_file(inode))
 		return -EOPNOTSUPP;
 
@@ -113,7 +110,6 @@ static int f2fs_begin_enable_verity(struct file *filp)
 	if (err)
 		return err;
 
-	set_inode_flag(inode, FI_VERITY_IN_PROGRESS);
 	return 0;
 }
 
@@ -143,8 +139,8 @@ static int f2fs_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 FI_VERITY_IN_PROGRESS; otherwise pages beyond
+	 * 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.
 	 */
@@ -164,14 +160,13 @@ static int f2fs_end_enable_verity(struct file *filp, const void *desc,
 	f2fs_set_inode_flags(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 
-	clear_inode_flag(inode, FI_VERITY_IN_PROGRESS);
 	return 0;
 
 cleanup:
 	/*
 	 * 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) and clearing FI_VERITY_IN_PROGRESS.
+	 * disk).
 	 *
 	 * Taking i_gc_rwsem[WRITE] is needed to stop f2fs garbage collection
 	 * from re-instantiating cached pages we are truncating (since unlike
@@ -186,7 +181,6 @@ static int f2fs_end_enable_verity(struct file *filp, const void *desc,
 		set_sbi_flag(sbi, SBI_NEED_FSCK);
 	}
 	f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
-	clear_inode_flag(inode, FI_VERITY_IN_PROGRESS);
 	return err ?: err2;
 }
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once()
  2026-11-20 15:50 ` [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
@ 2026-11-20 15:58   ` sashiko-bot
  2026-11-20 15:58   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 15:58 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> Constify inode parameter so that callers can pass const inode. Callers
> do not need a change.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 ` [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
@ 2026-11-20 15:58   ` sashiko-bot
  2026-11-20 15:59   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 15:58 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> 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 inode runtime flags that
> duplicated this.
> 
> btrfs only used BTRFS_INODE_VERITY_IN_PROGRESS internally, so remove it
> outright.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=5


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once()
  2026-11-20 15:50 ` [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
  2026-11-20 15:58   ` sashiko-bot
@ 2026-11-20 15:58   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 15:58 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> Constify inode parameter so that callers can pass const inode. Callers
> do not need a change.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=1


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 7/7] f2fs: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 ` [PATCH v3 7/7] f2fs: " Andrey Albershteyn
@ 2026-11-20 15:58   ` sashiko-bot
  2026-11-20 16:01   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 15:58 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> 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 inode runtime flags that
> duplicated this state.
> 
> Replace f2fs own helper f2fs_verity_in_progress() with
> fsverity_is_building(), and remove the and FI_VERITY_IN_PROGRESS flags.
> It's fine to remove IS_ENABLED() guard as fsverity_is_building() has
> stub.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=7


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 ` [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
  2026-11-20 15:58   ` sashiko-bot
@ 2026-11-20 15:59   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 15:59 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> 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 inode runtime flags that
> duplicated this.
> 
> btrfs only used BTRFS_INODE_VERITY_IN_PROGRESS internally, so remove it
> outright.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=5


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS
  2026-11-20 15:50 ` [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
@ 2026-11-20 16:00   ` sashiko-bot
  2026-11-20 16:02   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:00 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> The common use of FS_IOC_GETFLAGS/SETFLAGS is get-modify-set loop.
> Filesystems could return verity status with GETFLAGS, attempting to then
> pass FS_VERITY_FL to SETFLAGS is not allowed.
> 
> The ext4 and f2fs already treat FS_VERITY_FL in the set path as no-op,
> however, BTRFS returns -EOPNOTSUPP. So, the modification of other flags
> doesn't work on BTRFS for fsverity inodes.
> 
> Fix it for BTRFS and anyone else, the ext4 and f2fs masking becomes
> no-op. The file_get/setattr() path is fine here as this flag is cleared
> right before fileattr_set_prepare(). The future fsverity support in XFS
> would also need it.
> 
> Cc: Boris Burkov <boris@bur.io>
> Cc: David Sterba <dsterba@suse.com>
> Fixes: 146054090b08 ("btrfs: initial fsverity support")
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=2


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 6/7] ext4: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 ` [PATCH v3 6/7] ext4: " Andrey Albershteyn
@ 2026-11-20 16:00   ` sashiko-bot
  2026-11-20 16:01   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:00 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> 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 <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=6


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag
  2026-11-20 15:50 ` [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
@ 2026-11-20 16:01   ` sashiko-bot
  2026-11-20 16:01   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:01 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> Every filesystem that supports fs-verity keeps a private runtime inode
> flag meaning Merkle tree is currently being built *_VERITY_IN_PROGRESS.
> They all serve the same two purposes: reject a concurrent enable with
> -EBUSY and let the write paths recognize the special writes done while
> the tree is under construction.
> 
> Hoist this flag into the VFS as a new inode state flag,
> I_VERITY_BUILDING, and manage its lifetime in the generic fs-verity
> enable path. The flag is set after ->begin_enable_verity() succeeds and
> cleared after ->end_enable_verity() returns (both on the success and the
> rollback paths). Add the concurrent-enable guard.
> 
> A new helper, fsverity_is_building(), is provided for filesystems to
> query the flag. No filesystem uses it yet; the per-fs flags are
> converted in following patches.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=3


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 6/7] ext4: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 ` [PATCH v3 6/7] ext4: " Andrey Albershteyn
  2026-11-20 16:00   ` sashiko-bot
@ 2026-11-20 16:01   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:01 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> 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 <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=6


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 7/7] f2fs: use I_VERITY_BUILDING instead of private flags
  2026-11-20 15:50 ` [PATCH v3 7/7] f2fs: " Andrey Albershteyn
  2026-11-20 15:58   ` sashiko-bot
@ 2026-11-20 16:01   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:01 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> 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 inode runtime flags that
> duplicated this state.
> 
> Replace f2fs own helper f2fs_verity_in_progress() with
> fsverity_is_building(), and remove the and FI_VERITY_IN_PROGRESS flags.
> It's fine to remove IS_ENABLED() guard as fsverity_is_building() has
> stub.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=7


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag
  2026-11-20 15:50 ` [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
  2026-11-20 16:01   ` sashiko-bot
@ 2026-11-20 16:01   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:01 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> Every filesystem that supports fs-verity keeps a private runtime inode
> flag meaning Merkle tree is currently being built *_VERITY_IN_PROGRESS.
> They all serve the same two purposes: reject a concurrent enable with
> -EBUSY and let the write paths recognize the special writes done while
> the tree is under construction.
> 
> Hoist this flag into the VFS as a new inode state flag,
> I_VERITY_BUILDING, and manage its lifetime in the generic fs-verity
> enable path. The flag is set after ->begin_enable_verity() succeeds and
> cleared after ->end_enable_verity() returns (both on the success and the
> rollback paths). Add the concurrent-enable guard.
> 
> A new helper, fsverity_is_building(), is provided for filesystems to
> query the flag. No filesystem uses it yet; the per-fs flags are
> converted in following patches.
> 
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=3


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS
  2026-11-20 15:50 ` [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
  2026-11-20 16:00   ` sashiko-bot
@ 2026-11-20 16:02   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:02 UTC (permalink / raw)
  To: Andrey Albershteyn, linux-ext4; +Cc: tytso

> The common use of FS_IOC_GETFLAGS/SETFLAGS is get-modify-set loop.
> Filesystems could return verity status with GETFLAGS, attempting to then
> pass FS_VERITY_FL to SETFLAGS is not allowed.
> 
> The ext4 and f2fs already treat FS_VERITY_FL in the set path as no-op,
> however, BTRFS returns -EOPNOTSUPP. So, the modification of other flags
> doesn't work on BTRFS for fsverity inodes.
> 
> Fix it for BTRFS and anyone else, the ext4 and f2fs masking becomes
> no-op. The file_get/setattr() path is fine here as this flag is cleared
> right before fileattr_set_prepare(). The future fsverity support in XFS
> would also need it.
> 
> Cc: Boris Burkov <boris@bur.io>
> Cc: David Sterba <dsterba@suse.com>
> Fixes: 146054090b08 ("btrfs: initial fsverity support")
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=2


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO
  2026-11-20 15:50 ` [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
@ 2026-11-20 16:13   ` sashiko-bot
  2026-11-20 16:21   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:13 UTC (permalink / raw)
  To: Andrey Albershteyn, fsverity, linux-ext4, dsterba, Eric Biggers,
	Christian Brauner
  Cc: tytso, chao, jaegeuk, viro, dsterba

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] iomap: false warning and skipped EOF zeroing in
  iomap_writeback_handle_eof()
- [Low] iomap: missing Fixes trailer for commit 63e242afa466
--

commit d5a593fe13feaadaf9eccdc0fdcb54b6905598bb
Author: Andrey Albershteyn <aalbersh@kernel.org>

> iomap: use fsverity_is_building() to check for fsverity IO
>
> Recently, inode gained new I_VERITY_BUILDING flag. This flag indicates
> that inode is undergoing fsverity metadata construction. Previously, it
> was indicated by stale iomap flag on the IO, now we can check the inode
> instead. As fsverity inodes are read-only, the only write IO happening
> during I_VERITY_BUILDING is fsverity metadata.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

[Severity: Low]
Since this fixes the check on the uninitialized or stale wpc->iomap.flags
in iomap_writeback_handle_eof(), should it carry:

  Fixes: 63e242afa466 ("iomap: introduce IOMAP_F_FSVERITY and teach writeback to handle fsverity")

> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index d6e2f1ded5ca6..4fb4136908ec5 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1930,7 +1930,7 @@ static bool iomap_writeback_handle_eof(struct folio *folio,
>  	struct inode *inode = wpc->inode;
>  	u64 isize = i_size_read(inode);
>  
> -	if (wpc->iomap.flags & IOMAP_F_FSVERITY) {
> +	if (fsverity_is_building(inode)) {
>  		WARN_ON_ONCE(folio_pos(folio) < isize);
>  		return true;
>  	}

[Severity: Medium]
Can this trigger a false WARN_ON_ONCE() and skip EOF tail zeroing when
pre-existing dirty data folios are written back while I_VERITY_BUILDING
is set?

fsverity_ioctl_enable() calls deny_write_access(), and enable_verity()
sets I_VERITY_BUILDING after ->begin_enable_verity() without flushing
dirty data folios already in inode->i_mapping:

fs/verity/enable.c:enable_verity() {
    ...
		err = vops->begin_enable_verity(filp);
		if (!err) {
			spin_lock(&inode->i_lock);
			inode_state_set(inode, I_VERITY_BUILDING);
			spin_unlock(&inode->i_lock);
		}
    ...
}

If a file is written via buffered write or mmap, closed without fsync,
and reopened O_RDONLY for FS_IOC_ENABLE_VERITY, writeback of dirty data
folios below i_size can run while I_VERITY_BUILDING is set.  Because
fsverity_is_building() is an inode-wide flag, iomap_writeback_handle_eof()
fires WARN_ON_ONCE(folio_pos(folio) < isize) and returns early.  For a
dirty data folio straddling i_size, returning early also skips
folio_zero_segment() and leaves *end_pos unclamped past i_size.

Checking fsverity_is_building(inode) only when the folio is completely at
or beyond i_size (where iomap_writeback_handle_eof() otherwise returns
false) would avoid affecting regular data folios.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-2-aalbersh@kernel.org?part=4

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO
  2026-11-20 15:50 ` [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
  2026-11-20 16:13   ` sashiko-bot
@ 2026-11-20 16:21   ` sashiko-bot
  1 sibling, 0 replies; 22+ messages in thread
From: sashiko-bot @ 2026-11-20 16:21 UTC (permalink / raw)
  To: Andrey Albershteyn, fsverity, linux-ext4, dsterba, Eric Biggers,
	Christian Brauner
  Cc: tytso, chao, jaegeuk, viro, dsterba

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] iomap: inode-wide fsverity_is_building() check in
  iomap_writeback_handle_eof()
- [Low] iomap: missing Fixes trailer for broken fsverity check in
  writeback
--

commit f52ac6dc651e2b12c5452600fd41f0db8111577f
Author: Andrey Albershteyn <aalbersh@kernel.org>

> iomap: use fsverity_is_building() to check for fsverity IO
>
> Recently, inode gained new I_VERITY_BUILDING flag. This flag indicates
> that inode is undergoing fsverity metadata construction. Previously, it
> was indicated by stale iomap flag on the IO, now we can check the inode
> instead. As fsverity inodes are read-only, the only write IO happening
> during I_VERITY_BUILDING is fsverity metadata.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>

[Severity: Low]
This fixes the check that read an uninitialized or stale wpc->iomap
before wpc->ops->writeback_range() mapped the folio.  Should it carry:

  Fixes: 63e242afa466 ("iomap: introduce IOMAP_F_FSVERITY and teach writeback to handle fsverity")

> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index d6e2f1ded5ca6..4fb4136908ec5 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1930,7 +1930,7 @@ static bool iomap_writeback_handle_eof(struct folio *folio,
>  	struct inode *inode = wpc->inode;
>  	u64 isize = i_size_read(inode);
>  
> -	if (wpc->iomap.flags & IOMAP_F_FSVERITY) {
> +	if (fsverity_is_building(inode)) {
>  		WARN_ON_ONCE(folio_pos(folio) < isize);
>  		return true;
>  	}

[Severity: Medium]
Can writeback of a dirty data folio while I_VERITY_BUILDING is set hit
this WARN_ON_ONCE() and skip post-EOF tail zeroing?

enable_verity() sets I_VERITY_BUILDING without flushing pre-existing
dirty data folios in inode->i_mapping, and filesystems write back both
dirty data and verity metadata folios while I_VERITY_BUILDING is still
set (either during background writeback or in ->end_enable_verity()).
Because fsverity_is_building(inode) is an inode-wide flag checked before
comparing the folio offset against isize, any dirty regular data folio
written back during verity construction triggers WARN_ON_ONCE(folio_pos(folio) < isize),
and a dirty data folio straddling isize returns early without running
folio_zero_segment() or clamping *end_pos to isize.

Should the fsverity_is_building(inode) exemption apply only when the
folio lies entirely at or beyond isize?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120155032.187246-1-aalbersh@kernel.org?part=4

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2026-11-20 16:21 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 15:50 [PATCH v3 0/7] fsverity: lift ioctl() input masking and runtime inode flag to VFS Andrey Albershteyn
2026-11-20 15:50 ` [PATCH v3 1/7] fs: constify inode argument of inode_state_read_once() Andrey Albershteyn
2026-11-20 15:58   ` sashiko-bot
2026-11-20 15:58   ` sashiko-bot
2026-11-20 15:50 ` [PATCH v3 2/7] fs: strip FS_VERITY_FL from FS_IOC_SETFLAGS Andrey Albershteyn
2026-11-20 16:00   ` sashiko-bot
2026-11-20 16:02   ` sashiko-bot
2026-11-20 15:50 ` [PATCH v3 3/7] fs,fsverity: add I_VERITY_BUILDING inode state flag Andrey Albershteyn
2026-11-20 16:01   ` sashiko-bot
2026-11-20 16:01   ` sashiko-bot
2026-11-20 15:50 ` [PATCH v3 4/7] iomap: use fsverity_is_building() to check for fsverity IO Andrey Albershteyn
2026-11-20 16:13   ` sashiko-bot
2026-11-20 16:21   ` sashiko-bot
2026-11-20 15:50 ` [PATCH v3 5/7] btrfs: use I_VERITY_BUILDING instead of private flags Andrey Albershteyn
2026-11-20 15:58   ` sashiko-bot
2026-11-20 15:59   ` sashiko-bot
2026-11-20 15:50 ` [PATCH v3 6/7] ext4: " Andrey Albershteyn
2026-11-20 16:00   ` sashiko-bot
2026-11-20 16:01   ` sashiko-bot
2026-11-20 15:50 ` [PATCH v3 7/7] f2fs: " Andrey Albershteyn
2026-11-20 15:58   ` sashiko-bot
2026-11-20 16:01   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox