<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/nilfs2, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>iomap: pass iomap_iter_next_fn directly instead of struct iomap_ops</title>
<updated>2026-11-05T14:52:51+00:00</updated>
<author>
<name>Joanne Koong</name>
<email>joannelkoong@gmail.com</email>
</author>
<published>2026-10-27T21:53:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9e8fc16dc6b474b9a87843c3d3ee12fc83f2bdcc'/>
<id>9e8fc16dc6b474b9a87843c3d3ee12fc83f2bdcc</id>
<content type='text'>
Now that all filesystems implement -&gt;iomap_next() and the legacy
-&gt;iomap_begin()/-&gt;iomap_end() fallback is gone, struct iomap_ops only
wraps a single iomap_next function pointer. Drop the struct entirely and
pass the iomap_iter_next_fn directly to iomap_iter() and all the
iomap/dax entry points. Filesystems pass their iomap_iter_next_fn
callback directly instead of an ops struct. Several iomap_iter_next_fn
callbacks become non-static and gain header declarations since callers
now reference them directly.

The iomap_iter tracepoint's ops field is renamed to next to match. These
tracepoints are explicitly not stable ABI (see the note in iomap/trace.h).

No functional change intended other than the tracepoint field rename
noted above.

Acked-by: Jan Kara &lt;jack@suse.cz&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Joanne Koong &lt;joannelkoong@gmail.com&gt;
Link: https://patch.msgid.link/20261027215326.2693300-5-joannelkoong@gmail.com
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that all filesystems implement -&gt;iomap_next() and the legacy
-&gt;iomap_begin()/-&gt;iomap_end() fallback is gone, struct iomap_ops only
wraps a single iomap_next function pointer. Drop the struct entirely and
pass the iomap_iter_next_fn directly to iomap_iter() and all the
iomap/dax entry points. Filesystems pass their iomap_iter_next_fn
callback directly instead of an ops struct. Several iomap_iter_next_fn
callbacks become non-static and gain header declarations since callers
now reference them directly.

The iomap_iter tracepoint's ops field is renamed to next to match. These
tracepoints are explicitly not stable ABI (see the note in iomap/trace.h).

No functional change intended other than the tracepoint field rename
noted above.

Acked-by: Jan Kara &lt;jack@suse.cz&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Joanne Koong &lt;joannelkoong@gmail.com&gt;
Link: https://patch.msgid.link/20261027215326.2693300-5-joannelkoong@gmail.com
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: convert iomap ops to -&gt;iomap_next()</title>
<updated>2026-11-05T14:52:47+00:00</updated>
<author>
<name>Joanne Koong</name>
<email>joannelkoong@gmail.com</email>
</author>
<published>2026-10-27T21:53:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a210eb87cd3d19e929d1a35e2430bdc85f3eb59b'/>
<id>a210eb87cd3d19e929d1a35e2430bdc85f3eb59b</id>
<content type='text'>
Convert nilfs2 iomap_ops to the new -&gt;iomap_next() callback. The callback
is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the
iomap_iter_next() helper to finish the previous mapping if needed and
produce the next one. No functional changes are intended.

Signed-off-by: Joanne Koong &lt;joannelkoong@gmail.com&gt;
Link: https://patch.msgid.link/20261027215326.2693300-2-joannelkoong@gmail.com
Acked-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Convert nilfs2 iomap_ops to the new -&gt;iomap_next() callback. The callback
is generated with the DEFINE_IOMAP_ITER_NEXT() macro, which wraps the
iomap_iter_next() helper to finish the previous mapping if needed and
produce the next one. No functional changes are intended.

