[PATCH v2 02/17] fs: add kiocb_write_iter() and kiocb_end_write_iter()
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Mon Nov 16 03:30:59 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] fs: unconditional freeze protection on non-regular files in
kiocb_write_iter()
--
commit c4bb9dc6398af3c2e2efc447c0b1b29d081b55ab
Author: Christian Brauner <brauner at kernel.org>
fs: add kiocb_write_iter() and kiocb_end_write_iter()
This commit adds kiocb_write_iter() and kiocb_end_write_iter() helpers to
manage superblock freeze protection across ->write_iter() calls.
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index eefc2c9d4af19..0b66a09fb686a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2840,6 +2840,54 @@ static inline void kiocb_end_write(struct kiocb *iocb)
[ ... ]
> +static inline ssize_t kiocb_write_iter(struct kiocb *iocb,
> + struct iov_iter *iter)
> +{
> + ssize_t ret;
> +
> + if (iocb->ki_flags & IOCB_NOWAIT) {
> + if (!kiocb_start_write_trylock(iocb))
> + return -EAGAIN;
> + } else {
> + kiocb_start_write(iocb);
> + }
> + iocb->ki_flags |= IOCB_WRITE;
[Severity: Medium]
Should kiocb_write_iter() check S_ISREG(file_inode(iocb->ki_filp)->i_mode)
before taking freeze protection and setting IOCB_WRITE, the way
file_start_write(), aio_write() and io_kiocb_start_write() do?
Callers such as loop and target_core_file accept S_ISBLK backing files.
Opening a block device node leaves file_inode(file)->i_sb pointing at the
filesystem hosting the device node rather than the block device. Without
an S_ISREG() check, writes to a block device node whose hosting filesystem
is frozen will block in sb_start_write() (or fail with -EAGAIN for
IOCB_NOWAIT), and will deadlock if that filesystem is mounted on or
flushing through the virtual block device during freeze_super().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-work-fs-frozen_writes-v2-0-ecc4a2aac40e@kernel.org?part=2
More information about the Linux-nvme
mailing list