From patchwork Tue May 28 12:09:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coly Li X-Patchwork-Id: 13676574 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB70716C6BF; Tue, 28 May 2024 12:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716898170; cv=none; b=qyzI/hd1if7BMPEOU9In85MEbpeRTYZDAnF3Rmh+b7RAX6JYd16h5ciP8aaodmaSnzzneR7KF17L9F4mcYou1tcjRW+b4fHJ9DnzAsVEZwUzUJ3Ef9QuO4xpK4qdWPN4mfXGmR3MldvdJsQSdt/z97lSrfp5PAFUaXMMz35BEGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716898170; c=relaxed/simple; bh=qs1lP3F/RReECvt5ig8VQh0exjUBp8B4DtgFQowtKis=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OA3xwZCKpBajsS7gzp58rPYuk+EnwltU8M72mN0VYbXTpUGgpAGkKX2t+nGt2KUHZrcpJkZw3oSuZa9gk1EXx98/LSZqCSTui33dym4bMSWtp+O6LQywaY17FAWI3zz2nZc7tXj06C3eYyVLFEii4vNCnQ+qDEx2EaJvDj2+wwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bpGdmoJR; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Kpnz5l+i; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bpGdmoJR; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=Kpnz5l+i; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bpGdmoJR"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Kpnz5l+i"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bpGdmoJR"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Kpnz5l+i" Received: from suse-arm.lan (unknown [10.149.192.130]) by smtp-out2.suse.de (Postfix) with ESMTP id DE66C20285; Tue, 28 May 2024 12:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898167; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4sCyETnzeCTk0ioHlBUzB9OCL1WL60LzLIijIDGAzvY=; b=bpGdmoJR9Vzfjeo0Auqb9C6v+d3OlFXKU++b/o6QnMZ5nKTyUCny4iOixTxQ6BfMfFvWB1 Tb9t/vMe1mZ90UND2PHS5Tcwkcjtnt42baq1G156uZuiczis9jkDAvu8fSy/HWX3q7jdag 4yyDxXWJaO9gOllXGM/0sH3yxdOyFDo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898167; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4sCyETnzeCTk0ioHlBUzB9OCL1WL60LzLIijIDGAzvY=; b=Kpnz5l+iPkp4hZboLPF4fg2nmOQRty2AisqcEO7kzbZnT799CDIfWgSmwrIRqvzON/UKEy xZEbZ7qgR0jALhAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898167; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4sCyETnzeCTk0ioHlBUzB9OCL1WL60LzLIijIDGAzvY=; b=bpGdmoJR9Vzfjeo0Auqb9C6v+d3OlFXKU++b/o6QnMZ5nKTyUCny4iOixTxQ6BfMfFvWB1 Tb9t/vMe1mZ90UND2PHS5Tcwkcjtnt42baq1G156uZuiczis9jkDAvu8fSy/HWX3q7jdag 4yyDxXWJaO9gOllXGM/0sH3yxdOyFDo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898167; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4sCyETnzeCTk0ioHlBUzB9OCL1WL60LzLIijIDGAzvY=; b=Kpnz5l+iPkp4hZboLPF4fg2nmOQRty2AisqcEO7kzbZnT799CDIfWgSmwrIRqvzON/UKEy xZEbZ7qgR0jALhAQ== From: Coly Li To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, Dongsheng Yang , Mingzhe Zou , Coly Li Subject: [PATCH 1/3] bcache: allow allocator to invalidate bucket in gc Date: Tue, 28 May 2024 20:09:12 +0800 Message-Id: <20240528120914.28705-2-colyli@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240528120914.28705-1-colyli@suse.de> References: <20240528120914.28705-1-colyli@suse.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.981]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] From: Dongsheng Yang Currently, if the gc is running, when the allocator found free_inc is empty, allocator has to wait the gc finish. Before that, the IO is blocked. But actually, there would be some buckets is reclaimable before gc, and gc will never mark this kind of bucket to be unreclaimable. So we can put these buckets into free_inc in gc running to avoid IO being blocked. Signed-off-by: Dongsheng Yang Signed-off-by: Mingzhe Zou Signed-off-by: Coly Li --- drivers/md/bcache/alloc.c | 13 +++++-------- drivers/md/bcache/bcache.h | 1 + drivers/md/bcache/btree.c | 7 ++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index ce13c272c387..32a46343097d 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -129,12 +129,9 @@ static inline bool can_inc_bucket_gen(struct bucket *b) bool bch_can_invalidate_bucket(struct cache *ca, struct bucket *b) { - BUG_ON(!ca->set->gc_mark_valid); - - return (!GC_MARK(b) || - GC_MARK(b) == GC_MARK_RECLAIMABLE) && - !atomic_read(&b->pin) && - can_inc_bucket_gen(b); + return (ca->set->gc_mark_valid || b->reclaimable_in_gc) && + ((!GC_MARK(b) || GC_MARK(b) == GC_MARK_RECLAIMABLE) && + !atomic_read(&b->pin) && can_inc_bucket_gen(b)); } void __bch_invalidate_one_bucket(struct cache *ca, struct bucket *b) @@ -148,6 +145,7 @@ void __bch_invalidate_one_bucket(struct cache *ca, struct bucket *b) bch_inc_gen(ca, b); b->prio = INITIAL_PRIO; atomic_inc(&b->pin); + b->reclaimable_in_gc = 0; } static void bch_invalidate_one_bucket(struct cache *ca, struct bucket *b) @@ -352,8 +350,7 @@ static int bch_allocator_thread(void *arg) */ retry_invalidate: - allocator_wait(ca, ca->set->gc_mark_valid && - !ca->invalidate_needs_gc); + allocator_wait(ca, !ca->invalidate_needs_gc); invalidate_buckets(ca); /* diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 4e6afa89921f..1d33e40d26ea 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -200,6 +200,7 @@ struct bucket { uint8_t gen; uint8_t last_gc; /* Most out of date gen in the btree */ uint16_t gc_mark; /* Bitfield used by GC. See below for field */ + uint16_t reclaimable_in_gc:1; }; /* diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index d011a7154d33..4e6ccf2c8a0b 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -1741,18 +1741,20 @@ static void btree_gc_start(struct cache_set *c) mutex_lock(&c->bucket_lock); - c->gc_mark_valid = 0; c->gc_done = ZERO_KEY; ca = c->cache; for_each_bucket(b, ca) { b->last_gc = b->gen; + if (bch_can_invalidate_bucket(ca, b)) + b->reclaimable_in_gc = 1; if (!atomic_read(&b->pin)) { SET_GC_MARK(b, 0); SET_GC_SECTORS_USED(b, 0); } } + c->gc_mark_valid = 0; mutex_unlock(&c->bucket_lock); } @@ -1809,6 +1811,9 @@ static void bch_btree_gc_finish(struct cache_set *c) for_each_bucket(b, ca) { c->need_gc = max(c->need_gc, bucket_gc_gen(b)); + if (b->reclaimable_in_gc) + b->reclaimable_in_gc = 0; + if (atomic_read(&b->pin)) continue; From patchwork Tue May 28 12:09:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coly Li X-Patchwork-Id: 13676575 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AE3C16C6BF; Tue, 28 May 2024 12:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716898173; cv=none; b=gmUUBiwbrf9nm6jAJ7D9NpN/RJoeWO0+qSM9fqNlpZ52kookMbaGhDmtdsIEd15sWsupBSTK57B7rmDi1Kb3JBRX7KFL4AtFKDGYxs7R4ZO20yWsYkCxgyRncZeJL44B3xSQ5mWDMq/P2imUQozFTCbOvlKyTFLc47lJtQKIHUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716898173; c=relaxed/simple; bh=nhEyW+xxyANKL/q4Lh5FO00xmvZp5ITPXPEhC/qKC+U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R3SpMagvYI3I0XY3bGOL6zQXJPSJBkhkRupdUUxUF3EW2kJQ0IFvqcEp2PvuFSiFeb2j+teGi+JWKX4LIXJ7i8BqtOGMpicONiWpdOUcm4dbhNAW6YCZItuHyLEicEblHyZNickKoW3dKomoRNbGSf7YsK7HkhsudZ90nOXiYjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=fNzyeYgL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=0XbKw6xm; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=fNzyeYgL; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=0XbKw6xm; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fNzyeYgL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0XbKw6xm"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fNzyeYgL"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0XbKw6xm" Received: from suse-arm.lan (unknown [10.149.192.130]) by smtp-out2.suse.de (Postfix) with ESMTP id DE62420288; Tue, 28 May 2024 12:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898169; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ecu6l64rYKbloNPdAo4aXfsHx7rdsvlKjgwucOmGwr4=; b=fNzyeYgLtrIkkSJVCezicad1Rt0MerBfp8hPeRBvbRlR6znSg75ncI6e68bAZZ+aIgtrkD vl6to/iq+ETwPXAhdPX9/aC/kn+gjxAXkx8xCVgyzt69UNZ04ZsiGCS4Qj8DwvvfQ5JDat 0NeVJKCiWczqUGCXSVtG51ADZegS5QM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898169; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ecu6l64rYKbloNPdAo4aXfsHx7rdsvlKjgwucOmGwr4=; b=0XbKw6xmoqytsJwKs+FR5Gb9T6l3lLUcVr7RUaDcrw7x7w49fMhy7BMnCTUacySNNW1wCZ enRlqo5EaaX+HgAw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898169; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ecu6l64rYKbloNPdAo4aXfsHx7rdsvlKjgwucOmGwr4=; b=fNzyeYgLtrIkkSJVCezicad1Rt0MerBfp8hPeRBvbRlR6znSg75ncI6e68bAZZ+aIgtrkD vl6to/iq+ETwPXAhdPX9/aC/kn+gjxAXkx8xCVgyzt69UNZ04ZsiGCS4Qj8DwvvfQ5JDat 0NeVJKCiWczqUGCXSVtG51ADZegS5QM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898169; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ecu6l64rYKbloNPdAo4aXfsHx7rdsvlKjgwucOmGwr4=; b=0XbKw6xmoqytsJwKs+FR5Gb9T6l3lLUcVr7RUaDcrw7x7w49fMhy7BMnCTUacySNNW1wCZ enRlqo5EaaX+HgAw== From: Coly Li To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, Coly Li Subject: [PATCH 2/3] bcache: call force_wake_up_gc() if necessary in check_should_bypass() Date: Tue, 28 May 2024 20:09:13 +0800 Message-Id: <20240528120914.28705-3-colyli@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240528120914.28705-1-colyli@suse.de> References: <20240528120914.28705-1-colyli@suse.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.980]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ZERO(0.00)[0]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] X-Spam-Score: -6.80 X-Spam-Flag: NO If there are extreme heavy write I/O continuously hit on relative small cache device (512GB in my testing), it is possible to make counter c->gc_stats.in_use continue to increase and exceed CUTOFF_CACHE_ADD. If 'c->gc_stats.in_use > CUTOFF_CACHE_ADD' happens, all following write requests will bypass the cache device because check_should_bypass() returns 'true'. Because all writes bypass the cache device, counter c->sectors_to_gc has no chance to be negative value, and garbage collection thread won't be waken up even the whole cache becomes clean after writeback accomplished. The aftermath is that all write I/Os go directly into backing device even the cache device is clean. To avoid the above situation, this patch uses a quite conservative way to fix: if 'c->gc_stats.in_use > CUTOFF_CACHE_ADD' happens, only wakes up garbage collection thread when the whole cache device is clean. Before the fix, the writes-always-bypass situation happens after 10+ hours write I/O pressure on 512GB Intel optane memory which acts as cache device. After this fix, such situation doesn't happen after 36+ hours testing. Signed-off-by: Coly Li --- drivers/md/bcache/request.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 83d112bd2b1c..af345dc6fde1 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -369,10 +369,24 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) struct io *i; if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) || - c->gc_stats.in_use > CUTOFF_CACHE_ADD || (bio_op(bio) == REQ_OP_DISCARD)) goto skip; + if (c->gc_stats.in_use > CUTOFF_CACHE_ADD) { + /* + * If cached buckets are all clean now, 'true' will be + * returned and all requests will bypass the cache device. + * Then c->sectors_to_gc has no chance to be negative, and + * gc thread won't wake up and caching won't work forever. + * Here call force_wake_up_gc() to avoid such aftermath. + */ + if (BDEV_STATE(&dc->sb) == BDEV_STATE_CLEAN && + c->gc_mark_valid) + force_wake_up_gc(c); + + goto skip; + } + if (mode == CACHE_MODE_NONE || (mode == CACHE_MODE_WRITEAROUND && op_is_write(bio_op(bio)))) From patchwork Tue May 28 12:09:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coly Li X-Patchwork-Id: 13676576 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B330E161321; Tue, 28 May 2024 12:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716898175; cv=none; b=nKcm5BwyUGORmlzPsL3H29uXpfb0GhV0xBI+XK5lWXaqTqoQjb/Vt441nKkLC2IGXS1iOLuZpYiP/vA/V+R5Uo6Riq41zq4WzhZpvlvbK5Wj0t7xzM9JpjiS4vapFCojQq5NuoRy0AaFK0pxoZGNCeqIsKOfETyixnTzWJ1ZG4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716898175; c=relaxed/simple; bh=8H7BV9/eeO5tjatJqOyVQkKquqg19jk66pQrSgWPS3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nUoox60XqDaEmSEueZ/ZxWn3OQjFEASNdOMUJiXkoTJ0tN74fR++iS+zeCFnVz5GnoE/cVlxSTBGoRYu3+3cIEavD8asL/nGQFcFpShyfH6MsRG+eGTZn8/LIemI2Hzn4/nZbEKUjuFjxy7/W4j9Z7/KHMk6js+3A8Kcr8inqYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NwlLummx; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=j/hDu81B; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NwlLummx; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=j/hDu81B; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NwlLummx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="j/hDu81B"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NwlLummx"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="j/hDu81B" Received: from suse-arm.lan (unknown [10.149.192.130]) by smtp-out2.suse.de (Postfix) with ESMTP id 407B020287; Tue, 28 May 2024 12:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+3f9q1shIhYWg9rVbKhSKne37I38ok0u2p9d2o7S2s=; b=NwlLummxCmct8INs3CIGrwAZ433/cFyOkNry0YkZ3ZqBpSfC68cIPv2gZvrJ3KRKfXRYOa 7igfmlgUfSKAbv4/bMTl6iwQI22t++VPhLeLEqxDVodeN2/N+3SdhTvwNVDw3uUamYc1iV MR/TtVRpw5Dvly58sMYuzcfWJeAiSIs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+3f9q1shIhYWg9rVbKhSKne37I38ok0u2p9d2o7S2s=; b=j/hDu81B/mYHHXPYUJ0gu2L1vC1fUb/th9gCREccG5Y7yKndNGzn76P4UnWxEJJl8pMOcb eUdbIH+JsgK62oCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716898172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+3f9q1shIhYWg9rVbKhSKne37I38ok0u2p9d2o7S2s=; b=NwlLummxCmct8INs3CIGrwAZ433/cFyOkNry0YkZ3ZqBpSfC68cIPv2gZvrJ3KRKfXRYOa 7igfmlgUfSKAbv4/bMTl6iwQI22t++VPhLeLEqxDVodeN2/N+3SdhTvwNVDw3uUamYc1iV MR/TtVRpw5Dvly58sMYuzcfWJeAiSIs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716898172; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X+3f9q1shIhYWg9rVbKhSKne37I38ok0u2p9d2o7S2s=; b=j/hDu81B/mYHHXPYUJ0gu2L1vC1fUb/th9gCREccG5Y7yKndNGzn76P4UnWxEJJl8pMOcb eUdbIH+JsgK62oCg== From: Coly Li To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, Coly Li Subject: [PATCH 3/3] bcache: code cleanup in __bch_bucket_alloc_set() Date: Tue, 28 May 2024 20:09:14 +0800 Message-Id: <20240528120914.28705-4-colyli@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240528120914.28705-1-colyli@suse.de> References: <20240528120914.28705-1-colyli@suse.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.978]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ZERO(0.00)[0]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email] In __bch_bucket_alloc_set() the lines after lable 'err:' indeed do nothing useful after multiple cache devices are removed from bcache code. This cleanup patch drops the useless code to save a bit CPU cycles. Signed-off-by: Coly Li --- drivers/md/bcache/alloc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index 32a46343097d..48ce750bf70a 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c @@ -498,8 +498,8 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve, ca = c->cache; b = bch_bucket_alloc(ca, reserve, wait); - if (b == -1) - goto err; + if (b < 0) + return -1; k->ptr[0] = MAKE_PTR(ca->buckets[b].gen, bucket_to_sector(c, b), @@ -508,10 +508,6 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve, SET_KEY_PTRS(k, 1); return 0; -err: - bch_bucket_free(c, k); - bkey_put(c, k); - return -1; } int bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,