Signed-off-by: Joanne Koong &lt;joannelkoong@gmail.com&gt;
Link: https://patch.msgid.link/20261027215326.2693300-2-joannelkoong@gmail.com
Acked-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'nilfs2-v7.4-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/nilfs2</title>
<updated>2026-10-21T01:59:26+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-10-21T01:59:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d28fb91dd82aa56359b6de4d6241b7063672a4c0'/>
<id>d28fb91dd82aa56359b6de4d6241b7063672a4c0</id>
<content type='text'>
Pull nilfs2 updates from Viacheslav Dubeyko:
 "Fix issues in nilfs_sufile_get_suinfo(), nilfs_scan_dsync_log(), and
  nilfs_find_or_create_root() (Aldo Ariel Panzardo):
   - If the requested segment number is greater than the total number of
     segments, the function may process segment numbers outside the
     filesystem.
   - nilfs_scan_dsync_log() trusts the block counts in each on-disk file
     information entry. If fi_ndatablk is greater than fi_nblocks, the
     data block loop can consume excessive summary entries and the later
     subtraction used to derive the number of node blocks underflows.
   - nilfs_find_or_create_root() links a new checkpoint root into the
     checkpoint tree and drops ns_cptree_lock before creating the root's
     sysfs group. If nilfs_sysfs_create_snapshot_group() then fails, the
     root is freed while it is still reachable from ns_cptree, so a
     concurrent nilfs_lookup_root() can dereference freed memory.

  Fix typos in comments, reported by scripts/checkpatch.pl using the
  misspelling list in scripts/spelling.txt (Hemanth Selam)

  Fix issues in nilfs_recover_dsync_blocks() and nilfs_readdir() (Jake
  Labelle):
   - During roll-forward recovery, nilfs_recover_dsync_blocks() obtains
     the inode designated by fi_ino of a dsync log without checking its
     type. Regular files, directories, and symlinks are the only inode
     types with data blocks to recover; reject anything else before
     touching its block mapping.
   - nilfs_readdir() uses ctx-&gt;pos, which userspace can set to an
     arbitrary value via llseek, as an offset into the directory folio
     and parses whatever bytes sit there as a directory entry. Snap
     unaligned positions onto a valid entry boundary by walking the
     rec_len chain from the chunk start before parsing.

  Fix issue in logic of clearing the dirty folios. When garbage
  collection fails, nilfs2 rolls the DAT metadata file's page cache back
  to a shadow copy taken before GC started. nilfs_clear_dirty_pages()
  drops the dirty state of the folios in the DAT cache, then
  nilfs_copy_back_pages() overwrites them with the saved contents and
  warns if one is still dirty. Add a force flag to
  nilfs_clear_dirty_pages() and nilfs_clear_folio_dirty() that skips the
  busy buffer check, and set it in the two calls from
  nilfs_mdt_restore_from_shadow_map() (Jiaming Zhang)

  Remove dead code and comment code sections in nilfs_new_inode(),
  nilfs_read_inode_common(), and nilfs_setup_super() (Joshua Crofts)

  Multiple fixes (Ryusuke Konishi):
   - While the recent out-of-bounds memory access issue in
     nilfs_direct_propagate() has already been fixed, adds extra checks
     to catch and gracefully handle similar potential bugs.
   - Fix syzbot reported deadlock between nilfs_evict_inode() and
     find_inode() by removing the synchronous log writer trigger from
     nilfs_evict_inode().
   - Fix an omitted clear of the dirty flag on backing device buffers,
     which could cause an abnormal buffer state and potential block
     overwriting data corruption.
   - Improve stability by preventing errors caused by user interrupts
     while waiting for log writes, which are triggered by synchronous
     write flags following operations such as rename().
   - Refactor the metadata file writeback callback function,
     restructuring an inefficient legacy function organization rooted in
     the era of aops-&gt;writepage() to align with aops-&gt;writepages().
   - Fix a link count underflow during rmdir on a directory with a
     corrupted link count (an issue recently reported by syzbot).

  Eliminate blockdev_direct_IO() from nilfs2 entirely. Add iomap.h
  with declaration of iomap operations and iomap.c with implementation
  of nilfs_iomap_begin(). The nilfs_direct_IO() and the .direct_IO
  callback on nilfs_aops are removed. The nilfs_file_read_iter()
  dispatches O_DIRECT reads to iomap_dio_rw() using nilfs_iomap_ops.
  Everything else still goes through generic_file_read_iter()
  (Viacheslav Dubeyko)"

