From: Theodore Ts'o <tytso@mit.edu>
To: Mike Fleetwood <mike.fleetwood@googlemail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: How to query ext2/3/4 total fs size while mounted?
Date: Fri, 7 Sep 2012 20:39:27 -0400 [thread overview]
Message-ID: <20120908003927.GE2542@thunk.org> (raw)
In-Reply-To: <CAMU1PDg-WrH9TS-U9SfeMfV2FTBz7Md+7PR1k55aMTFVq=7NiA@mail.gmail.com>
On Fri, Sep 07, 2012 at 09:12:49PM +0100, Mike Fleetwood wrote:
>
> Is it safe to read the super block off disk using ext2fs_open() or by
> running dumpe2fs for a mounted file system? What if the file system has
> just been resized? Are there any other methods for querying the total
> file system size?
Yes, it would be safe to read the superblock off a mounted disk.
There is always going to be a race if someone is resizing the file
system as you read the file system, but that's true for the statfs
system call as well.
There's no way that parted can stop someone else from kicking off a
online resize between the time you display information about the
partition table and their contents and the user types in another
command.
Well, you could freeze the file system, but if another process is
writing huge amounts of data at the time, freezing the file system for
long periods of time could cause the system to run into significant
memory problems (since it can't clean memory pages so they can be
dropped to make room for more modified pages, leading to OOM kills).
Probably the best thing you can do, if this is really important to
you, is to snapshot the state of the file systems, then when the user
enters a command, in quick succession, freeze the file system, double
check to make sure nothing has changed, and if it hasn't, update the
partition table (this is most important if you are shrinking the
partition), and then unfreeze the file system.
Cheers,
- Ted
next prev parent reply other threads:[~2012-09-08 0:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-07 20:12 How to query ext2/3/4 total fs size while mounted? Mike Fleetwood
2012-09-08 0:39 ` Theodore Ts'o [this message]
2012-09-10 10:39 ` Mike Fleetwood
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=20120908003927.GE2542@thunk.org \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=mike.fleetwood@googlemail.com \
/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;
as well as URLs for NNTP newsgroup(s).