Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3848655ybx; Mon, 4 Nov 2019 03:56:46 -0800 (PST) X-Google-Smtp-Source: APXvYqz/erYpU9BwpjIE52PxQkC93wL+lk+1LvlUi5GyI1ak3mJ/B9mv0AOcERnH9t9j9HKZDDBk X-Received: by 2002:a17:906:f15:: with SMTP id z21mr23574211eji.119.1572868606360; Mon, 04 Nov 2019 03:56:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1572868606; cv=pass; d=google.com; s=arc-20160816; b=M5Rx0DW7iSUmlcBgB0MKquvUcRRELqXID6R81egBOK7NloZ9OciPEoBCGmcZK0yFEF La71jF6GCsJSSGW3L9PDazrmk4lzcaIfmNk8P/8Q1GzzkhAZHWRacb7cwTyxQeb/JXRX FCwDdq/SOPUp6K40sJruAqWPYjJh6Zex6QTf5sO0oWlV3Ml1Js/RCxuewnQBbL9O5wnT JNoPvOE1rBR3R15QjYalt2qkfqoVq6ri9iay6ZbCQPCYlhoNkjdFGrjVYTnWHh6yX0yc IctDx4BNKxfunR2DVd1p4ZIIHp+wsSm5FJoY9fjNDIxMWcOA161lvuTz/DnGZzP9tutJ p37g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:subject:message-id:cc:to:from :dkim-signature; bh=vD2mCFzn5UUpY9L7B2S+YTK+IZxao6tB3UjpLRoC+0I=; b=ZqcRyCPIE21aKbEpKgD1Ra5ekVVIZOMM3t5ns4zovgdDbKDqQ3Nm/igbj3mjutcGS/ UO/5WgVF+PxlZ6TEdYvbK7u2Z6P6ZxVbLEa4newgFIlFgjgNZp3fNqrW3Bcz0XrKe7Fm OtVkthFdianF2DtW4VxXsmjVlTD8oYCOsTGx3HEdFMs0/kOriwi6lh/4Qpo5tbxYQU47 G8otYyK233w/3yJsHI1ck23AK3oBqynGF0kMx+O/sAH3cN8z+Iqz80dIijNgbMztO7Ro jRgCeVaEt8mLm+TZd7dVTZsWLeVcoEomQbDgHaxqCpcys1Od4Ssl3OYmjkASH86ZscP3 q6Iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=E3kFSWIN; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q30si8126063edb.372.2019.11.04.03.56.18; Mon, 04 Nov 2019 03:56:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=E3kFSWIN; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727663AbfKDL4O (ORCPT + 99 others); Mon, 4 Nov 2019 06:56:14 -0500 Received: from sender3-of-o52.zoho.com.cn ([124.251.121.247]:21985 "EHLO sender2.zoho.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728346AbfKDL4M (ORCPT ); Mon, 4 Nov 2019 06:56:12 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1572867663; cv=none; d=zoho.com.cn; s=zohoarc; b=UsW76rhlBPLUFUKJLgq27iaTcR8khwjKSdGZUsPCyQQe3U8S2AJ8IlzqJiDqa+9emM3PncxECuuxYr3baW8ZdzjypHf9sFu0OKJ3ZxJvRQJlx7geq1rBZbpNEphubQKGLPfsg+rK5Pucxx0MDOANulARkWRuGQ3UpbpsoZBDZAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1572867663; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=vD2mCFzn5UUpY9L7B2S+YTK+IZxao6tB3UjpLRoC+0I=; b=lLEwjYctF60oFRWW/plD9XiTGvd1XOxHoouf9HDPFAvh92cTnFfhFhhQqJat8CvyQfsGVpz96JkbssQQBGb7EpeJ9uSSaDsbH8ikv8Uv+eUPXH+alPrDbaW3VaVVyChGhm+8DkxRC8vIDYaNl8GRHGh/noybLApPuSfCRzfAgfY= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1572867663; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; l=1502; bh=vD2mCFzn5UUpY9L7B2S+YTK+IZxao6tB3UjpLRoC+0I=; b=E3kFSWINHB2yCIbB3PtpKtnO4i3satdUvGSJD1IapUOAbG9Be9adgX84v4iehbPW lSZmhrvFMeLK5bDe5QEpuhbeW9t49+XsGyi7USJ982aZ1na/qY5UyqUSY6RgLDuZAvV EP9BRRXv+6uO0Ioqx+1CKk+OHpNUER2jvgNp3t98= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1572867662321557.7088117113368; Mon, 4 Nov 2019 19:41:02 +0800 (CST) From: Chengguang Xu To: jack@suse.com Cc: linux-ext4@vger.kernel.org, Chengguang Xu Message-ID: <20191104114036.9893-4-cgxu519@mykernel.net> Subject: [PATCH 4/5] ext2: code cleanup for ext2_try_to_allocate() Date: Mon, 4 Nov 2019 19:40:35 +0800 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191104114036.9893-1-cgxu519@mykernel.net> References: <20191104114036.9893-1-cgxu519@mykernel.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Code cleanup by removing duplicated code. Signed-off-by: Chengguang Xu --- 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 grou= p, =09=09=09=09; =09=09} =09} -=09start =3D grp_goal; =20 -repeat: -=09if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group), grp_goal, -=09=09=09 =09=09=09=09bitmap_bh->b_data)) { -=09=09/* -=09=09 * The block was allocated by another thread, or it was -=09=09 * allocated and then freed by another thread -=09=09 */ -=09=09start++; -=09=09grp_goal++; -=09=09if (start >=3D end) -=09=09=09goto fail_access; -=09=09goto repeat; -=09} -=09num++; -=09grp_goal++; -=09while (num < *count && grp_goal < end -=09=09&& !ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group), +=09while (num < *count && grp_goal < end) { +=09=09if (ext2_set_bit_atomic(sb_bgl_lock(EXT2_SB(sb), group), =09=09=09=09=09grp_goal, bitmap_bh->b_data)) { +=09=09=09if (num =3D=3D 0) { +=09=09=09=09grp_goal++; +=09=09=09=09continue; +=09=09=09} else { +=09=09=09=09break; +=09=09=09} +=09=09} + =09=09num++; =09=09grp_goal++; =09} + +=09if (!num) +=09=09goto fail_access; + =09*count =3D num; =09return grp_goal - num; fail_access: --=20 2.20.1