* tag 'nilfs2-v7.4-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/nilfs2:
  nilfs2: validate directory position after llseek in readdir
  nilfs2: reject non-regular inodes in dsync recovery
  nilfs2: fix link count underflow when removing corrupted directory
  nilfs2: simplify nilfs_mdt_writeback()
  nilfs2: ignore non-fatal signals during synchronous log write wait
  nilfs2: clear dirty flag on bdev buffers on log write failure
  nilfs2: fix deadlock between nilfs_evict_inode() and find_inode()
  nilfs2: fix checkpoint root lifetime on sysfs errors
  nilfs2: switch O_DIRECT to iomap based operations
  nilfs2: add iomap operations for direct I/O
  nilfs2: validate file block counts during recovery
  nilfs2: force clear dirty state when restoring from the shadow map
  nilfs2: validate segment number in nilfs_sufile_get_suinfo()
  nilfs2: fix typos in comments
  nilfs2: remove '#if 0' code blocks
  nilfs2: strengthen consistency checks in nilfs_direct_propagate()
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull nilfs2 updates from Viacheslav Dubeyko:
 "Fix issues in nilfs_sufile_get_suinfo(), nilfs_scan_dsync_log(), and
  nilfs_find_or_create_root() (Aldo Ariel Panzardo):
   - If the requested segment number is greater than the total number of
     segments, the function may process segment numbers outside the
     filesystem.
   - nilfs_scan_dsync_log() trusts the block counts in each on-disk file
     information entry. If fi_ndatablk is greater than fi_nblocks, the
     data block loop can consume excessive summary entries and the later
     subtraction used to derive the number of node blocks underflows.
   - nilfs_find_or_create_root() links a new checkpoint root into the
     checkpoint tree and drops ns_cptree_lock before creating the root's
     sysfs group. If nilfs_sysfs_create_snapshot_group() then fails, the
     root is freed while it is still reachable from ns_cptree, so a
     concurrent nilfs_lookup_root() can dereference freed memory.

  Fix typos in comments, reported by scripts/checkpatch.pl using the
  misspelling list in scripts/spelling.txt (Hemanth Selam)

  Fix issues in nilfs_recover_dsync_blocks() and nilfs_readdir() (Jake
  Labelle):
   - During roll-forward recovery, nilfs_recover_dsync_blocks() obtains
     the inode designated by fi_ino of a dsync log without checking its
     type. Regular files, directories, and symlinks are the only inode
     types with data blocks to recover; reject anything else before
     touching its block mapping.
   - nilfs_readdir() uses ctx-&gt;pos, which userspace can set to an
     arbitrary value via llseek, as an offset into the directory folio
     and parses whatever bytes sit there as a directory entry. Snap
     unaligned positions onto a valid entry boundary by walking the
     rec_len chain from the chunk start before parsing.

  Fix issue in logic of clearing the dirty folios. When garbage
  collection fails, nilfs2 rolls the DAT metadata file's page cache back
  to a shadow copy taken before GC started. nilfs_clear_dirty_pages()
  drops the dirty state of the folios in the DAT cache, then
  nilfs_copy_back_pages() overwrites them with the saved contents and
  warns if one is still dirty. Add a force flag to
  nilfs_clear_dirty_pages() and nilfs_clear_folio_dirty() that skips the
  busy buffer check, and set it in the two calls from
  nilfs_mdt_restore_from_shadow_map() (Jiaming Zhang)

  Remove dead code and comment code sections in nilfs_new_inode(),
  nilfs_read_inode_common(), and nilfs_setup_super() (Joshua Crofts)

  Multiple fixes (Ryusuke Konishi):
   - While the recent out-of-bounds memory access issue in
     nilfs_direct_propagate() has already been fixed, adds extra checks
     to catch and gracefully handle similar potential bugs.
   - Fix syzbot reported deadlock between nilfs_evict_inode() and
     find_inode() by removing the synchronous log writer trigger from
     nilfs_evict_inode().
   - Fix an omitted clear of the dirty flag on backing device buffers,
     which could cause an abnormal buffer state and potential block
     overwriting data corruption.
   - Improve stability by preventing errors caused by user interrupts
     while waiting for log writes, which are triggered by synchronous
     write flags following operations such as rename().
   - Refactor the metadata file writeback callback function,
     restructuring an inefficient legacy function organization rooted in
     the era of aops-&gt;writepage() to align with aops-&gt;writepages().
   - Fix a link count underflow during rmdir on a directory with a
     corrupted link count (an issue recently reported by syzbot).

  Eliminate blockdev_direct_IO() from nilfs2 entirely. Add iomap.h
  with declaration of iomap operations and iomap.c with implementation
  of nilfs_iomap_begin(). The nilfs_direct_IO() and the .direct_IO
  callback on nilfs_aops are removed. The nilfs_file_read_iter()
  dispatches O_DIRECT reads to iomap_dio_rw() using nilfs_iomap_ops.
  Everything else still goes through generic_file_read_iter()
  (Viacheslav Dubeyko)"

