Skip to contentSkip to conversation

2.6.0-test6-mm4

DISCUSSION Andrew Morton 5 participants 11 messages Oct 5, 2003 – Oct 10, 2003 Memory management

lore
Share & tools
lore
#0 lore raw

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.0-test6/2.6.0-test6-mm4/

This is a small stabilisation update against -mm3 to fix various bits of brokenness which people have inflicted upon me. To make it all build, boot and run on ia32, ia64 and ppc64.

Changes since 2.6.0-test6-mm3:

linus.patch

latest Linus tree

-skb-leak-fix.patch

Merged

-utime-on-immutable-file-fix-cleanup.patch

Dropped: the current code is OK.

-readonly-bind-mounts.patch

This got broken.

+compat-ioctl-consolidation-job-control-update.patch

Update compat-ioctl-consolidation.patch for move-job-control-fields.patch

+move-job-control-fields-ia64-fix.patch

Fix ia64 for move-job-control-fields.patch

+ia32-efi-other-arch-fix.patch

Fix ia32-efi-support.patch for non-ia32 builds

+sparc32-sched_clock.patch

Simple sched_clock() implementation for sparc32

+unmap_vmas-warning-fix.patch

Warning fixlet

+athlon-prefetch-handling.patch
+athlon-prefetch-handling-fix.patch

Latest athlon prefetch workaround.

All 155 patches:

linus.patch

mm.patch
add -mmN to EXTRAVERSION

