linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
To: linux-ext4@vger.kernel.org
Subject: Re: How to query ext2/3/4 total fs size while mounted?
Date: Mon, 10 Sep 2012 11:39:39 +0100	[thread overview]
Message-ID: <CAMU1PDic_hPBogL_orM5XYjhYxGRdATTrdJxU=GuqFrtSYG28Q@mail.gmail.com> (raw)
In-Reply-To: <20120908003927.GE2542@thunk.org>

On 8 September 2012 01:39, Theodore Ts'o <tytso@mit.edu> wrote:
> 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.

It would also be easiest if GParted can use the free blocks from the on
disk super block too, rather than calling statvfs().  How up to date
will the on disk free blocks figure be?

My testing using a slowly allocating space workload finds ext2 writes
the super block every 6 seconds keeping the blocks free figure up to
date.  However for ext3 & ext4 the super block doesn't change.  I guess
because all the meta data updates are journalled and can be replayed on
crash.

Freezing and unfreezing ext3/4 does get the blocks free figure in the
super block updated, but GParted shouldn't be freezing and unfreezing a
file system just to get the free space.  I guess that GParted should
just use statvfs() to query free blocks.

Thanks,
Mike

      reply	other threads:[~2012-09-10 10: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
2012-09-10 10:39   ` Mike Fleetwood [this message]

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='CAMU1PDic_hPBogL_orM5XYjhYxGRdATTrdJxU=GuqFrtSYG28Q@mail.gmail.com' \
    --to=mike.fleetwood@googlemail.com \
    --cc=linux-ext4@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;
as well as URLs for NNTP newsgroup(s).