* tag 'nilfs2-v7.4-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/nilfs2:
  nilfs2: validate directory position after llseek in readdir
  nilfs2: reject non-regular inodes in dsync recovery
  nilfs2: fix link count underflow when removing corrupted directory
  nilfs2: simplify nilfs_mdt_writeback()
  nilfs2: ignore non-fatal signals during synchronous log write wait
  nilfs2: clear dirty flag on bdev buffers on log write failure
  nilfs2: fix deadlock between nilfs_evict_inode() and find_inode()
  nilfs2: fix checkpoint root lifetime on sysfs errors
  nilfs2: switch O_DIRECT to iomap based operations
  nilfs2: add iomap operations for direct I/O
  nilfs2: validate file block counts during recovery
  nilfs2: force clear dirty state when restoring from the shadow map
  nilfs2: validate segment number in nilfs_sufile_get_suinfo()
  nilfs2: fix typos in comments
  nilfs2: remove '#if 0' code blocks
  nilfs2: strengthen consistency checks in nilfs_direct_propagate()
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: validate directory position after llseek in readdir</title>
<updated>2026-10-08T16:39:43+00:00</updated>
<author>
<name>Jake Labelle</name>
<email>southampton.jake.labelle@gmail.com</email>
</author>
<published>2026-10-08T11:52:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=de7f49c12566cc5c7437a2f26c6c754b9d4d5648'/>
<id>de7f49c12566cc5c7437a2f26c6c754b9d4d5648</id>
<content type='text'>
nilfs_readdir() uses ctx-&gt;pos, which userspace can set to an arbitrary
value via llseek, as an offset into the directory folio and parses
whatever bytes sit there as a directory entry.  A position pointing
into the middle of an entry -- or at unused bytes of a corrupted image
that the page validator never inspected -- makes dir_emit() copy up to
255 (name_len) bytes from a bogus entry, possibly reading past the end
of the folio and returning unrelated memory contents to userspace.

Snap unaligned positions onto a valid entry boundary by walking the
rec_len chain from the chunk start before parsing, as ext2 does in
ext2_validate_entry().

[ryusuke: fixed offset wrap-around in nilfs_validate_entry() and
 conformed AI tag to guidelines]

Fixes: 2ba466d74ed7 ("nilfs2: directory entry operations")
Assisted-by: Claude:claude-mythos-5
Signed-off-by: Jake Labelle &lt;southampton.jake.labelle@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
nilfs_readdir() uses ctx-&gt;pos, which userspace can set to an arbitrary
value via llseek, as an offset into the directory folio and parses
whatever bytes sit there as a directory entry.  A position pointing
into the middle of an entry -- or at unused bytes of a corrupted image
that the page validator never inspected -- makes dir_emit() copy up to
255 (name_len) bytes from a bogus entry, possibly reading past the end
of the folio and returning unrelated memory contents to userspace.

Snap unaligned positions onto a valid entry boundary by walking the
rec_len chain from the chunk start before parsing, as ext2 does in
ext2_validate_entry().

[ryusuke: fixed offset wrap-around in nilfs_validate_entry() and
 conformed AI tag to guidelines]

Fixes: 2ba466d74ed7 ("nilfs2: directory entry operations")
Assisted-by: Claude:claude-mythos-5
Signed-off-by: Jake Labelle &lt;southampton.jake.labelle@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: reject non-regular inodes in dsync recovery</title>
<updated>2026-10-08T16:39:43+00:00</updated>
<author>
<name>Jake Labelle</name>
<email>southampton.jake.labelle@gmail.com</email>
</author>
<published>2026-10-08T11:52:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ef2ccb1554df254eb4066171ce93e6d5fb1af2e3'/>
<id>ef2ccb1554df254eb4066171ce93e6d5fb1af2e3</id>
<content type='text'>
During roll-forward recovery, nilfs_recover_dsync_blocks() obtains the
inode designated by fi_ino of a dsync log without checking its type.
If a corrupted image designates a special inode (e.g. a device node)
there, the inode's embedded bmap was never initialized:
__nilfs_read_inode() calls nilfs_bmap_read() only for regular files,
directories and symlinks.  The subsequent nilfs_get_block() then
dereferences the uninitialized bmap-&gt;b_ops and jumps through it,
crashing the kernel or worse.

