From: Gionatan Danti <g.danti@assyoma.it>
To: linux-xfs@vger.kernel.org
Cc: g.danti@assyoma.it
Subject: It is safe to execute a fallocate on a opened and in-use file?
Date: Sat, 10 Jun 2017 20:09:40 +0200 [thread overview]
Message-ID: <85e83dbc8f31ecd79e018d595aa2e491@assyoma.it> (raw)
Hi all,
I would like to understand if it is safe, or not, to execute a fallocate
on a opened an possibly in-use file.
Scenario: a running Qemu/KVM virtual machine that need its RAW-image
vdisk to be expanded.
I normally stop the virtual machine and issue "fallocate -l <newsize>
<filename>", then I restart it. I wonder if I can skip the stop/start
phases, going directly for the fallocate.
Reasoning on the question, I naively think that fallocating when the VM
is writing on the file has the potential to cause corruption, due to
this racing condition:
- I execute fallocate;
- the filesystem begins searching for to-be-allocated chunks, and finds
one;
- the VM suddenly writes to the very same block found on the previous
step;
- the filesystem continue allocating the previos block, accidentally
discarding the just-written data.
This scenario can be avoided if the relevant critical path are protected
with mutex (or equivalent structures). Is it the case?
In general, how to consider concurrent metadata updates for the same
file/block? Should I expect file corruption, similar to concurrently
writing data to the same file/block?
Thanks.
--
Danti Gionatan
Supporto Tecnico
Assyoma S.r.l. - www.assyoma.it
email: g.danti@assyoma.it - info@assyoma.it
GPG public key ID: FF5F32A8
next reply other threads:[~2017-06-10 18:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-10 18:09 Gionatan Danti [this message]
2017-06-10 21:18 ` It is safe to execute a fallocate on a opened and in-use file? Darrick J. Wong
2017-06-10 22:00 ` Gionatan Danti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85e83dbc8f31ecd79e018d595aa2e491@assyoma.it \
--to=g.danti@assyoma.it \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox