Skip to contentSkip to conversation

loop: don't require ->write_iter for writable files in loop_configure

PATCH Applied Christoph Hellwig 2 participants 2 messages May 20, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loop: don't require ->write_iter for writable files in loop_configure

Block devices can be opened read-write even if they can't be written to for historic reasons. Remove the check requiring file->f_op->write_iter when the block devices was opened in loop_configure. The call to loop_check_backing_file just below ensures the ->write_iter is present for backing files opened for writing, which is the only check that is actually needed.

Fixes f5c84eff634b ("loop: Add sanity check for read/write_iter")
---
 drivers/block/loop.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/block/loop.c +0 -3
index b8ba7de08753..e2b1f377f585 100644
@@ -979,9 +979,6 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
 	if (!file)
 		return -EBADF;
 
-	if ((mode & BLK_OPEN_WRITE) && !file->f_op->write_iter)
-		return -EINVAL;
-
 	error = loop_check_backing_file(file);
 	if (error)
 		return error;
Signature · 1 line
2.47.2
maintainer Applied
#1 lore raw
Quoted 8 lines · Christoph Hellwig

Block devices can be opened read-write even if they can't be written to for historic reasons. Remove the check requiring file->f_op->write_iter when the block devices was opened in loop_configure. The call to loop_check_backing_file just below ensures the ->write_iter is present for backing files opened for writing, which is the only check that is actually needed.

[...]

Applied, thanks!

[1/1] loop: don't require ->write_iter for writable files in loop_configure

      commit: 355341e4359b2d5edf0ed5e117f7e9e7a0a5dac0

Best regards,

Signature · 1 line
Jens Axboe