Regular files, directories, and symlinks are the only inode types
with data blocks to recover; reject anything else before touching
its block mapping.

[ryusuke: conformed AI tag to guidelines]

Fixes: 0f3e1c7f23f8 ("nilfs2: recovery functions")
Assisted-by: Claude:claude-mythos-5
Signed-off-by: Jake Labelle &lt;southampton.jake.labelle@gmail.com&gt;
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
During roll-forward recovery, nilfs_recover_dsync_blocks() obtains the
inode designated by fi_ino of a dsync log without checking its type.
If a corrupted image designates a special inode (e.g. a device node)
there, the inode's embedded bmap was never initialized:
__nilfs_read_inode() calls nilfs_bmap_read() only for regular files,
directories and symlinks.  The subsequent nilfs_get_block() then
dereferences the uninitialized bmap-&gt;b_ops and jumps through it,
crashing the kernel or worse.

Regular files, directories, and symlinks are the only inode types
with data blocks to recover; reject anything else before touching
its block mapping.

[ryusuke: conformed AI tag to guidelines]

Fixes: 0f3e1c7f23f8 ("nilfs2: recovery functions")
Assisted-by: Claude:claude-mythos-5
Signed-off-by: Jake Labelle &lt;southampton.jake.labelle@gmail.com&gt;
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: fix link count underflow when removing corrupted directory</title>
<updated>2026-10-06T17:03:46+00:00</updated>
<author>
<name>Ryusuke Konishi</name>
<email>konishi.ryusuke@gmail.com</email>
</author>
<published>2026-10-06T08:48:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=814f5a53b4724798795b15690ff3d1c1d9ac1eb6'/>
<id>814f5a53b4724798795b15690ff3d1c1d9ac1eb6</id>
<content type='text'>
When removing an empty directory with a corrupted link count (e.g.,
i_nlink is 1 due to filesystem corruption), nilfs_rmdir() calls
drop_nlink() via nilfs_do_unlink() and then calls drop_nlink() again
on the directory inode.  This second call causes an underflow of
i_nlink, triggering a kernel WARNING in drop_nlink().

Fix this issue by using clear_nlink() instead of drop_nlink() to
finalize the link count reset for the target directory in nilfs_rmdir().
Additionally, log a warning message when i_nlink is not 2 before
removing an empty directory to notify about the link count inconsistency.

Reported-by: syzbot+c388db0347b7fc88fa7a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c388db0347b7fc88fa7a
Fixes: d25006523d0b ("nilfs2: pathname operations")
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When removing an empty directory with a corrupted link count (e.g.,
i_nlink is 1 due to filesystem corruption), nilfs_rmdir() calls
drop_nlink() via nilfs_do_unlink() and then calls drop_nlink() again
on the directory inode.  This second call causes an underflow of
i_nlink, triggering a kernel WARNING in drop_nlink().

Fix this issue by using clear_nlink() instead of drop_nlink() to
finalize the link count reset for the target directory in nilfs_rmdir().
Additionally, log a warning message when i_nlink is not 2 before
removing an empty directory to notify about the link count inconsistency.

Reported-by: syzbot+c388db0347b7fc88fa7a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c388db0347b7fc88fa7a
Fixes: d25006523d0b ("nilfs2: pathname operations")
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: simplify nilfs_mdt_writeback()</title>
<updated>2026-10-05T17:12:54+00:00</updated>
<author>
<name>Ryusuke Konishi</name>
<email>konishi.ryusuke@gmail.com</email>
</author>
<published>2026-10-04T23:31:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d4dfe010220320801fc97ae7a6befa3aaf4cb2d1'/>
<id>d4dfe010220320801fc97ae7a6befa3aaf4cb2d1</id>
<content type='text'>
The writepages() callback for metadata files, nilfs_mdt_writeback(),
calls nilfs_mdt_write_folio() for each dirty folio via writeback_iter(),
where read-only superblock checks, folio dirty state clearing on error,
and triggering of the log writer via nilfs_construct_segment() are
performed.  This helper function is used nowhere else.

