gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gluster-devel] Why to fork so many times?


From: Pavan T C
Subject: Re: [Gluster-devel] Why to fork so many times?
Date: Tue, 7 Jun 2011 12:29:07 +0530
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10

On Tuesday 07 June 2011 10:54 AM, Daniel wrote:
Hello hackers:

I am learning glusterfs and get one question when I reading
contrib/fuse-lib/mount.c fuse_mnt_add_mount(). Why does it fork four
times and the grand-grand-child exec("/bin/mount")? What is the benefit
and the consideration?

As I see it, it forks thrice. Here is what I understand from the code:

+---------------------+
| fuse_mnt_add_mount()|<------------------------------+
| fork and wait for   |                               |
| child to return     |                               |
+-----+---------------+                               |
      |                                               |
      |                                               |
      X                                               |
     / \                                              |
    /if \                                             |
   /sync-\    NO    +---------------------------+     |
  X mtab  X-------->| Do async ops by returning |     |
   \ == 1/   fork() | from here so that parent  |     |
    \   /           | does not wait. But before |     |
     \ /            | doing that, create a dummy|     |
      X             | parent to wait for child  |     |
      | YES         | that does the /bin/mount  |     |
      |             +------------+--------------+     |
      | fork()                   |                    |
      V                          |                    |
+-----+----------+               | fork() -> Parent returns here.
| Child: execl   |               v
| /bin/mount with|         +---------------+
| -f option to   |         |dummy parent:  |
| only populate  |  fork() | fork and wait |
| mtab but don't |<--------+ for /bin/mount|
| actually mount |         | to return     |
| anything.      |         +---------------+
+----------------+

HTH,
Pavan


Thank you

Daniel


_______________________________________________
Gluster-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/gluster-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]