kgdb-ga.patch
kgdb stub for ia32 (George Anzinger's one)
kgdbL warning fix

kgdb-buff-too-big.patch
kgdb buffer overflow fix

kgdb-warning-fix.patch
kgdbL warning fix

kgdb-build-fix.patch

kgdb-spinlock-fix.patch

kgdb-fix-debug-info.patch
kgdb: CONFIG_DEBUG_INFO fix

kgdb-cpumask_t.patch

kgdb-x86_64-fixes.patch
x86_64 fixes

kgdb-over-ethernet.patch
kgdb-over-ethernet patch

kgdb-over-ethernet-fixes.patch
kgdb-over-ethernet fixlets

kgdb-CONFIG_NET_POLL_CONTROLLER.patch
kgdb: replace CONFIG_KGDB with CONFIG_NET_RX_POLL in net drivers

kgdb-handle-stopped-NICs.patch
kgdb: handle netif_stopped NICs

eepro100-poll-controller.patch

tlan-poll_controller.patch

tulip-poll_controller.patch

tg3-poll_controller.patch
kgdb: tg3 poll_controller

kgdb-eth-smp-fix.patch
kgdb-over-ethernet: fix SMP

kgdb-eth-reattach.patch

kgdb-skb_reserve-fix.patch
kgdb-over-ethernet: skb_reserve() fix

must-fix.patch

should-fix.patch

RD0-initrd-B6.patch

RD1-cdrom_ioctl-B6.patch

RD2-ioctl-B6.patch

RD2-ioctl-B6-fix.patch
RD2-ioctl-B6 fixes

RD3-cdrom_open-B6.patch

RD4-open-B6.patch

RD5-cdrom_release-B6.patch

RD6-release-B6.patch

RD7-presto_journal_close-B6.patch

RD8-f_mapping-B6.patch

RD9-f_mapping2-B6.patch

RD10-i_sem-B6.patch

RD11-f_mapping3-B6.patch

RD12-generic_osync_inode-B6.patch

RD13-bd_acquire-B6.patch

RD14-generic_write_checks-B6.patch

RD15-I_BDEV-B6.patch

RD16-rest-B6.patch

serio-01-renaming.patch
serio: rename serio_[un]register_slave_port to __serio_[un]register_port

serio-02-race-fix.patch
serio: possible race between port removal and kseriod

serio-03-blacklist.patch
Add black list to handler<->device matching

serio-04-synaptics-cleanup.patch
Synaptics: code cleanup

serio-05-reconnect-facility.patch
serio: reconnect facility

serio-06-synaptics-use-reconnect.patch
Synaptics: use serio_reconnect

acpi_off-fix.patch
fix acpi=off

cfq-4.patch
CFQ io scheduler
CFQ fixes

config_spinline.patch
uninline spinlocks for profiling accuracy.

ppc64-bar-0-fix.patch
Allow PCI BARs that start at 0

ppc64-reloc_hide.patch

ppc64-semaphore-reimplementation.patch
ppc64: use the ia32 semaphore implementation

ppc64-sym2-fix.patch
ppc64 sym2 fix

sym-do-160.patch
make the SYM driver do 160 MB/sec

input-use-after-free-checks.patch
input layer debug checks

fbdev.patch
framebbuffer driver update

cursor-flashing-fix.patch
fbdev: fix cursor letovers

radeonfb-line_length-fix.patch
From: Peter Chubb <[email protected]>
Subject: Radeon framebuffer problems i 2.6.0-test6

aic7xxx-parallel-build-fix.patch
fix parallel builds for aic7xxx

ramdisk-cleanup.patch

intel8x0-cleanup.patch
intel8x0 cleanups

uml-update.patch
Update UML to 2.6.0-test5

selectable-logbuf-size.patch
boot-time selectable log buffer size

8139too-edimax.patch

pdflush-diag.patch

kobject-oops-fixes.patch
fix oopses is kobject parent is removed before child

futex_refs_and_lock_fix.patch
futex locking fix

futex-locking-fix-fix.patch
fix to futex locking fix

futex-uninlinings.patch
futex uninlining

node-enumeration-cleanup-01.patch
Clean up MAX_NR_NODES/NUMNODES/etc. [1/5]

node-enumeration-cleanup-02.patch
Clean up MAX_NR_NODES/NUMNODES/etc. [2/5]

node-enumeration-cleanup-03.patch
Clean up MAX_NR_NODES/NUMNODES/etc. [3/5]

node-enumeration-cleanup-04.patch
Clean up MAX_NR_NODES/NUMNODES/etc. [4/5]

node-enumeration-cleanup-05.patch
Clean up MAX_NR_NODES/NUMNODES/etc. [5/5]

node-enumeration-cleanup-fix-01.patch
node enumeration fixes

zap_page_range-debug.patch
zap_page_range() debug

acpi-thinkpad-fix.patch
APCI fix for thinkpads

compat-ioctl-consolidation.patch
compat ioctl consolidation

compat-ioctl-consolidation-job-control-update.patch

alsa-gameport-fix.patch
ALSA pci Kconfig fix

scsi-handle-zero-length-requests.patch
scsi: handle zero-length requests

sizeof-in-ioctl-fix.patch
incorrect use of sizeof() in aty128fb

call_usermodehelper-retval-fix-3.patch
Make call_usermodehelper report exit status

asus-L5-fix.patch
Asus L5 framebuffer fix

ax25-timer-cleanup.patch
X25 timer cleanup

jffs-use-daemonize.patch

calc_vm_trans-commentary.patch
document the macro for translating PROT_ to VM_ bits

tulip-NAPI-support.patch
tulip NAPI support

tulip-napi-disable.patch
tulip NAPI: disable poll in close

io-refcount-debugging.patch
io context refcounting debugging

proc-sys-auxv.patch
/proc/sys/auxv

kernel-doc-fixes.patch
kernel documentation fixes

kill-CONFIG_EISA_ALWAYS.patch
EISA_bus cleanup

ext3-concurrent-alloc-locking-fix.patch

dscc4-fixes.patch
dscc4 driver fixes

cpufreq-sysfs-oops-fix.patch
cpufreq sysfs oops fix

move-job-control-fields.patch
move job control fields from task_struct to signal_struct

move-job-control-fields-ia64-fix.patch

get_user_pages-handle-VM_IO.patch

ia32-MSI-support.patch
Updated ia32 MSI Patches

ia32-MSI-support-tweaks.patch

ia32-efi-support.patch
EFI support for ia32

CONFIG_ACPI_EFI-defaults-off.patch

ia32-efi-support-warning-fixes.patch

ia32-efi-support-tidy.patch

ia32-efi-other-arch-fix.patch
fix EFI for ppc64, ia64

support-zillions-of-scsi-disks.patch
support many SCSI disks

dynamic-irq_vector-allocation.patch
dynamic irq_vector allocation for ia32

SGI-IOC4-IDE-chipset-support.patch
Add support for SGI's IOC4 chipset

do_no_page-pte_chain_leak-fix.patch
fix pte_chain leak in do_no_page

vma-split-truncate-race-fix.patch
fix split_vma vs. invalidate_mmap_range_list race

vma-split-truncate-race-fix-tweaks.patch

sparc32-sched_clock.patch

unmap_vmas-warning-fix.patch
Fix unmap_vmas() compile warning

keyboard-repeat-rate-setting-fix.patch
keyboard repeat rate setting fix

list_del-debug.patch
list_del debug check

print-build-options-on-oops.patch
print a few config options on oops

show_task-free-stack-fix.patch
show_task() fix and cleanup

oops-dump-preceding-code.patch
i386 oops output: dump preceding code

lockmeter.patch

printk-oops-mangle-fix.patch
disentangle printk's whilst oopsing on SMP

20-odirect_enable.patch

21-odirect_cruft.patch

22-read_proc.patch

23-write_proc.patch

24-commit_proc.patch

25-odirect.patch

nfs-O_DIRECT-always-enabled.patch
Force CONFIG_NFS_DIRECTIO

4g-2.6.0-test2-mm2-A5.patch
4G/4G split patch
4G/4G: remove debug code
4g4g: pmd fix
4g/4g: fixes from Bill
4g4g: fpu emulation fix
4g/4g usercopy atomicity fix
4G/4G: remove debug code
4g4g: pmd fix
4g/4g: fixes from Bill
4g4g: fpu emulation fix
4g/4g usercopy atomicity fix
4G/4G preempt on vstack
4G/4G: even number of kmap types
4g4g: fix __get_user in slab
4g4g: Remove extra .data.idt section definition
4g/4g linker error (overlapping sections)
4G/4G: remove debug code
4g4g: pmd fix
4g/4g: fixes from Bill
4g4g: fpu emulation fix
4g4g: show_registers() fix
4g/4g usercopy atomicity fix
4g4g: debug flags fix
4g4g: Fix wrong asm-offsets entry
cyclone time fixmap fix
4G/4G preempt on vstack
4G/4G: even number of kmap types
4g4g: fix __get_user in slab
4g4g: Remove extra .data.idt section definition
4g/4g linker error (overlapping sections)
4G/4G: remove debug code
4g4g: pmd fix
4g/4g: fixes from Bill
4g4g: fpu emulation fix
4g4g: show_registers() fix
4g/4g usercopy atomicity fix
4g4g: debug flags fix
4g4g: Fix wrong asm-offsets entry
cyclone time fixmap fix
use direct_copy_{to,from}_user for kernel access in mm/usercopy.c 4G/4G might_sleep warning fix
4g/4g pagetable accounting fix

athlon-prefetch-handling.patch
Athlon prefetch patch for 2.6.0test6mm2

athlon-prefetch-handling-fix.patch

ppc-fixes.patch
make mm4 compile on ppc

aic7xxx_old-oops-fix.patch

O_DIRECT-race-fixes-rollup.patch
DIO fixes forward port and AIO-DIO fix
O_DIRECT race fixes comments
O_DRIECT race fixes fix fix fix
DIO locking rework

O_DIRECT-race-fixes-rework-XFS-fix.patch
O_DIRECT XFS fix

aio-01-retry.patch
AIO: Core retry infrastructure
Fix aio process hang on EINVAL
AIO: flush workqueues before destroying ioctx'es
AIO: hold the context lock across unuse_mm task task_lock in use_mm()

aio-refcounting-fix.patch
aio ref count in io_submit_one

aio-retry-elevated-refcount.patch
aio: extra ref count during retry

aio-02-lockpage_wq.patch
AIO: Async page wait

aio-03-fs_read.patch
AIO: Filesystem aio read

aio-04-buffer_wq.patch
AIO: Async buffer wait
lock_buffer_wq fix

aio-05-fs_write.patch
AIO: Filesystem aio write

aio-06-bread_wq.patch
AIO: Async block read

aio-07-ext2getblk_wq.patch
AIO: Async get block for ext2

O_SYNC-speedup-2.patch
speed up O_SYNC writes

O_SYNC-speedup-2-f_mapping-fixes.patch

aio-09-o_sync.patch
aio O_SYNC
AIO: fix a BUG
Unify o_sync changes for aio and regular writes
aio-O_SYNC-fix bits got lost
aio: writev nr_segs fix
More AIO O_SYNC related fixes

aio-09-o_sync-f_mapping-fixes.patch

gang_lookup_next.patch
Change the page gang lookup API

aio-gang_lookup-fix.patch
AIO gang lookup fixes

aio-O_SYNC-short-write-fix.patch
Fix for O_SYNC short writes

aio-12-readahead.patch
AIO: readahead fixes
aio O_DIRECT no readahead
Unified page range readahead for aio and regular reads

aio-12-readahead-f_mapping-fix.patch

aio-readahead-speedup.patch
Readahead issues and AIO read speedup

#1 lore raw

It doesn't compile to me ...
too many undefined references to ntohl/htonl/htons/...

make all:
..
fs/built-in.o: In function `ext3_get_dev_journal':
/usr/src/linux-2.6.0-test6-mm4/fs/ext3/super.c:1533: undefined reference to ntohl' /usr/src/linux-2.6.0-test6-mm4/fs/ext3/super.c:1534: undefined reference to ntohl' fs/built-in.o: In function `journal_commit_transaction':
/usr/src/linux-2.6.0-test6-mm4/fs/jbd/commit.c:376: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/fs/jbd/commit.c:377: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/fs/jbd/commit.c:378: undefined reference to htonl' fs/built-in.o: In function journal_commit_transaction':
/usr/src/linux-2.6.0-test6-mm4/include/linux/jbd.h:306: undefined reference to htonl' fs/built-in.o: In function journal_commit_transaction':
/usr/src/linux-2.6.0-test6-mm4/fs/jbd/commit.c:444: undefined reference to htonl' fs/built-in.o:/usr/src/linux-2.6.0-test6-mm4/fs/jbd/commit.c:468: more undefined references to htonl' follow fs/built-in.o: In function `journal_recover':
/usr/src/linux-2.6.0-test6-mm4/fs/jbd/recovery.c:240: undefined reference to ntohl' fs/built-in.o: In function do_one_pass':
/usr/src/linux-2.6.0-test6-mm4/fs/jbd/recovery.c:331: undefined reference to ntohl' net/built-in.o: In function ip_rt_redirect':
/usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:981: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:981: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:981: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:981: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:981: undefined reference to htonl' net/built-in.o:/usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:981: more undefined references to htonl' follow net/built-in.o: In function `ip_rt_frag_needed':
/usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1243: undefined reference to ntohs' net/built-in.o: In function ip_route_input_mc':
/usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: undefined reference to htonl' net/built-in.o:/usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: more undefined references to htonl' follow net/built-in.o: In function `ip_route_input_mc':
/usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1448: undefined reference to htons' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1452: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1452: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1453: undefined reference to htonl' /usr/src/linux-2.6.0-test6-mm4/net/ipv4/route.c:1453: undefined reference to `htonl'
...
...
make: *** [.tmp_vmlinux1] Error 1

Signature · 1 line
Daniele.
#2 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

In reply to Andrew Morton

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

Unable to handle kernel paging request at virtual address 6b6b6b6b
 printing eip:
c018fa34
*pde = 00000000
Oops: 0000 [#1]
SMP
CPU:    1
EIP:    0060:[<c018fa34>]    Not tainted VLI
EFLAGS: 00010002

EIP is at __aio_run_iocbs+0x19/0xa2
eax: 00000000 ebx: d443b318 ecx: d4055c78 edx: 6b6b6b6b
esi: d4055c78 edi: d4055cb0 ebp: dfd6df48 esp: dfd6df34
ds: 007b es: 007b ss: 0068
Process aio/1 (pid: 16, threadinfo=dfd6c000 task=dfd71340)

Stack: 00010000 dfd71914 d4055c78 d4055c9c dfd72790 dfd6df68 c018faf6 d4055c78
       dfd6df54 dfd6df54 dfd6c000 d4055cfc 00000287 dfd6dfec c0138ad8 d4055c78
       dfd6dfa0 00000000 5a5a5a5a dfd727b8 dfd727a8 d4055c78 c018fabd dfd727a0

Call Trace:
 [<c018faf6>] aio_kick_handler+0x39/0x96
 [<c0138ad8>] worker_thread+0x1e6/0x346
 [<c018fabd>] aio_kick_handler+0x0/0x96
 [<c0122041>] default_wake_function+0x0/0x2e

Daniel

#3 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

Quoted 7 lines · Daniel McNeil

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

What are the i/o sizes and block sizes for which you get the oops ? Is this only for large i/o sizes ?

__aio_run_iocbs should have been called only for buffered i/o, so this sounds like an O_DIRECT fallback to buffered i/o. Possibly after already submitting some blocks direct to BIO, the i/o completion path for which ends up calling aio_complete releasing the iocb. That could explain the use-after-free situation you see.

But, O_DIRECT write should fallback to buffered i/o only if it encounters holes in the middle of the file, not for simple appends as in your case. Need to figure out how this could have happened ...

Could you try placing a few printks to find out if this is the case or if we need to look elsewhere ?

Regards
Suparna

Quoted 29 lines

Unable to handle kernel paging request at virtual address 6b6b6b6b
 printing eip:
c018fa34
*pde = 00000000
Oops: 0000 [#1]
SMP
CPU:    1
EIP:    0060:[<c018fa34>]    Not tainted VLI
EFLAGS: 00010002

EIP is at __aio_run_iocbs+0x19/0xa2
eax: 00000000 ebx: d443b318 ecx: d4055c78 edx: 6b6b6b6b
esi: d4055c78 edi: d4055cb0 ebp: dfd6df48 esp: dfd6df34
ds: 007b es: 007b ss: 0068
Process aio/1 (pid: 16, threadinfo=dfd6c000 task=dfd71340)

Stack: 00010000 dfd71914 d4055c78 d4055c9c dfd72790 dfd6df68 c018faf6 d4055c78
       dfd6df54 dfd6df54 dfd6c000 d4055cfc 00000287 dfd6dfec c0138ad8 d4055c78
       dfd6dfa0 00000000 5a5a5a5a dfd727b8 dfd727a8 d4055c78 c018fabd dfd727a0

Call Trace:
 [<c018faf6>] aio_kick_handler+0x39/0x96
 [<c0138ad8>] worker_thread+0x1e6/0x346
 [<c018fabd>] aio_kick_handler+0x0/0x96
 [<c0122041>] default_wake_function+0x0/0x2e

Daniel

Signature · 3 lines
Suparna Bhattacharya ([email protected])
Linux Technology Center
IBM Software Labs, India
#4 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

Quoted 19 lines · Suparna Bhattacharya
Quoted 7 lines · Daniel McNeil

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

What are the i/o sizes and block sizes for which you get the oops ? Is this only for large i/o sizes ?

__aio_run_iocbs should have been called only for buffered i/o, so this sounds like an O_DIRECT fallback to buffered i/o. Possibly after already submitting some blocks direct to BIO, the i/o completion path for which ends up calling aio_complete releasing the iocb. That could explain the use-after-free situation you see.

Quoted 3 lines

But, O_DIRECT write should fallback to buffered i/o only if it encounters holes in the middle of the file, not for simple appends as in your case. Need to figure out how this could have happened ...

Took a quick look at aiocp.c - wondering if its possible that some of the later read requests complete earlier and trigger a write to higher offset first. Resulting in the file being extended with holes in between - holes which get overwritten at a later point as the earlier read requests complete.

Though I don't yet see how a situation could arise in the single threaded case where part of the request gets submitted direct to BIO and the rest falls back to buffered-io ... Need to think about it a bit more.
Are your writes all block aligned ?

Regards
Suparna

Signature · 3 lines
Suparna Bhattacharya ([email protected])
Linux Technology Center
IBM Software Labs, India
#6 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

In reply to Suparna Bhattacharya
Quoted 11 lines · Suparna Bhattacharya
Quoted 7 lines · Daniel McNeil

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

What are the i/o sizes and block sizes for which you get the oops ? Is this only for large i/o sizes ?

I've done more testing and it is a little confusing. I originally got the oops running a shell script which copied 4 88MB files one at a time to a sub-directory:

for i in fff ff1 ff2 ff3
do
aiocp -b 128k -n 8 -f CREAT -f DIRECT $i junkdir/$i
done
sync

This script would always cause the oops and the machine would lock up.

I ran aiocp manually using different block sizes (4k-128k) to copy 1 file to a subdirectory. I removed the file in the subdirectory afterward. These tests completed without any problems or oopses.

Quoted 6 lines

__aio_run_iocbs should have been called only for buffered i/o, so this sounds like an O_DIRECT fallback to buffered i/o. Possibly after already submitting some blocks direct to BIO, the i/o completion path for which ends up calling aio_complete releasing the iocb. That could explain the use-after-free situation you see.

mm4 has my extra iocb ref count for retries patch. So the iocb should not be being freed by aio_complete. The stack trace looks like the fault is on the ctx or ctx->runlist.

Quoted 7 lines

But, O_DIRECT write should fallback to buffered i/o only if it encounters holes in the middle of the file, not for simple appends as in your case. Need to figure out how this could have happened ...

Could you try placing a few printks to find out if this is the case or if we need to look elsewhere ?

I'll do more debugging and let you know what I find.

Daniel

#5 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

In reply to Suparna Bhattacharya
Quoted 24 lines · Suparna Bhattacharya
Quoted 19 lines · Suparna Bhattacharya
Quoted 7 lines · Daniel McNeil

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

What are the i/o sizes and block sizes for which you get the oops ? Is this only for large i/o sizes ?

__aio_run_iocbs should have been called only for buffered i/o, so this sounds like an O_DIRECT fallback to buffered i/o. Possibly after already submitting some blocks direct to BIO, the i/o completion path for which ends up calling aio_complete releasing the iocb. That could explain the use-after-free situation you see.

Quoted 3 lines

But, O_DIRECT write should fallback to buffered i/o only if it encounters holes in the middle of the file, not for simple appends as in your case. Need to figure out how this could have happened ...

Quoted 5 lines

Took a quick look at aiocp.c - wondering if its possible that some of the later read requests complete earlier and trigger a write to higher offset first. Resulting in the file being extended with holes in between - holes which get overwritten at a later point as the earlier read requests complete.

That is an interesting idea. I can change my aiocp program to do a printf if it hits this situation.

Quoted 6 lines

Though I don't yet see how a situation could arise in the single threaded case where part of the request gets submitted direct to BIO and the rest falls back to buffered-io ... Need to think about it a bit more.
Are your writes all block aligned ?

All i/o is aligned to the size of the block size (128k in this test).

Daniel

#10 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

In reply to Suparna Bhattacharya

In article <[email protected]>,
Suparna Bhattacharya <[email protected]> wrote:

| On Wed, Oct 08, 2003 at 04:18:15PM -0700, Daniel McNeil wrote:
| 
| __aio_run_iocbs should have been called only for buffered i/o, 
| so this sounds like an O_DIRECT fallback to buffered i/o.
| Possibly after already submitting some blocks direct to BIO,
| the i/o completion path for which ends up calling aio_complete
| releasing the iocb. That could explain the use-after-free situation
| you see.
| 
| But, O_DIRECT write should fallback to buffered i/o only if it 
| encounters holes in the middle of the file, not for simple appends 
| as in your case. Need to figure out how this could have happened ...

Are the write kept ordered?

Signature · 3 lines
bill davidsen <[email protected]>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
#7 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

In reply to Daniel McNeil
Quoted 37 lines · Daniel McNeil
Quoted 11 lines · Suparna Bhattacharya
Quoted 7 lines · Daniel McNeil

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

What are the i/o sizes and block sizes for which you get the oops ? Is this only for large i/o sizes ?

I've done more testing and it is a little confusing. I originally got the oops running a shell script which copied 4 88MB files one at a time to a sub-directory:

for i in fff ff1 ff2 ff3
do
aiocp -b 128k -n 8 -f CREAT -f DIRECT $i junkdir/$i
done
sync

This script would always cause the oops and the machine would lock up.

I ran aiocp manually using different block sizes (4k-128k) to copy 1 file to a subdirectory. I removed the file in the subdirectory afterward. These tests completed without any problems or oopses.

Quoted 6 lines

__aio_run_iocbs should have been called only for buffered i/o, so this sounds like an O_DIRECT fallback to buffered i/o. Possibly after already submitting some blocks direct to BIO, the i/o completion path for which ends up calling aio_complete releasing the iocb. That could explain the use-after-free situation you see.

Quoted 3 lines

mm4 has my extra iocb ref count for retries patch. So the iocb should not be being freed by aio_complete. The stack trace looks like the fault is on the ctx or ctx->runlist.

The race I was suspecting is a different one - a case where the dio code calls aio_complete before a fallback to buffered i/o, and the latter queues up a retry. By the time the retry gets to run the reference to the iocb would have gone. (your extra iocb ref count patch wouldn't be able to guard against this - the correct solution would be to avoid doing aio_complete if we run into -ENOTBLK i.e. when we intend to fallback to buffered i/o).

But, if you are sure that its not the iocb but the ctx thats got freed, I don't yet see why that would happen (since the workqueue should have been flushed before terminating the ioctx at exit).

Regards
Suparna

Quoted 13 lines
Quoted 8 lines

But, O_DIRECT write should fallback to buffered i/o only if it encounters holes in the middle of the file, not for simple appends as in your case. Need to figure out how this could have happened ...

Could you try placing a few printks to find out if this is the case or if we need to look elsewhere ?

I'll do more debugging and let you know what I find.

Daniel

Signature · 3 lines
Suparna Bhattacharya ([email protected])
Linux Technology Center
IBM Software Labs, India
#8 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

Quoted 42 lines · Suparna Bhattacharya
Quoted 37 lines · Daniel McNeil
Quoted 11 lines · Suparna Bhattacharya
Quoted 7 lines · Daniel McNeil

I'm been testing AIO on test6-mm4 using a ext3 file system and copying a 88MB file to an already existing preallocated file of 88MB. I been using my aiocp program to copy the file using i/o sizes of 1k to 512k and outstanding aio requests of between 1 and 64 using O_DIRECT, O_SYNC and O_DIRECT & O_SYNC. Everything works as long as the file is pre-allocated. When copying the file to a new file (O_CREAT|O_DIRECT), I get the following oops:

What are the i/o sizes and block sizes for which you get the oops ? Is this only for large i/o sizes ?

I've done more testing and it is a little confusing. I originally got the oops running a shell script which copied 4 88MB files one at a time to a sub-directory:

for i in fff ff1 ff2 ff3
do
aiocp -b 128k -n 8 -f CREAT -f DIRECT $i junkdir/$i
done
sync

This script would always cause the oops and the machine would lock up.

I ran aiocp manually using different block sizes (4k-128k) to copy 1 file to a subdirectory. I removed the file in the subdirectory afterward. These tests completed without any problems or oopses.

Quoted 6 lines

__aio_run_iocbs should have been called only for buffered i/o, so this sounds like an O_DIRECT fallback to buffered i/o. Possibly after already submitting some blocks direct to BIO, the i/o completion path for which ends up calling aio_complete releasing the iocb. That could explain the use-after-free situation you see.

Quoted 3 lines

mm4 has my extra iocb ref count for retries patch. So the iocb should not be being freed by aio_complete. The stack trace looks like the fault is on the ctx or ctx->runlist.

Quoted 8 lines

The race I was suspecting is a different one - a case where the dio code calls aio_complete before a fallback to buffered i/o, and the latter queues up a retry. By the time the retry gets to run the reference to the iocb would have gone. (your extra iocb ref count patch wouldn't be able to guard against this - the correct solution would be to avoid doing aio_complete if we run into -ENOTBLK i.e. when we intend to fallback to buffered i/o).

Could you try applying the following hack and see if it makes a difference ?

I was able to recreate an oops running aiocp with the same arguments that you mentioned on 2.6.0-test6-mm4; and that didn't seem to occur when I applied this patch.

Note: This is not a complete fix though and probably room for doing this in a cleaner way. If what I suspect is going on, we'll need more work to get there - like thinking through the case where a request spans an allocated region followed by a hole.

Regards
Suparna

Signature · 39 lines
Suparna Bhattacharya ([email protected])
Linux Technology Center
IBM Software Labs, India

----------------------------------------------

AIO-DIO fix: Don't call aio_complete if we are falling back to buffered i/o

diff -urp puremm/fs/direct-io.c linux-2.6.0-test6-mm4/fs/direct-io.c
--- puremm/fs/direct-io.c	2003-10-10 14:26:53.000000000 +0530
+++ linux-2.6.0-test6-mm4/fs/direct-io.c	2003-10-10 14:26:26.000000000 +0530
@@ -208,7 +208,7 @@ static struct page *dio_get_page(struct 
  */
 static void dio_complete(struct dio *dio, loff_t offset, ssize_t bytes)
 {
-	if (dio->end_io)
+	if (dio->end_io && dio->result != -ENOTBLK)
 		dio->end_io(dio->inode, offset, bytes, dio->map_bh.b_private);
 	if (dio->needs_locking)
 		up_read(&dio->inode->i_alloc_sem);
@@ -224,7 +224,8 @@ static void finished_one_bio(struct dio 
 		if (dio->is_async) {
 			dio_complete(dio, dio->block_in_file << dio->blkbits,
 					dio->result);
-			aio_complete(dio->iocb, dio->result, 0);
+			if (dio->result != -ENOTBLK)
+				aio_complete(dio->iocb, dio->result, 0);
 			kfree(dio);
 		}
 	}
@@ -978,6 +979,8 @@ direct_io_worker(int rw, struct kiocb *i
 	 * OK, all BIOs are submitted, so we can decrement bio_count to truly
 	 * reflect the number of to-be-processed BIOs.
 	 */
+	if (ret == -ENOTBLK)
+		dio->result = ret;
 	if (dio->is_async) {
 		if (ret == 0)
 			ret = dio->result;	/* Bytes written */
#9 lore raw

Re: 2.6.0-test6-mm4 - oops in __aio_run_iocbs()

Quoted 7 lines · Suparna Bhattacharya

Could you try applying the following hack and see if it makes a difference ?

I was able to recreate an oops running aiocp with the same arguments that you mentioned on 2.6.0-test6-mm4; and that didn't seem to occur when I applied this patch.

Quoted 7 lines

Note: This is not a complete fix though and probably room for doing this in a cleaner way. If what I suspect is going on, we'll need more work to get there - like thinking through the case where a request spans an allocated region followed by a hole.

Regards
Suparna

good news, I tried the patch and the oops no longer occurs.

I also added code to aiocp to check if the AIO reads are completing out of order, which would cause the AIO writes to out of order. The reads are completing in order. However, I added code to check if the AIO writes are completing out of order, and, if fact, they do. Not very often, but I got 8 i/o where an i/o farther in file completes before an earlier i/o.

Daniel