lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 23 Mar 2018 11:32:49 -0700
From:   harshads <harshads@...gle.com>
To:     tytso@....edu
Cc:     linux-ext4@...r.kernel.org, harshads <harshads@...gle.com>
Subject: [PATCH] debugfs: release clusters only once in release_blocks_proc

While killing file by inode in debugfs (kill_file_by_inode), if
bigalloc feature is turned on, release clusters only once. We do it by
remembering the last released cluster while releasing blocks. We
release a cluster only if it is not already released.

Signed-off-by: Harshad Shirwadkar <harshads@...gle.com>
---
 debugfs/debugfs.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 398bf722..d479ecf7 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -1796,11 +1796,17 @@ static int release_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
 			       e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
 			       blk64_t ref_block EXT2FS_ATTR((unused)),
 			       int ref_offset EXT2FS_ATTR((unused)),
-			       void *private EXT2FS_ATTR((unused)))
+			       void *private)
 {
-	blk64_t	block;
+	blk64_t	block = *blocknr;
+	blk64_t *last_cluster = (blk64_t *)private;
+	blk64_t cluster = EXT2FS_B2C(fs, block);
+
+	if (cluster == *last_cluster)
+		return 0;
+
+	*last_cluster = cluster;
 
-	block = *blocknr;
 	ext2fs_block_alloc_stats2(fs, block, -1);
 	return 0;
 }
@@ -1815,8 +1821,9 @@ static void kill_file_by_inode(ext2_ino_t inode)
 	if (debugfs_write_inode(inode, &inode_buf, 0))
 		return;
 	if (ext2fs_inode_has_valid_blocks2(current_fs, &inode_buf)) {
+		blk64_t last_cluster = 0;
 		ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY,
-				      NULL, release_blocks_proc, NULL);
+				      NULL, release_blocks_proc, &last_cluster);
 	}
 	printf("\n");
 	ext2fs_inode_alloc_stats2(current_fs, inode, -1,
-- 
2.17.0.rc0.231.g781580f067-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