Skip to content

Refcount driver mounts #3073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2014
Merged

Conversation

alexlarsson
Copy link
Contributor

This adds a Put() operation to the driver API which pairs with the Get() call.
All callers of Get() are changed to have a corresponding Put() which lets us balance the uses of a particular ID.
We then use this in the devicemapper driver to avoid leaving mounts around.

For instance, we almost never need any images of init layers mounted, only when e.g. diffing or calculating sizes. We also don't want to leave stray mounts for every container that was ever run (we currently even mount old ones on daemon start!).

@creack
Copy link
Contributor

creack commented Dec 5, 2013

/cc @shykes @crosbymichael @vieux

@@ -85,6 +85,9 @@ func (d *Driver) Get(id string) (string, error) {
return dir, nil
}

func (d *Driver) Put(id string) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment why we do not need to implement Put on vfs?

@alexlarsson
Copy link
Contributor Author

New version uses atomics and adds a comment to Vfs Put() implementation. It also removes the deprecated container.EnsureMounted()

@shykes
Copy link
Contributor

shykes commented Dec 12, 2013

This is really needed. Not sure about the Put name (maybe "Release"?) but we should review this this week if possible. /cc @crosbymichael @creack @vieux

@@ -222,6 +222,9 @@ func (a *Driver) Get(id string) (string, error) {
return out, nil
}

func (a *Driver) Put(id string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be implemented for aufs as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, i kinda left that out as I don't regularly run the aufs backend, but its no worse of than currently without this implemented :)

@alexlarsson
Copy link
Contributor Author

New version fixes the comments above, (well, still no aufs support, and its still called Put).

@creack
Copy link
Contributor

creack commented Jan 3, 2014

@alexlarsson Let me know if you need assistance in order to implement the AUFS Put() when you come back.

@alexlarsson
Copy link
Contributor Author

Updated series with signoffs. Will take a look at aufs next.

@alexlarsson
Copy link
Contributor Author

Added aufs version of Put(). Tested in vagrant and seems to work well.

@unclejack
Copy link
Contributor

@alexlarsson Can you rebase, please?

@alexlarsson
Copy link
Contributor Author

rebased on master

@unclejack
Copy link
Contributor

@alexlarsson It seems this needs a go fmt. Can you please go fmt?

@unclejack
Copy link
Contributor

@alexlarsson The integration tests are failing because c.EnsureMounted() is being called in integration/utils_test.go
the exact error is:

# github.com/dotcloud/docker/integration
./utils_test.go:74: c.EnsureMounted undefined (type *docker.Container has no field or method EnsureMounted)

This makes all users of Put() have a corresponding call
to Get() which means we will be able to track whether
any particular ID is in use and if not unmount it.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This was deprecated already and all it did was call Mount().
The use of this was a bit confusing since we need to pair Mount/Unmount
calls which wasn't obvious with "EnsureMounted".

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
This implements the new Put() operation such that
Get()/Put() maintains a refcount for each ID, mounting
only on first Get() and unmounting on the last Get().

This means we avoid littering the system with lots of mounts
and active devicemapper devices and free resources related
to them.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)

asdfljk
This implements the new Put() operation such that
Get()/Put() maintains a refcount for each ID, mounting
only on first Get() and unmounting on the last Get().

This means we avoid littering the system with lots of mounts
and free resources related to them.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
@alexlarsson
Copy link
Contributor Author

Sorry, i missed the new EnsureMounted() call, new rebased series includes that.

@unclejack
Copy link
Contributor

LGTM

ping @creack @crosbymichael

@crosbymichael
Copy link
Contributor

LGTM

1 similar comment
@creack
Copy link
Contributor

creack commented Jan 22, 2014

LGTM

creack added a commit that referenced this pull request Jan 22, 2014
@creack creack merged commit f61a91f into moby:master Jan 22, 2014
@alexlarsson alexlarsson deleted the refcount-driver-mounts branch March 28, 2014 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants