Skip to content

Run btrfs rescan only if userDiskQuota is enabled#29835

Merged
cpuguy83 merged 1 commit into
moby:masterfrom
yongtang:29810-btrfs-rescan
Jan 26, 2017
Merged

Run btrfs rescan only if userDiskQuota is enabled#29835
cpuguy83 merged 1 commit into
moby:masterfrom
yongtang:29810-btrfs-rescan

Conversation

@yongtang

@yongtang yongtang commented Jan 3, 2017

Copy link
Copy Markdown
Member

This fix tries to address the issue raised in #29810 where btrfs subvolume removal failed when docker
is in an unprivileged lxc container. The failure was caused by Failed to rescan btrfs quota with operation not permitted.

However, if disk quota is not enabled, there is no need to run a btrfs rescan at the first place.

This fix checks for quotaEnabled and only run btrfs rescan if quotaEnabled is true.

This fix fixes #29810.

Signed-off-by: Yong Tang [email protected]

/cc @zhuguihua

@Keno

Keno commented Jan 3, 2017

Copy link
Copy Markdown

👍 I did the same patch locally earlier today and works for me.

@zhuguihua

Copy link
Copy Markdown
Contributor

Thanks for your fix. Good to me.

Comment thread daemon/graphdriver/btrfs/btrfs.go Outdated

@thaJeztah thaJeztah Jan 3, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was looking at the code, and a bit in doubt. The quotaEnabled boolean
is set either if --storage-opt size=btrfs.min_space is set globally (on the daemon), or if a size is passed when creating a container (see set storage driver options per container)

I'm not too familiar with this part of the code; is the Create() method also called when starting an existing container, or only the first time its filesystem is created?

Otherwise, this may not work, because the quotaEnabled variable is only set here; https://github.com/docker/docker/blob/v1.12.5/daemon/graphdriver/btrfs/btrfs.go#L461-L466 (in situations where btrfs.min_space is not set on the daemon)

So, maybe this is the right change, but I'm just writing down my thoughts, in case it's useful.

ping @cpuguy83 you probably know

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Create is not called on container startup. Cleanup has a similar check.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, this will be a problem on restore, for sure.
We need a better way to determine if quota is enabled.

This fix tries to address the issue raised in 29810
where btrfs subvolume removal failed when docker
is in an unprivileged lxc container. The failure
was caused by `Failed to rescan btrfs quota` with
`operation not permitted`.

However, if disk quota is not enabled, there is no
need to run a btrfs rescan at the first place.

This fix checks for `quotaEnabled` and only run btrfs
rescan if `quotaEnabled` is true.

This fix fixes 29810.

Signed-off-by: Yong Tang <[email protected]>
@yongtang
yongtang force-pushed the 29810-btrfs-rescan branch from 5c0b0d8 to b36e613 Compare January 5, 2017 13:18
@yongtang

yongtang commented Jan 5, 2017

Copy link
Copy Markdown
Member Author

To check if quota is enabled, I think one way is to look up the qgroup and see if it returns something. In case quota is not enabled then error will be returned.

I updated the PR so that now if quotaEnabled is false, then a qgroup lookup will be performed to validate if quota is truly enabled or not.

/cc @thaJeztah @cpuguy83 @tonistiigi @mlaventure @zhuguihua

quotaEnabled = false
userDiskQuota = false
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Think the two global variables could be avoided. the quotaEnabled could be wrapped into driver *, and userDiskQuota is only a temporary variable.


// Cleanup unmounts the home directory.
func (d *Driver) Cleanup() error {
if quotaEnabled {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Move quotaEnabled inside the d *Driver to hide the logic of quotaEnabled checking.

// In case quotaEnabled is not set, check qgroup and update quotaEnabled as needed
if _, err := subvolLookupQgroup(d.home); err == nil {
d.quotaEnabled = true
return nil

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Perform a qgroup lookup and sync quotaEnabled as needed.

@LK4D4

LK4D4 commented Jan 26, 2017

Copy link
Copy Markdown
Contributor

ping @cpuguy83 @tonistiigi

@tonistiigi

Copy link
Copy Markdown
Member

LGTM

@cpuguy83 cpuguy83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@cpuguy83
cpuguy83 merged commit 93e322f into moby:master Jan 26, 2017
@GordonTheTurtle GordonTheTurtle added this to the 1.14.0 milestone Jan 26, 2017
@yongtang
yongtang deleted the 29810-btrfs-rescan branch January 27, 2017 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run btrfs rescan only, if userDiskQuota is enabled

9 participants