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: <20191104114036.9893-4-cgxu519@mykernel.net>
Date:   Mon,  4 Nov 2019 19:40:35 +0800
From:   Chengguang Xu <cgxu519@...ernel.net>
To:     jack@...e.com
Cc:     linux-ext4@...r.kernel.org, Chengguang Xu <cgxu519@...ernel.net>
Subject: [PATCH 4/5] ext2: code cleanup for ext2_try_to_allocate()

Code cleanup by removing duplicated code.

Signed-off-by: Chengguang Xu <cgxu519@...ernel.net>
---
 fs/ext2/balloc.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index a0c22e166682..9a9bd566243d 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -710,29 +710,25 @@ ext2_try_to_allocate(struct super_block *sb, int group,
 				;
 		}
 	}
-	start = grp_goal;
 
-repeat:
-	if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group), grp_goal,
-			       				bitmap_bh->b_data)) {
-		/*
-		 * The block was allocated by another thread, or it was
-		 * allocated and then freed by another thread
-		 */
-		start++;
-		grp_goal++;
-		if (start >= end)
-			goto fail_access;
-		goto repeat;
-	}
-	num++;
-	grp_goal++;
-	while (num < *count && grp_goal < end
-		&& !ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group),
+	while (num < *count && grp_goal < end) {
+		if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group),
 					grp_goal, bitmap_bh->b_data)) {
+			if (num == 0) {
+				grp_goal++;
+				continue;
+			} else {
+				break;
+			}
+		}
+
 		num++;
 		grp_goal++;
 	}
+
+	if (!num)
+		goto fail_access;
+
 	*count = num;
 	return grp_goal - num;
 fail_access:
-- 
2.20.1



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