Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRemove btrfs quota groups after containers destroyed #29427
Conversation
421140b
to
57c74de
|
Sorry for late reply. LGTM. |
57c74de
to
44dee9c
|
Previously the PR didn't take into consideration that, if Now the PR has been updated to add the check for |
|
Also wondering the same here as on #29835 (comment) |
|
I had a quick look at the code, it looks like @thaJeztah may be correct. Would wait on @cpuguy83 for confirmation |
|
if I'm correct, we may need some mechanism to detect if a quota is set (perhaps querying btrfs), otherwise it's possible we don't know when to cleanup / manage quotas |
|
I think you are right. On daemon restore it could really be a problem. |
|
@cpuguy83 @tonistiigi @yongtang so, what we're going to do with this and #29385 |
44dee9c
to
ba10de8
|
Here is the complete steps to verify that the issue is fixed (Including --live-restore case). Would be good to setup integration test for btrfs in Jenkins Note: this PR has been updated to incorporate #30497. If this one is merged then #30497 could be closed pre-fix behavior with qgroup leftover:
PR with qgroup cleaned (non --live-restore case):
PR with qgroup cleaned (--live-restore case):
|
| @@ -320,7 +337,7 @@ func (d *Driver) subvolEnableQuota() error { | |||
| func (d *Driver) subvolDisableQuota() error { | |||
| if !d.quotaEnabled { | |||
This comment has been minimized.
This comment has been minimized.
mlaventure
Feb 10, 2017
Contributor
Shouldn't this be turned into a isQuotaEnabled() routine to avoid this code to be duplicated?
Also, quotaEnabled is just a boolean, but don't we need a lock around it?
|
ping @cpuguy83 @tonistiigi |
d7f3c09
to
4d312d6
|
Thanks @mlaventure for the review. The PR has been updated with |
| } | ||
|
|
||
| func (d *Driver) subvolEnableQuota() error { | ||
| d.mu.Lock() |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
yongtang
Feb 13, 2017
Author
Member
Thanks @mlaventure.
Inside the subvolEnableQuota the d.quotaEnabled will be changed again to true at the end of subvolEnableQuota (located in Line 343). For that I placed the Lock() outside of isQuotaEnabled().
This comment has been minimized.
This comment has been minimized.
|
ping @cpuguy83 @tonistiigi this is waiting for reviews |
|
ping @cpuguy83 @tonistiigi PTAL |
|
This is not re-applying qutoas on daemon restart.
|
|
It looks like we need to rescan for quota in |
|
Or I guess write out a file to trigger an auto-enable of the quota on restart. |
|
ping @yongtang |
|
ping @yongtang do you still have time to work on this? |
|
@thaJeztah Sorry for the late response. Let me spend the next several days to get this one fixed. |
8106d15
to
9792f99
|
@cpuguy83 The PR has been updated. Now the quota is saved in |
|
Alternatively, you can just wait for this patchset to land: http://www.spinics.net/lists/linux-btrfs/msg65928.html |
|
@sargun nice! Unfortunately we don't control the host, so cannot guarantee that patch is present on each distro / version, so not sure we can rely on that |
| if quota, err := ioutil.ReadFile(d.quotasDirID(id)); err == nil { | ||
| if size, err := strconv.ParseUint(string(quota), 10, 64); err == nil && size >= d.options.minSpace { | ||
| d.subvolEnableQuota() | ||
| subvolLimitQgroup(dir, size) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -557,6 +635,13 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { | |||
| return "", fmt.Errorf("%s: not a directory", dir) | |||
| } | |||
|
|
|||
| if quota, err := ioutil.ReadFile(d.quotasDirID(id)); err == nil { | |||
| if size, err := strconv.ParseUint(string(quota), 10, 64); err == nil && size >= d.options.minSpace { | |||
| d.subvolEnableQuota() | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -533,7 +606,12 @@ func (d *Driver) Remove(id string) error { | |||
| if _, err := os.Stat(dir); err != nil { | |||
| return err | |||
| } | |||
| if err := subvolDelete(d.subvolumesDir(), id); err != nil { | |||
| os.Remove(d.quotasDirID(id)) | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| if err := idtools.MkdirAllAs(quotas, 0700, rootUID, rootGID); err != nil { | ||
| return err | ||
| } | ||
| if err := ioutil.WriteFile(path.Join(quotas, id), []byte(fmt.Sprint(driver.options.size)), 0666); err != nil { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This fix tries to address the issue raised in 29325 where btrfs quota groups are not clean up even after containers have been destroyed. The reason for the issue is that btrfs quota groups have to be explicitly destroyed. This fix fixes this issue. This fix is tested manually in Ubuntu 16.04, with steps specified in 29325. This fix fixes 29325. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is an extension of fix for 29325 based on the review comment. In this commit, the quota size for btrfs is kept in `/var/lib/docker/btrfs/quotas` so that a daemon restart keeps quota. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
9792f99
to
16328cc
|
Thanks @cpuguy83 for the review. The PR has been updated. Please take a look. |
|
LGTM |
|
All tests passed now, merging... |
54dacaf
into
moby:master
yongtang commentedDec 14, 2016
•
edited
- What I did
This fix tries to address the issue raised in #29325 where btrfs quota groups are not clean up even after containers have been destroyed.
- How I did it
The reason for the issue is that btrfs quota groups have to be explicitly destroyed. This fix fixes this issue.
- How to verify it
This fix is tested manually in Ubuntu 16.04:
pre-fix behavior with qgroup leftover:
PR with qgroup cleaned (non --live-restore case):
PR with qgroup cleaned (--live-restore case):
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
This fix fixes #29325.
Signed-off-by: Yong Tang yong.tang.github@outlook.com