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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230824092619.1327976-9-yi.zhang@huaweicloud.com>
Date:   Thu, 24 Aug 2023 17:26:11 +0800
From:   Zhang Yi <yi.zhang@...weicloud.com>
To:     linux-ext4@...r.kernel.org
Cc:     tytso@....edu, adilger.kernel@...ger.ca, jack@...e.cz,
        yi.zhang@...wei.com, yi.zhang@...weicloud.com,
        chengzhihao1@...wei.com, yukuai3@...wei.com
Subject: [RFC PATCH 08/16] ext4: refactor delalloc space reservation

From: Zhang Yi <yi.zhang@...wei.com>

Cleanup the delalloc reserve space calling, split it from the bigalloc
checks, call ext4_da_reserve_space() if it have unmapped block need to
reserve, no logical changes.

Signed-off-by: Zhang Yi <yi.zhang@...wei.com>
---
 fs/ext4/inode.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 546a3b09fd0a..861602903b4d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1623,8 +1623,9 @@ static void ext4_print_free_blocks(struct inode *inode)
 static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-	int ret;
+	unsigned int rsv_dlen = 1;
 	bool allocated = false;
+	int ret;
 
 	/*
 	 * If the cluster containing lblk is shared with a delayed,
@@ -1637,11 +1638,8 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
 	 * it's necessary to examine the extent tree if a search of the
 	 * extents status tree doesn't get a match.
 	 */
-	if (sbi->s_cluster_ratio == 1) {
-		ret = ext4_da_reserve_space(inode);
-		if (ret != 0)   /* ENOSPC */
-			return ret;
-	} else {   /* bigalloc */
+	if (sbi->s_cluster_ratio > 1) {
+		rsv_dlen = 0;
 		if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
 			if (!ext4_es_scan_clu(inode,
 					      &ext4_es_is_mapped, lblk)) {
@@ -1649,19 +1647,22 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
 						      EXT4_B2C(sbi, lblk));
 				if (ret < 0)
 					return ret;
-				if (ret == 0) {
-					ret = ext4_da_reserve_space(inode);
-					if (ret != 0)   /* ENOSPC */
-						return ret;
-				} else {
+				if (ret == 0)
+					rsv_dlen = 1;
+				else
 					allocated = true;
-				}
 			} else {
 				allocated = true;
 			}
 		}
 	}
 
+	if (rsv_dlen > 0) {
+		ret = ext4_da_reserve_space(inode);
+		if (ret)   /* ENOSPC */
+			return ret;
+	}
+
 	ext4_es_insert_delayed_block(inode, lblk, allocated);
 	return 0;
 }
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