mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Jan Kara <jack@suse.cz>
Cc: Shakeel Butt <shakeel.butt@linux.dev>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	Jens Axboe <axboe@kernel.dk>,
	 linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 io-uring@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	 linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	 linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	 linux-unionfs@vger.kernel.org, bpf@vger.kernel.org,
	 linux-nfs@vger.kernel.org,
	 "Christian Brauner (Amutable)" <brauner@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH v2 10/17] target: fileio: take freeze protection for unmap
Date: Mon, 16 Nov 2026 12:03:50 +0100	[thread overview]
Message-ID: <20261116-work-fs-frozen_writes-v2-10-ecc4a2aac40e@kernel.org> (raw)
In-Reply-To: <20261116-work-fs-frozen_writes-v2-0-ecc4a2aac40e@kernel.org>

UNMAP and WRITE SAME with UNMAP=1 end up in fd_execute_unmap() which
calls ->fallocate() of the backing file directly. That skips the freeze
protection vfs_fallocate() would have taken. So they go straight
through to a filesystem that is frozen, with and without fd_async_io.
With the backing file on ext4:

  WARNING: fs/ext4/ext4_jbd2.c:90 at ext4_journal_check_start+0x1f6/0x2d0, CPU#1: kworker/1:1/50
  Workqueue: target_submission target_queued_submit_work
  Call Trace:
   <TASK>
   __ext4_journal_start_sb+0x7a/0x470
   ext4_dirty_inode+0xa1/0x120
   __mark_inode_dirty+0x154/0x1110
   file_update_time_flags+0x3ab/0x4b0
   ext4_fallocate+0x286/0x3440
   fd_execute_unmap+0x1eb/0x6e0
   sbc_execute_write_same_unmap+0x93/0xe0
   __target_execute_cmd+0x53/0x190
   tcm_loop_write_pending+0xe/0x20
   transport_generic_new_cmd+0x612/0xdb0
   __target_submit+0x12c/0x380
   target_queued_submit_work+0x73/0x270
   process_one_work+0x946/0x1820
   worker_thread+0x4f1/0xd60
   kthread+0x364/0x460
   ret_from_fork+0x525/0x770
   ret_from_fork_asm+0x1a/0x30
   </TASK>

Take freeze protection around ->fallocate() like vfs_fallocate() does.

Fixes: 70d3ae5c8075 ("target/file: Add WRITE_SAME w/ UNMAP=1 emulation support")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
 drivers/target/target_core_file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index e8a44ddf6f5c9..5600ef7bbdbb6 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -584,7 +584,8 @@ fd_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
 		if (!file->f_op->fallocate)
 			return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 
-		ret = file->f_op->fallocate(file, mode, pos, len);
+		scoped_guard(file_write, file)
+			ret = file->f_op->fallocate(file, mode, pos, len);
 		if (ret < 0) {
 			pr_warn("FILEIO: fallocate() failed: %d\n", ret);
 			return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;

-- 
2.53.0


  parent reply	other threads:[~2026-11-16 11:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:03 [PATCH v2 00/17] fs: take freeze protection for writes to backing files Christian Brauner
2026-11-16 11:03 ` [PATCH v2 01/17] fs: add kiocb_start_write_trylock() Christian Brauner
2026-11-16 11:03 ` [PATCH v2 02/17] fs: add kiocb_write_iter() and kiocb_end_write_iter() Christian Brauner
2026-11-16 11:03 ` [PATCH v2 03/17] fs: add file_write guard Christian Brauner
2026-11-16 11:03 ` [PATCH v2 04/17] zloop: take freeze protection for writes Christian Brauner
2026-11-16 11:03 ` [PATCH v2 05/17] nvmet: take freeze protection for writes to files Christian Brauner
2026-11-16 11:03 ` [PATCH v2 06/17] target: fileio: don't free the aio command under the filesystem Christian Brauner
2026-11-16 11:03 ` [PATCH v2 07/17] target: fileio: take freeze protection for aio writes Christian Brauner
2026-11-16 11:03 ` [PATCH v2 08/17] loop: take freeze protection for discard and write zeroes Christian Brauner
2026-11-16 11:03 ` [PATCH v2 09/17] zloop: take freeze protection when recording write pointers Christian Brauner
2026-11-16 11:03 ` Christian Brauner [this message]
2026-11-16 11:03 ` [PATCH v2 11/17] coredump: take freeze protection for the truncate Christian Brauner
2026-11-16 11:03 ` [PATCH v2 12/17] ovl: take freeze protection when storing the uuid Christian Brauner
2026-11-16 11:03 ` [PATCH v2 13/17] bpf: fs/xattr: take freeze protection in the xattr kfuncs Christian Brauner
2026-11-16 11:03 ` [PATCH v2 14/17] nfsd: take freeze protection for the truncate on open Christian Brauner
2026-11-16 11:03 ` [PATCH v2 15/17] loop: use kiocb_write_iter() Christian Brauner
2026-11-16 11:03 ` [PATCH v2 16/17] fs: use kiocb_write_iter() in vfs_iocb_iter_write() Christian Brauner
2026-11-16 11:03 ` [PATCH v2 17/17] backing-file: use kiocb_end_write_iter() Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116-work-fs-frozen_writes-v2-10-ecc4a2aac40e@kernel.org \
    --to=brauner@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=io-uring@vger.kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=target-devel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®