Executing these operations per folio is inefficient:

- Checking if the filesystem has fallen back to read-only mode is
  repeated redundantly.

- Calling nilfs_construct_segment() inside the per-folio loop causes
  redundant log writer invocations for a single sync request, where only
  the first invocation performs actual log writing.

Unfold nilfs_mdt_write_folio() into nilfs_mdt_writeback() and consolidate
these operations at the function level.  The read-only check is moved to
the top of nilfs_mdt_writeback(), replacing per-folio
nilfs_clear_folio_dirty() calls with a single nilfs_clear_dirty_pages()
call to discard dirty pages across the mapping at once.  Additionally,
nilfs_construct_segment() is invoked once when 'sync_mode' is WB_SYNC_ALL
and the mapping is tagged dirty.

With these operations consolidated outside the loop, the remaining
per-folio actions (calling folio_redirty_for_writepage() on already
dirty folios and unlocking them) serve no purpose, so the folio iteration
itself is removed.

Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The writepages() callback for metadata files, nilfs_mdt_writeback(),
calls nilfs_mdt_write_folio() for each dirty folio via writeback_iter(),
where read-only superblock checks, folio dirty state clearing on error,
and triggering of the log writer via nilfs_construct_segment() are
performed.  This helper function is used nowhere else.

Executing these operations per folio is inefficient:

- Checking if the filesystem has fallen back to read-only mode is
  repeated redundantly.

- Calling nilfs_construct_segment() inside the per-folio loop causes
  redundant log writer invocations for a single sync request, where only
  the first invocation performs actual log writing.

Unfold nilfs_mdt_write_folio() into nilfs_mdt_writeback() and consolidate
these operations at the function level.  The read-only check is moved to
the top of nilfs_mdt_writeback(), replacing per-folio
nilfs_clear_folio_dirty() calls with a single nilfs_clear_dirty_pages()
call to discard dirty pages across the mapping at once.  Additionally,
nilfs_construct_segment() is invoked once when 'sync_mode' is WB_SYNC_ALL
and the mapping is tagged dirty.

With these operations consolidated outside the loop, the remaining
per-folio actions (calling folio_redirty_for_writepage() on already
dirty folios and unlocking them) serve no purpose, so the folio iteration
itself is removed.

Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: ignore non-fatal signals during synchronous log write wait</title>
<updated>2026-09-29T23:35:33+00:00</updated>
<author>
<name>Ryusuke Konishi</name>
<email>konishi.ryusuke@gmail.com</email>
</author>
<published>2026-09-29T18:26:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7131aaa74bcc7c9da1f1d1c8724da75c775557a0'/>
<id>7131aaa74bcc7c9da1f1d1c8724da75c775557a0</id>
<content type='text'>
Based on a syzbot report, Wang Jianjian pointed out that following a
successful directory operation in nilfs_rename(), a synchronous write
requested within nilfs_transaction_commit(), triggered by a sync flag
set by nilfs_commit_chunk(), could be interrupted by a user signal.
This interruption leaves in-memory metadata updates intact while
returning an error, causing inconsistency with the VFS dentry cache and
ultimately triggering a kernel warning.

According to "signal(7)", local disks are not classified as "slow
devices" (such as terminals, FIFOs, or pipes) and their I/O operations
on disk devices are not interrupted by signals.  In kernel space,
waiting for such disk I/O should therefore not be aborted by ordinary
(non-fatal) signals.

Suppress this issue by modifying nilfs_segctor_sync(), which waits for
the log writer thread to complete synchronous writes, to catch only
fatal signals via fatal_signal_pending() and return -EINTR rather than
-ERESTARTSYS.  To complement this change and prevent the wait loop from
busy-looping when schedule() returns immediately due to a pending
non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to
TASK_KILLABLE.

This serves as an effective interim stabilization measure without
structural changes until a comprehensive fix for metadata consistency
is implemented.

