Re: [uml-devel] hostfs oddities

2008-07-08 Thread Jeff Dike
On Sat, Jul 05, 2008 at 08:46:31PM +0200, Ingo van Lil wrote:
> 1. If a file is held read-only by one process it cannot by creat()'ed by 
> another one:
> 
>[EMAIL PROTECTED] ~]# mount -t hostfs none /mnt
>[EMAIL PROTECTED] ~]# cd /mnt/tmp
>[EMAIL PROTECTED] tmp]# touch foo
>[EMAIL PROTECTED] tmp]# tail -f foo &
>[1] 895
>[EMAIL PROTECTED] tmp]# > foo
>-bash: foo: Invalid argument
>[EMAIL PROTECTED] tmp]# kill 895
>[1]+  Terminated  tail -f foo
>[EMAIL PROTECTED] tmp]# > foo
> 
> I tracked that problem down to the set_attr() function in hostfs_user.c: 
> It tries to ftruncate() the read-only file descriptor. The file should 
> be re-opened writable before changing its length.

Looks like a good diagnosis.  There is code in host_file_open which is
supposed to handle this case, but it's not being hit when the shell
opens the file, which I don't understand.

> 2. As long as a file is held open changes made outside the UML kernel 
> (i.e. on the host side) may not be visible:
> 
>[EMAIL PROTECTED] tmp]# tail -f foo &
>[1] 897
># Host system: echo "Hello World" > /tmp/foo
>[EMAIL PROTECTED] tmp]# cat foo
>[EMAIL PROTECTED] tmp]# kill 897
>[1]+  Terminated  tail -f foo
>[EMAIL PROTECTED] tmp]# cat foo
>Hello World
> 
> I guess this is some kind of caching effect, because strace shows that 
> there is only a single read to the actual physical file. Maybe hostfs 
> should check whether the outside file has changed and invalidate the 
> cache if necessary.

Correct.  I've pondered using [id]notify to track changes on the host
and either invalidate the UML cache or update it.  Both involve
interactions with the page cache that I'm not entirely comfortable
with right now.

Jeff

-- 
Work email - jdike at linux dot intel dot com

-
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] hostfs oddities

2008-07-08 Thread Ingo van Lil
Jeff Dike wrote:

>> 1. If a file is held read-only by one process it cannot by creat()'ed by 
>> another one:
>>
[...]
>>
>> I tracked that problem down to the set_attr() function in hostfs_user.c: 
>> It tries to ftruncate() the read-only file descriptor. The file should 
>> be re-opened writable before changing its length.
> 
> Looks like a good diagnosis.  There is code in host_file_open which is
> supposed to handle this case, but it's not being hit when the shell
> opens the file, which I don't understand.

I tracked that down step-by-step on Saturday: If the O_TRUNC flag is set 
in the open() syscall the file will first be truncated and then opened.

The call stack for truncating the file:

  - sys_open (fs/open.c)
  - do_sys_open (fs/open.c)
  - do_filp_open (fs/open.c)
  - open_namei (fs/namei.c)
  - may_open (fs/namei.c)
  - do_truncate (fs/open.c)

And the call stack for actually opening the file:

  - sys_open (fs/open.c)
  - do_sys_open (fs/open.c)
  - do_filp_open (fs/open.c)
  - nameidata_to_filp (fs/open.c)
  - __dentry_open (fs/open.c)

Maybe that helps.


> Correct.  I've pondered using [id]notify to track changes on the host
> and either invalidate the UML cache or update it.  Both involve
> interactions with the page cache that I'm not entirely comfortable
> with right now.

That problem is actually more severe for my UML use case: I'm developing 
firmware for an embedded device, and I'm using UML because it's quicker 
and more convenient than developing on the target hardware. Now, if I 
re-compile some library which is still in use by another process the 
changes will not be visible until I reboot (or kill these background 
processes).
How do similar filesystems (e.g. NFS) solve that problem?

Cheers,
Ingo


-
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


[uml-devel] Question about Host PCI and DMA support in UML

2008-07-08 Thread lianwei Wang
Hello Jeff Dike,

I find from the UML website that the UML can access the host PCI device
accessing with VPCI patch, but it seem that that VPCI patch is too old. Do
you know that latest information about the VPCI patch? Is it stable? And
where could I find the patch?

>From the below mail you say that you are trying to emulate the DMA using
iomem. How about the latest information of it?  And does it worked or not?


*Re: [uml-user] PCI & DMA
From: P. Thambi <[EMAIL PROTECTED]> - 2003-10-06 23:02
--- Jeff Dike <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] said:
> > Is there any other ways to emulate the PCI & DMA
> in uml other than
> > using iomems?
>
> There's Jon Smirl's VPCI patch for PCI. I don't
> know what you can do for
> DMA since any addresses that UML knows about will be
> virtual ones, and DMA
> has to be to physical addresses.

I looked at VPCI but it for actual PCI device access
in the x86 I believe. Yes DMA access needs using
physical address. But I am trying to emulate the DMA
using iomem. so I that I can some how map(emulate) the
register access/virtual->physical address in iomem
memory. I know to emulate the entire PPC processor is
a big task. But I dont have any other option because
hardware is little behind.

Thanks,
Lianwei
*
-
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel