From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 59F792EE262 for ; Tue, 31 Mar 2026 14:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774966066; cv=none; b=e8vuagroJ8Snr1a0b0wPwndayIryDo4DWr3yltoyKXMYxCZpPG40Oju6tCfvy97Zp5si/dUHcy5h0/3r37WafY/mSpKMtdw0itJyn4TPvP/QJRzwtane6Rk1E7sdW8VotN9zs5qXpouviZBOijSJSadosNhC0ipkzksVDKbMTho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774966066; c=relaxed/simple; bh=nSIpKCjU15DVAJQsXibRhbN8Hs2EWNKOm99/+EzWcjc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=af4qSoF8dtUfn9Y2VUQJwmB9zm7sSw6pd6fz0UmLP+TM+uPTotWDZvsv+aVyQJ+SZfCMApoSkaeW20rxwewvHNIKuRbOHUlHqZ99WFwVpM5++2lO4WYtQ7tYs49YSnU7s2sUHXa0fOOSGxuRIKiqZ404ha4/N+/wg54mQMkuzkM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=permerror header.from=versity.com; spf=pass smtp.mailfrom=versity.com; dkim=pass (2048-bit key) header.d=versity.com header.i=@versity.com header.b=ZggSa9uf; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=permerror header.from=versity.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=versity.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=versity.com header.i=@versity.com header.b="ZggSa9uf" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b9382e59c0eso923573566b.0 for ; Tue, 31 Mar 2026 07:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=versity.com; s=google; t=1774966062; x=1775570862; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=XVZf265xbwWuftbHUTLEb+w1RVUrEhMXXX/Tp8GFU6E=; b=ZggSa9ufbLlaFidsjlWe0kdkc4As2At9X8uVo5LRWyCvnXGOutYt2XRG4FblF+62kT iloJepFxFRBmSn44q23XIJOlHo0p2aQlq7ZsxL7u8KdL1Ab+0IHHEGXkZ5RC8gsr46zF 5469ybxnTkAxX8i9LQ0XtUNfE+ItYF8zxIUdJqmEswVKt75/kJ9vO0gfzCHLU8whajiI jnWdzCGlq3+C9bU0z0eqAx2Wu6MqOe2CgbSTnVMurivRGSpw2QIDbY2lQkDPjLCInhYl GZ1HQGnHhpp1j/HqqD8iIZEtNagaiaSGcPq/Dc819e90dj3psq7yFBFuKXDUz8afniex AJ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774966062; x=1775570862; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XVZf265xbwWuftbHUTLEb+w1RVUrEhMXXX/Tp8GFU6E=; b=gQ3CSARhGq9w+7HcO5/lL9v7BGeUgofqyw2sSEkphQj6/EaXWjd8IkA16CIUPZI9MW CpdXysaKOb4NjzcnoCmkAW7wgAJCO9aLm0W7u4w9a885Yrbj3YdH3d74cPHzptxlv2EX cBbf0so+DRE5M+HSn6jbrQwk8zkgyvbgOm638MQ8s/jf9RvAiFTbAtDbmfIhk2R2YDEx VdJmrNJqRoI2z5rWdX8UebovPHpQCFEf5UZZXXEgCpFLOnJ7n35F5BKg6FTMYfxEaNwJ 18uypknoh31wrzI5j6lvQ/aok+XDtMzKi88P0i3FRImH0i/9UF5GXIbqpP4dBvYS6rmN x4+g== X-Gm-Message-State: AOJu0YyZWhi74zQIEhxHQ401m1oORkdXOCCfM1UvofHIk7GY30jAzAvT 2VFJau+Xeef5yBDufsAbSrLl8Cu/QqvPyPUGS0Hz6OYsDn/duBDZh5XH5MbxEg1NB7CzGFHZAQD 1T6Sc X-Gm-Gg: ATEYQzzF8xxQ5I3y7jP9v0Kb2XGa9Yp7Kl0kx+NDAK4koljf/Ey7Y3mTbtzWS8ksmEe 4Q6oAwHvfAN7ecmYw0jo6rbVBRm31wbcqtmKl4E8rDz8UXWlp3IEUW4szs/TUeYqejrQwU3C9l9 /7X//rJCIo58pgD71xYL5+1jnBqp/SK7eCaS86IQJrdNli1i0qx6hA2FidiEyHBuW40nggADOJ+ wFCPI0AzZB1wScpVASj6TJVTelNZ2BBmzfrqutHixDgRaXlb8EgdM9IIAcRKXRMXYV3n0k8fUl1 8EPBYmo07TGW8ygfNN2xKFbo7Jm18nLeGOeS5GrtLlIdsUT8/D7wTMS++QaTZYt324TuCSSj7Wq TzLMHP50iiHq104WLiwLtvFMjS8U5U861EElmXOdFjukmpqDsE1WQjqs0lr77NaiX7ZZ0l3VK1B QRIM9IRYN9ta/323xDmZfpt8ZQx0mc7oPLfTJRiGWvdC6pGvR7Tq81a+zJeVl33r/0HL4diKumU j6ixQ/vegDcXAVd3PID/yqWO4A= X-Received: by 2002:a17:907:1c9b:b0:b9b:171e:baef with SMTP id a640c23a62f3a-b9b502bfd0cmr1037930766b.6.1774966061387; Tue, 31 Mar 2026 07:07:41 -0700 (PDT) Received: from localhost.localdomain (46-117-212-87.ftth.glasoperator.nl. [87.212.117.46]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9b7b1a65c2sm409907966b.34.2026.03.31.07.07.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 07:07:41 -0700 (PDT) From: Valerie Aurora To: rpdfs-devel@lists.linux.dev Subject: [PATCH] Move block region publish out of RCU callback Date: Tue, 31 Mar 2026 16:07:32 +0200 Message-ID: <20260331140732.29036-1-val@versity.com> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: rpdfs-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit We were unnecessarily complicating the freeing of a region builder by doing it in an RCU callback. Move the region publication out of the RCU callback and free the region builder itself with standard kfree_rcu(). Signed-off-by: Valerie Aurora --- fs/rpdfs/block.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/fs/rpdfs/block.c b/fs/rpdfs/block.c index bece03045d82..ef935fcbdbad 100644 --- a/fs/rpdfs/block.c +++ b/fs/rpdfs/block.c @@ -470,22 +470,6 @@ static struct rpdfs_block *lookup_block(struct rpdfs_block_info *binf, u64 bnr) return bk; } -static void publish_region_rcu(struct rcu_head *head) -{ - struct rpdfs_block_region_builder *rbld; - - rbld = container_of(head, struct rpdfs_block_region_builder, hte.rcu); - rpdfs_balloc_publish_region(rbld->rfi, rbld->reg); - kfree(rbld); -} - -/* - * We need to wait for a grace period before rcu readers are done with - * the region and we can hand it off to balloc. So we model it like - * kfree_rcu. Once no requests are in flight and the refcounts drop we - * hand off to an rcu callback which publishes it with balloc once the - * grace period ends. - */ static void put_rbld(struct rpdfs_block_info *binf, struct rpdfs_block_region_builder *rbld) { if (IS_ERR_OR_NULL(rbld)) @@ -495,7 +479,7 @@ static void put_rbld(struct rpdfs_block_info *binf, struct rpdfs_block_region_bu if (rpdfs_ht_put(&binf->rbld_ht, &rbld->hte, rbld_ht_params, atomic_read(&rbld->in_flight) == 0)) { atomic64_inc(&binf->regions_done); - call_rcu(&rbld->hte.rcu, publish_region_rcu); + kfree_rcu(rbld, hte.rcu); } rcu_read_unlock(); } @@ -1708,6 +1692,7 @@ static int recv_free_stripe_grant(struct rpdfs_fs_info *rfi, struct rpdfs_net_me unsigned long stripes; struct rpdfs_block *bk; int nr_blocks; + int in_flight; u64 mver; u64 bnr; int b; @@ -1762,27 +1747,31 @@ static int recv_free_stripe_grant(struct rpdfs_fs_info *rfi, struct rpdfs_net_me goto out; } + spin_lock(&rbld->lock); + rpdfs_balloc_set_stripe_bits(rbld->reg, this_stripe, stripes, fsg->bmap, + RPDFS_MSG_BLOCKS_PER_FREE_STRIPE); + spin_unlock(&rbld->lock); + /* only the first search result for a given rbld will send requests to others */ if (fsg->flags & RPDFS_MSG_FREE_STRIPE_GRANT_FLAG_SEARCH) { - if (atomic_cmpxchg(&rbld->in_flight, stripes, stripes - 1) == stripes) { + in_flight = atomic_cmpxchg(&rbld->in_flight, stripes, stripes - 1) - 1; + if (in_flight == stripes - 1) { for (i = 0; i < stripes; i++) { if (i == this_stripe) continue; ret = send_free_stripe_request(rfi, bnr + i, 0, GFP_NOFS); if (ret < 0) - atomic_dec(&rbld->in_flight); + in_flight = atomic_dec_return(&rbld->in_flight); } } } else { - atomic_dec(&rbld->in_flight); + in_flight = atomic_dec_return(&rbld->in_flight); } - spin_lock(&rbld->lock); - rpdfs_balloc_set_stripe_bits(rbld->reg, this_stripe, stripes, fsg->bmap, - RPDFS_MSG_BLOCKS_PER_FREE_STRIPE); - spin_unlock(&rbld->lock); + /* publish the region if all requests are answered (or failed to send) */ + if (in_flight == 0) + rpdfs_balloc_publish_region(rbld->rfi, rbld->reg); - /* reg is published to balloc in rcu calback once in_flight == 0 */ put_rbld(binf, rbld); ret = 0; -- 2.49.0