Reported-by: syzbot+f6c7e1f1809f235eeb90@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f6c7e1f1809f235eeb90
Fixes: 9ff05123e3bf ("nilfs2: segment constructor")
Tested-by: syzbot+f6c7e1f1809f235eeb90@syzkaller.appspotmail.com
Cc: Wang Jianjian &lt;wangjianjian3@huawei.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Based on a syzbot report, Wang Jianjian pointed out that following a
successful directory operation in nilfs_rename(), a synchronous write
requested within nilfs_transaction_commit(), triggered by a sync flag
set by nilfs_commit_chunk(), could be interrupted by a user signal.
This interruption leaves in-memory metadata updates intact while
returning an error, causing inconsistency with the VFS dentry cache and
ultimately triggering a kernel warning.

According to "signal(7)", local disks are not classified as "slow
devices" (such as terminals, FIFOs, or pipes) and their I/O operations
on disk devices are not interrupted by signals.  In kernel space,
waiting for such disk I/O should therefore not be aborted by ordinary
(non-fatal) signals.

Suppress this issue by modifying nilfs_segctor_sync(), which waits for
the log writer thread to complete synchronous writes, to catch only
fatal signals via fatal_signal_pending() and return -EINTR rather than
-ERESTARTSYS.  To complement this change and prevent the wait loop from
busy-looping when schedule() returns immediately due to a pending
non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to
TASK_KILLABLE.

This serves as an effective interim stabilization measure without
structural changes until a comprehensive fix for metadata consistency
is implemented.

Reported-by: syzbot+f6c7e1f1809f235eeb90@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f6c7e1f1809f235eeb90
Fixes: 9ff05123e3bf ("nilfs2: segment constructor")
Tested-by: syzbot+f6c7e1f1809f235eeb90@syzkaller.appspotmail.com
Cc: Wang Jianjian &lt;wangjianjian3@huawei.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: clear dirty flag on bdev buffers on log write failure</title>
<updated>2026-09-29T17:49:58+00:00</updated>
<author>
<name>Ryusuke Konishi</name>
<email>konishi.ryusuke@gmail.com</email>
</author>
<published>2026-09-29T06:38:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6faad04a002603d800134398fcd042b403b32d35'/>
<id>6faad04a002603d800134398fcd042b403b32d35</id>
<content type='text'>
Since the commit referenced in the Fixes tag stopped directly calling
inode_attach_wb(), a dirty flag is set on buffers (with
mark_buffer_dirty()) allocated to the backing device for segment
summaries and the super root block during log writes.

While this dirty flag is cleared upon a successful log write, it remains
uncleared if the log write fails.

Consequently, when a log write fails, these backing device buffers are
left in an inconsistent state where their uptodate flag and the dirty
flag of the containing page/folio are cleared, but the buffer's dirty
flag remains as stale garbage.

Particularly when the block size is smaller than the page size, if other
buffers on the same page/folio become dirty, this buffer unexpectedly
becomes a target for writeback again.  As a result, if the block is
later reused for other data or metadata, that contents risks being
corrupted.

Fix this issue by calling clear_buffer_dirty() for the backing device
buffers when aborting log writes in nilfs_abort_logs().

Fixes: 68142cb628f7 ("nilfs2: do not call inode_attach_wb() directly")
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since the commit referenced in the Fixes tag stopped directly calling
inode_attach_wb(), a dirty flag is set on buffers (with
mark_buffer_dirty()) allocated to the backing device for segment
summaries and the super root block during log writes.

While this dirty flag is cleared upon a successful log write, it remains
uncleared if the log write fails.

Consequently, when a log write fails, these backing device buffers are
left in an inconsistent state where their uptodate flag and the dirty
flag of the containing page/folio are cleared, but the buffer's dirty
flag remains as stale garbage.

Particularly when the block size is smaller than the page size, if other
buffers on the same page/folio become dirty, this buffer unexpectedly
becomes a target for writeback again.  As a result, if the block is
later reused for other data or metadata, that contents risks being
corrupted.

Fix this issue by calling clear_buffer_dirty() for the backing device
buffers when aborting log writes in nilfs_abort_logs().

