Skip to content

Avoid extra mount/unmount during container registration - #4067

Merged
crosbymichael merged 1 commit into
moby:masterfrom
alexlarsson:fix-devmapper-race
Feb 11, 2014
Merged

crosbymichael merged 1 commit into
moby:masterfrom
alexlarsson:fix-devmapper-race

Conversation

@alexlarsson

Copy link
Copy Markdown
Contributor

Runtime.Register() called driver.Get()/Put() in order to read back the
basefs of the container. However, this is not needed, as the basefs
is read during container.Mount() anyway, and basefs is only valid
while mounted (and all current calls satisfy this).

This seems minor, but this is actually problematic, as the Get/Put
pair will create a spurious mount/unmount cycle that is not needed and
slows things down. Additionally it will create a supurious
devicemapper activate/deactivate cycle that causes races with udev as
seen in #4036.

With this change devicemapper is now race-free, and container startup
is slightly faster.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson [email protected] (github: alexlarsson)

Runtime.Register() called driver.Get()/Put() in order to read back the
basefs of the container. However, this is not needed, as the basefs
is read during container.Mount() anyway, and basefs is only valid
while mounted (and all current calls satisfy this).

This seems minor, but this is actually problematic, as the Get/Put
pair will create a spurious mount/unmount cycle that is not needed and
slows things down. Additionally it will create a supurious
devicemapper activate/deactivate cycle that causes races with udev as
seen in moby#4036.

With this change devicemapper is now race-free, and container startup
is slightly faster.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <[email protected]> (github: alexlarsson)
@unclejack

Copy link
Copy Markdown
Contributor

LGTM

ping @creack @crosbymichael @vieux

@crosbymichael

Copy link
Copy Markdown
Contributor

@alexlarsson

I thought the point of reference counting and the driver Get method is that we can call it as many times as we want and there are no side effects if it is already mounted. Shouldn't the fix happen in the device mapper driver ?

@alexlarsson

Copy link
Copy Markdown
Contributor Author

@crosbymichael You can, but at this point there are no other gets, so a get() will mount, and a put() will then unmount. Then a bit later there will be a new get() that mounts it for real use in the started container.

@crosbymichael

Copy link
Copy Markdown
Contributor

LGTM

crosbymichael added a commit that referenced this pull request Feb 11, 2014
Avoid extra mount/unmount during container registration
@crosbymichael
crosbymichael merged commit da3e539 into moby:master Feb 11, 2014
@unclejack unclejack added this to the 0.8.1 milestone Feb 14, 2014
@alexlarsson
alexlarsson deleted the fix-devmapper-race branch March 28, 2014 09:13
@wzymaster

Copy link
Copy Markdown

I encountered this problem in Docker 1.9 as well !

@dmjio

dmjio commented Dec 11, 2015

Copy link
Copy Markdown

+1 still an issue

2 similar comments
@joepreludian

Copy link
Copy Markdown

+1 still an issue

@ghost

ghost commented Feb 27, 2016

Copy link
Copy Markdown

+1 still an issue

@bitliner

bitliner commented Mar 7, 2016

Copy link
Copy Markdown

+1

2 similar comments
@zyrex008

Copy link
Copy Markdown

+1

@alexploit

Copy link
Copy Markdown

+1

@thaJeztah

Copy link
Copy Markdown
Member

To those adding +1's, please open a new issue describing the exact issue, and ways to reproduce. Commenting on a closed pull request that's over two years old, and containing code changes in parts of docker that are not even in the current code base anymore, isn't helpful, and likely won't help resolving your issue.

I'll lock this conversation

@moby moby locked and limited conversation to collaborators May 11, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.