Skip to contentSkip to conversation

qga: ignore EBUSY when freezing a filesystem

PATCH In review Peter Lieven 3 participants 8 messages Jan 31, 2017 – Feb 17, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga: ignore EBUSY when freezing a filesystem

the current implementation fails if we try to freeze an already frozen filesystem. This can happen if a filesystem is mounted more than once (e.g. with a bind mount).

---
 qga/commands-posix.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
qga/commands-posix.c +4 -1
index ea37c09..73d93eb 100644
@@ -1243,6 +1243,9 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
          * filesystems may not implement fsfreeze for less obvious reasons.
          * these will report EOPNOTSUPP. we simply ignore these when tallying
          * the number of frozen filesystems.
+         * if a filesystem is mounted more than once (aka bind mount) a
+         * consecutive attempt to freeze an already frozen filesystem will
+         * return EBUSY.
          *
          * any other error means a failure to freeze a filesystem we
          * expect to be freezable, so return an error in those cases
@@ -1250,7 +1253,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,
          */
         ret = ioctl(fd, FIFREEZE);
         if (ret == -1) {
-            if (errno != EOPNOTSUPP) {
+            if (errno != EOPNOTSUPP && errno != EBUSY) {
                 error_setg_errno(errp, errno, "failed to freeze %s",
                                  mount->dirname);
                 close(fd);
Signature · 1 line
1.9.1
#2 lore raw

Hi,

to clarify: I guess you ask about what happens when you thaw with the same condition: a filesystem that is mounted multiple times.

When I created the patch initially I looked at the thaw code and found it to already expect that thaws may happen outside its control and that the error handling is fine.

The code definitely does not have an early exit upon encountering an issue with thawing/double thawing.

Christian

Quoted 9 lines · Paolo Bonzini
Quoted 4 lines · Peter Lieven

the current implementation fails if we try to freeze an already frozen filesystem. This can happen if a filesystem is mounted more than once (e.g. with a bind mount).

Quoted 7 lines
Quoted 3 lines

What happens when you thaw?

Paolo

--
Christian Theune · [email protected] · +49 345 219401 0
Flying Circus Internet Operations GmbH · http://flyingcircus.io
Forsterstraße 29 · 06112 Halle (Saale) · Deutschland
HR Stendal HRB 21169 · Geschäftsführer: Christian. Theune, Christian. Zagrodnick

#3 lore raw
In reply to Paolo Bonzini

Am 02.02.2017 um 22:41 schrieb Paolo Bonzini:

Quoted 6 lines · Peter Lieven
Quoted 4 lines

the current implementation fails if we try to freeze an already frozen filesystem. This can happen if a filesystem is mounted more than once (e.g. with a bind mount).

Quoted 6 lines
Quoted 3 lines

What happens when you thaw?

Paolo

If you try to THAW an unfrozen FS you get EINVAL.

The current code thaws until an error is returned.

So it should work as is.

If you feel uncomfortable with the EBUSY approach. The other idea would

be to track all devices which have been successfully frozen and skip consecutive

tries to freeze them.

Peter

#4 lore raw

Hi,

Quoted 7 lines · Peter Lieven

If you try to THAW an unfrozen FS you get EINVAL.

The current code thaws until an error is returned.

Quoted 8 lines

So it should work as is.

If you feel uncomfortable with the EBUSY approach. The other idea would

be to track all devices which have been successfully frozen and skip consecutive

tries to freeze them.

Which will be subject to race conditions as other processes may call freeze/thaw on any device. Those are completely out of our control.

Christian

--
Christian Theune · [email protected] · +49 345 219401 0
Flying Circus Internet Operations GmbH · http://flyingcircus.io
Forsterstraße 29 · 06112 Halle (Saale) · Deutschland
HR Stendal HRB 21169 · Geschäftsführer: Christian. Theune, Christian. Zagrodnick

#5 lore raw

Am 03.02.2017 um 09:22 schrieb Christian Theune:

Quoted 12 lines

Hi,

Quoted 10 lines · On 3 Feb 2017, at 09:20, Peter Lieven <[email protected] <mailto:[email protected]>> wrote:

If you try to THAW an unfrozen FS you get EINVAL.

The current code thaws until an error is returned.

So it should work as is.

Quoted 7 lines
Quoted 5 lines

If you feel uncomfortable with the EBUSY approach. The other idea would

be to track all devices which have been successfully frozen and skip consecutive

tries to freeze them.

Which will be subject to race conditions as other processes may call freeze/thaw on any device. Those are completely out of our control.

That will always be out of control. If we freeze the FS and another process thaws it, we snapshot an unfrozen fs and believe it is frozen.

I think the EBUSY approach is fine. If I look at the documentation of the thaw in the code it seems that the behaviour of the linux kernel changed. It seems that it was possible to call FIFREEZE multiple times on an FS and this required multiple FITHAWs to unfreeze it.

Peter

#6 lore raw
In reply to Peter Lieven
Quoted 14 lines · Peter Lieven

Am 02.02.2017 um 22:41 schrieb Paolo Bonzini:

Quoted 6 lines · Peter Lieven
Quoted 4 lines

the current implementation fails if we try to freeze an already frozen filesystem. This can happen if a filesystem is mounted more than once (e.g. with a bind mount).

Quoted 6 lines
Quoted 3 lines

What happens when you thaw?

Paolo

Quoted 8 lines

If you try to THAW an unfrozen FS you get EINVAL. The current code thaws until an error is returned.

So it should work as is.

If you feel uncomfortable with the EBUSY approach. The other idea would be to track all devices which have been successfully frozen and skip consecutive tries to freeze them.

No, just asking.

#7 lore raw

Am 03.02.2017 um 19:31 schrieb Paolo Bonzini:

Quoted 17 lines · Peter Lieven
Quoted 15 lines

Am 02.02.2017 um 22:41 schrieb Paolo Bonzini:

Quoted 11 lines · Peter Lieven
Quoted 7 lines

the current implementation fails if we try to freeze an already frozen filesystem. This can happen if a filesystem is mounted more than once (e.g. with a bind mount).

What happens when you thaw?

Paolo

If you try to THAW an unfrozen FS you get EINVAL. The current code thaws until an error is returned.

Quoted 8 lines
Quoted 5 lines

So it should work as is.

If you feel uncomfortable with the EBUSY approach. The other idea would be to track all devices which have been successfully frozen and skip consecutive tries to freeze them.

No, just asking.

Ping, Michael can you pick this up please.

Thanks,

Peter