Fixes: 68142cb628f7 ("nilfs2: do not call inode_attach_wb() directly")
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>nilfs2: fix deadlock between nilfs_evict_inode() and find_inode()</title>
<updated>2026-09-24T18:19:01+00:00</updated>
<author>
<name>Ryusuke Konishi</name>
<email>konishi.ryusuke@gmail.com</email>
</author>
<published>2026-09-23T16:41:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ff1227f70eead8704ecfec69259fb4c041f92cda'/>
<id>ff1227f70eead8704ecfec69259fb4c041f92cda</id>
<content type='text'>
Syzbot reported a deadlock between nilfs_evict_inode(), executed via
an asynchronous workqueue (kworker) as:

  process_one_work()
    process_scheduled_works()
      nilfs_iput_work_func()
        nilfs_dispose_list()
          iput()
            iput_final()
              evict()
                s_op-&gt;evict_inode()
                  nilfs_evict_inode()

and find_inode(), called via

  nilfs_mkdir()
    nilfs_new_inode()
      nilfs_insert_inode_locked()
        insert_inode_locked4()
          inode_insert5()
            find_inode()

When an inode is deleted (i_nlink == 0), nilfs_evict_inode() clears its
ifile bitmap entry and then synchronously triggers the log writer via
nilfs_transaction_commit() if IS_SYNC(inode) is true.

If a concurrent directory creation via nilfs_new_inode() attempts to
allocate the same newly freed inode number, however, find_inode() called
just before inserting it into the inode hash, blocks waiting for the old
inode's evict() to complete.

Meanwhile, the synchronous log writer invoked from nilfs_evict_inode()
tries to acquire a write lock on 'ns_segctor_sem' which is read locked
by the caller of nilfs_new_inode() (in this case, nilfs_mkdir()),
resulting in a deadlock.

The synchronous log writer invocation from nilfs_evict_inode() is a
legacy artifact; it is no longer necessary because the call itself
(triggered by iput()) is now handled asynchronously with a kworker
if i_nlink == 0.  It merely increases the risk of deadlock.

Fix this deadlock by removing the synchronous log writer trigger from
nilfs_evict_inode().

Reported-by: syzbot+6646318bbcf419411bc5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6646318bbcf419411bc5
Fixes: 7ef3ff2fea8b ("nilfs2: fix deadlock of segment constructor over I_SYNC flag")
Tested-by: syzbot+6646318bbcf419411bc5@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Syzbot reported a deadlock between nilfs_evict_inode(), executed via
an asynchronous workqueue (kworker) as:

  process_one_work()
    process_scheduled_works()
      nilfs_iput_work_func()
        nilfs_dispose_list()
          iput()
            iput_final()
              evict()
                s_op-&gt;evict_inode()
                  nilfs_evict_inode()

and find_inode(), called via

  nilfs_mkdir()
    nilfs_new_inode()
      nilfs_insert_inode_locked()
        insert_inode_locked4()
          inode_insert5()
            find_inode()

When an inode is deleted (i_nlink == 0), nilfs_evict_inode() clears its
ifile bitmap entry and then synchronously triggers the log writer via
nilfs_transaction_commit() if IS_SYNC(inode) is true.

If a concurrent directory creation via nilfs_new_inode() attempts to
allocate the same newly freed inode number, however, find_inode() called
just before inserting it into the inode hash, blocks waiting for the old
inode's evict() to complete.

Meanwhile, the synchronous log writer invoked from nilfs_evict_inode()
tries to acquire a write lock on 'ns_segctor_sem' which is read locked
by the caller of nilfs_new_inode() (in this case, nilfs_mkdir()),
resulting in a deadlock.

The synchronous log writer invocation from nilfs_evict_inode() is a
legacy artifact; it is no longer necessary because the call itself
(triggered by iput()) is now handled asynchronously with a kworker
if i_nlink == 0.  It merely increases the risk of deadlock.

Fix this deadlock by removing the synchronous log writer trigger from
nilfs_evict_inode().

Reported-by: syzbot+6646318bbcf419411bc5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6646318bbcf419411bc5
Fixes: 7ef3ff2fea8b ("nilfs2: fix deadlock of segment constructor over I_SYNC flag")
Tested-by: syzbot+6646318bbcf419411bc5@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Ryusuke Konishi &lt;konishi.ryusuke@gmail.com&gt;
Signed-off-by: Viacheslav Dubeyko &lt;slava@dubeyko.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
