Is there a reason why REQ_OP_READ has to be 0?
Subsystems (2)
Hi Jens, Christoph,
Do you know if there's a reason why REQ_OP_READ has to be 0? I'm seeing a circumstance where a direct I/O write on a blockdev is BUG'ing in my modified iov_iter code because the iterator says it's a source iterator (correct), but the bio->bi_opf == REQ_OP_READ (which should be wrong).
I thought I'd move REQ_OP_READ to, say, 4 so that I could try and see if it's just undefined but the kernel BUGs and then panics during boot.
David
------------[ cut here ]------------ kernel BUG at mm/filemap.c:1615! ------------[ cut here ]------------ invalid opcode: 0000 [#1] PREEMPT SMP PTI kernel BUG at mm/filemap.c:1615! CPU: 1 PID: 2196 Comm: systemd-udevd Not tainted 6.2.0-rc2-build3+ #12783 Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014 RIP: 0010:folio_end_writeback+0x30/0x70 Code: 48 8b 07 48 89 fb 0f ba e0 12 73 0a f0 80 67 02 fb e8 d0 de 00 00 48 89 df e8 fe df ff ff 48 89 df e8 f9 ac 00 00 84 c0 75 02 <0f> 0b 48 8b 03 84 c0 79 0d be 0f 00 00 00 48 89 df e8 44 f3 ff ff RSP: 0000:ffff8881091a3db8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffffea0004271d40 RCX: 0000000000001000 RDX: 0000000000000101 RSI: 0000000000000246 RDI: ffff888107694000 RBP: ffff888100b6f600 R08: 000000204d567e99 R09: 0000000000000200 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000001 R14: 0000000000001000 R15: ffff888107402080 FS: 00007f65ecde8940(0000) GS:ffff88840fa80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb269292ba1 CR3: 0000000107140004 CR4: 00000000001706e0 Call Trace: <TASK> mpage_end_io+0x91/0x9b blk_update_request+0x200/0x2be scsi_end_request+0x27/0xf3 scsi_io_completion+0x151/0x21e blk_complete_reqs+0x41/0x4c __do_softirq+0x123/0x27d __irq_exit_rcu+0x5a/0xcd common_interrupt+0x36/0xbc asm_common_interrupt+0x22/0x40 RIP: 0033:0x7f65edc7ab60 Code: 00 41 29 c5 4a 8d 14 ed 00 00 00 00 49 8d 34 0c 49 8d 7c 0c f8 e8 d0 5e ff ff 83 6d 20 01 eb 9f 66 2e 0f 1f 84 00 00 00 00 00 <f3> 0f 1e fa 53 48 89 fb 48 83 c7 08 e8 7f 60 ff ff 85 c0 75 0b 48 RSP: 002b:00007ffe0b70bd88 EFLAGS: 00000202 RAX: 0000000000000000 RBX: 000055ddc430c5dc RCX: 000055ddc4301f98 RDX: 00000000000000ff RSI: 000000000000000c RDI: 000055ddc4301f98 RBP: 00007ffe0b7102d0 R08: 45d54cec8b358fc3 R09: 00544145535f4449 R10: 000000000000000c R11: f17eedd8cae0d043 R12: 000055ddc4302920 R13: 000055ddc432091a R14: 000055ddc4308460 R15: 000055ddc42d90dc </TASK> Modules linked in:
invalid opcode: 0000 [#2] PREEMPT SMP PTI
Quoted 9 lines · David Howells
Hi Jens, Christoph,
Do you know if there's a reason why
REQ_OP_READhas to be 0? I'm seeing a circumstance where a direct I/O write on a blockdev is BUG'ing in my modifiediov_itercode because the iterator says it's a source iterator (correct), but thebio->bi_opf==REQ_OP_READ(which should be wrong).I thought I'd move
REQ_OP_READto, say, 4 so that I could try and see if it's just undefined but the kernel BUGs and then panics during boot.
There's all kind of assumptions of that from basically day 1 of Linux. The most obvious one is in op_is_write, but I'm pretty sure there are more hidden somewhere.
Jens Axboe
maintainerQuoted 8 lines · Christoph Hellwig
Quoted 7 lines · David Howells
Hi Jens, Christoph,
Do you know if there's a reason why
REQ_OP_READhas to be 0? I'm seeing a circumstance where a direct I/O write on a blockdev is BUG'ing in my modifiediov_itercode because the iterator says it's a source iterator (correct), but thebio->bi_opf==REQ_OP_READ(which should be wrong).
Quoted 6 lines
Quoted 2 lines
I thought I'd move
REQ_OP_READto, say, 4 so that I could try and see if it's just undefined but the kernel BUGs and then panics during boot.There's all kind of assumptions of that from basically day 1 of Linux. The most obvious one is in
op_is_write, but I'm pretty sure there are more hidden somewhere.
I didn't get this original email...
I would not change this frivilously, as Christoph says we've used 0/1 for basic read/write data direction since basically forever. So for all intents and purposes, yes that is basically hardwired.
Signature · 1 line
Jens Axboe
Aha!
The problem is that whilst aio, io_uring and cachefiles set IOCB_WRITE when giving a write op to the VFS, the write() syscall does not...
David