For btrfs driver, in d.Create(), Get() of parentDir is called but not followed
by Put().
If we apply SElinux mount label, we need to mount btrfs subvolumes in d.Get(),
without a Put() would end up with a later Remove() failure on
"Device resourse is busy".
This calls the subvolume helper function directly in d.Create().
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
| ... | ... |
@@ -256,10 +256,14 @@ func (d *Driver) Create(id, parent, mountLabel string) error {
|
| 256 | 256 |
return err |
| 257 | 257 |
} |
| 258 | 258 |
} else {
|
| 259 |
- parentDir, err := d.Get(parent, "") |
|
| 259 |
+ parentDir := d.subvolumesDirID(parent) |
|
| 260 |
+ st, err := os.Stat(parentDir) |
|
| 260 | 261 |
if err != nil {
|
| 261 | 262 |
return err |
| 262 | 263 |
} |
| 264 |
+ if !st.IsDir() {
|
|
| 265 |
+ return fmt.Errorf("%s: not a direcotory", parentDir)
|
|
| 266 |
+ } |
|
| 263 | 267 |
if err := subvolSnapshot(parentDir, subvolumes, id); err != nil {
|
| 264 | 268 |
return err |
| 265 | 269 |
} |