Skip to contentSkip to conversation

mmap on PPC removes file refcount?

DISCUSSION Dave Jiang 2 participants 3 messages Nov 20, 2007 – Nov 26, 2007

lore
Share & tools
lore

Dave Jiang

author
#0 lore raw

It seems the mmap() userland call on PPC causes the kernel to lose the ref count for the mount point. This is what I did on a prpmc2800 board (74xx) with latest powerpc.git tree (but also seem to happen on 8548 as well).

I mounted an IDE partition. The userland test app opens a file on the mounted partition and sits in a sleep loop while holding the file open. I call umount on the partition and I get "device is busy" which is suppose to happen. However, after the test app calls mmap on the file id for the opened file, I can successfully umount even though it should still say "device is busy". This does not happen on x86 so I'm assuming something is going on with just PPC.

So using lsof I can list the opened files on a particular partition. When the file is opened, it lists 1 entry. When mmaped, on x86 it would list 2 entries, but on ppc it lists nothing. Not only did the mmaped entry not show up, the entry caused by open disappeared as well. Also, I put a printk in do_umount() to see what the refcount is. On x86, it would be 3 and thus causes device busy. On PPC it is 3 when the file is openend, however if mmap is called, the refcount becomes 2 and thus umount proceeds. It's almost as if the mmap call wiped out the opened file entry and decremented the mount count as well.

Signature · 6 lines
------------------------------------------------------
Dave Jiang
Software Engineer
MontaVista Software, Inc.
http://www.mvista.com
------------------------------------------------------
author
#1 lore raw

NM, it was a bad test causing weird behavior on PPC. :(

Quoted 21 lines · Dave Jiang

It seems the mmap() userland call on PPC causes the kernel to lose the ref count for the mount point. This is what I did on a prpmc2800 board (74xx) with latest powerpc.git tree (but also seem to happen on 8548 as well).

I mounted an IDE partition. The userland test app opens a file on the mounted partition and sits in a sleep loop while holding the file open. I call umount on the partition and I get "device is busy" which is suppose to happen. However, after the test app calls mmap on the file id for the opened file, I can successfully umount even though it should still say "device is busy". This does not happen on x86 so I'm assuming something is going on with just PPC.

So using lsof I can list the opened files on a particular partition. When the file is opened, it lists 1 entry. When mmaped, on x86 it would list 2 entries, but on ppc it lists nothing. Not only did the mmaped entry not show up, the entry caused by open disappeared as well. Also, I put a printk in do_umount() to see what the refcount is. On x86, it would be 3 and thus causes device busy. On PPC it is 3 when the file is openend, however if mmap is called, the refcount becomes 2 and thus umount proceeds. It's almost as if the mmap call wiped out the opened file entry and decremented the mount count as well.

Signature · 6 lines
------------------------------------------------------
Dave Jiang
Software Engineer
MontaVista Software, Inc.
http://www.mvista.com
------------------------------------------------------
#2 lore raw
Quoted 1 line · Dave Jiang

NM, it was a bad test causing weird behavior on PPC. :(

Ah good, because I did spend some time looking at the code and didn't see anything wrong :-)

Cheers,
Ben.