From: Ted Ts'o <tytso@mit.edu>
To: GRobin Dong <hao.bigrat@gmail.com>
Cc: linux-ext4@vger.kernel.org, Robin Dong <sanbai@taobao.com>
Subject: Re: [PATCH 1/3] ext4: s_freeclusters_counter should not tranform to unit of block before assigning to "free_clusters" in ext4_has_free_cluste
Date: Sat, 24 Mar 2012 17:05:18 -0400 [thread overview]
Message-ID: <20120324210518.GB5883@thunk.org> (raw)
In-Reply-To: <1331638698-14796-1-git-send-email-hao.bigrat@gmail.com>
On Tue, Mar 13, 2012 at 07:38:16PM +0800, Robin Dong wrote:
> Creating 4-byte files until ENOSPC in a delay-allocation and bigalloc ext4 fs and then sync it, the dmseg will report like:
>
> [ 482.154538] EXT4-fs (sdb6): delayed block allocation failed for inode 1664 at logical offset 0 with max blocks 1 with error -28
> [ 482.154540] EXT4-fs (sdb6): This should not happen!! Data will be lost
>
> The reason is ext4_has_free_clusters reporting wrong
> result. Actually, the unit of sbi->s_dirtyclusters_counter is block,
> so we should tranform it to cluster for argument "dirty_clusters",
> just like "free_clusters".
We have a bigger problem here, which is that this is not the only
place where s_dirty_clusters_counter is being used in units of
clusters. (See ext4_claim_free_clusters, which when called by mballoc
is using units of clusters.)
We definitely have brokeness here, but this is not the whole story.
We need to take a step back here and decide whether the correct units
is clusters or blocks. Ultimately I think it does need to be
clusters, because we can't just convert blocks and clusters by using
B2C; we could dirty 3 blocks, but if those 3 blocks span two 64-block
clusters, what's important is that we have to reserve space for 2
clusters. We can't just calculate "3 >> 6" and assume that we can
reserve 0 clusters and be done with it!
This is one of the places where I think we need to solve things by
having a better data structure for tracking which pages have been
subject to delayed allocation, since if we touch another block in a
cluster where we've done a delayed allocation, we don't need to bump
s_dirtyclusters_counter. However, if this is the first time we've
touched a block in a particular cluster, then we *do* need to bump
s_dirtyclusters_counter --- and if we need to search all of the pages
in the page cache to make this determination, it's going to be
painful....
- Ted
next prev parent reply other threads:[~2012-03-24 21:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-13 11:38 [PATCH 1/3] ext4: s_freeclusters_counter should not tranform to unit of block before assigning to "free_clusters" in ext4_has_free_cluste Robin Dong
2012-03-13 11:38 ` [PATCH 2/3] ext4: modify the implementation of quota reservation in bigalloc-delay-allocation Robin Dong
2012-03-13 11:38 ` [PATCH 3/3] ext4: modify the process of invalidate_page for the new implemention of quota reservation Robin Dong
2012-03-24 21:05 ` Ted Ts'o [this message]
2012-04-16 3:35 ` [PATCH 1/3] ext4: s_freeclusters_counter should not tranform to unit of block before assigning to "free_clusters" in ext4_has_free_cluste Robin Dong
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=20120324210518.GB5883@thunk.org \
--to=tytso@mit.edu \
--cc=hao.bigrat@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sanbai@taobao.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).