From: Eric Whitney <enwlinux@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: [PATCH] e2fsck: fix multiply-claimed block quota accounting when deleting files
Date: Wed, 10 May 2017 18:04:40 -0400 [thread overview]
Message-ID: <20170510220440.GA26875@localhost.localdomain> (raw)
As e2fsck processes each file in pass1, the actual file system quota is
increased by the number of blocks discovered in the file. This can
include both non-multiply-claimed and multiply-claimed blocks, if the
latter exist. However, if a file containing multiply-claimed blocks
is then deleted in pass1b, those blocks are not taken into account when
decreasing the actual quota. In this case, the new quota values written
to the file system by e2fsck overstate the space actually consumed.
And, e2fsck must be run twice on the file system to fully correct
quota.
Fix this by counting multiply-claimed blocks as a debit to quota when
deleting files in pass1b.
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
---
e2fsck/pass1b.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index b40f026..8744fad 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -636,11 +636,13 @@ static int delete_file_block(ext2_filsys fs,
lc = EXT2FS_B2C(fs, blockcnt);
if (ext2fs_test_block_bitmap2(ctx->block_dup_map, *block_nr)) {
n = dict_lookup(&clstr_dict, INT_TO_VOIDPTR(c));
- if (n) {
- p = (struct dup_cluster *) dnode_get(n);
- if (lc != pb->cur_cluster)
+ if (n)
+ if (lc != pb->cur_cluster) {
+ p = (struct dup_cluster *) dnode_get(n);
decrement_badcount(ctx, *block_nr, p);
- } else
+ pb->dup_blocks++;
+ }
+ else
com_err("delete_file_block", 0,
_("internal error: can't find dup_blk for %llu\n"),
*block_nr);
--
2.1.4
next reply other threads:[~2017-05-10 22:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 22:04 Eric Whitney [this message]
2017-05-10 23:05 ` [PATCH] e2fsck: fix multiply-claimed block quota accounting when deleting files Andreas Dilger
2017-05-11 15:42 ` Eric Whitney
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=20170510220440.GA26875@localhost.localdomain \
--to=enwlinux@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).