From patchwork Tue Oct 27 13:52:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 312169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 753F1C388F9 for ; Tue, 27 Oct 2020 17:02:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2213020809 for ; Tue, 27 Oct 2020 17:02:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603818125; bh=vu6tQ4BPjHYNEBWKoF8+6r4eyeStegbWma9YjhNfaiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=s2m8PgDBgkBn1Te9xF3FO6oil/0kvyYa7g0lM0p42B9gVjGG1PrqXVW1My2Ta/2CO ovlaa7SakXZbNUWXMgkWP2kzOp0EV1IimApWUHmFMGYytUPsD5AiVM881OSTh70tYy uaJ5X5u2xbOU2FPTIjt5HHMcLTrOOa30VgWkADUU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1793827AbgJ0RBw (ORCPT ); Tue, 27 Oct 2020 13:01:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793816AbgJ0PI3 (ORCPT ); Tue, 27 Oct 2020 11:08:29 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 757362072E; Tue, 27 Oct 2020 15:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811309; bh=vu6tQ4BPjHYNEBWKoF8+6r4eyeStegbWma9YjhNfaiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVcxtNGkKbOhjhSfJvSmlkgOv8HKeRhoTF7IHyXhQAtFuv5oGDe59nfj0B/WFm3sS 0ka5jjoSe5nm75cyQjD78hUBrNaP9RY1mw+ayGz98jFZzeE4slT9FGvX9by9FBTyYI Sd8AlBOryi8R1K7Rp8pSW0O3l9uJ7YE7up2dQspw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , Sasha Levin Subject: [PATCH 5.8 416/633] afs: Fix cell purging with aliases Date: Tue, 27 Oct 2020 14:52:39 +0100 Message-Id: <20201027135542.234599263@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: David Howells [ Upstream commit 286377f6bdf71568a4cf07104fe44006ae0dba6d ] When the afs module is removed, one of the things that has to be done is to purge the cell database. afs_cell_purge() cancels the management timer and then starts the cell manager work item to do the purging. This does a single run through and then assumes that all cells are now purged - but this is no longer the case. With the introduction of alias detection, a later cell in the database can now be holding an active count on an earlier cell (cell->alias_of). The purge scan passes by the earlier cell first, but this can't be got rid of until it has discarded the alias. Ordinarily, afs_unuse_cell() would handle this by setting the management timer to trigger another pass - but afs_set_cell_timer() doesn't do anything if the namespace is being removed (net->live == false). rmmod then hangs in the wait on cells_outstanding in afs_cell_purge(). Fix this by making afs_set_cell_timer() directly queue the cell manager if net->live is false. This causes additional management passes. Queueing the cell manager increments cells_outstanding to make sure the wait won't complete until all cells are destroyed. Fixes: 8a070a964877 ("afs: Detect cell aliases 1 - Cells with root volumes") Signed-off-by: David Howells Signed-off-by: Sasha Levin --- fs/afs/cell.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index c906000b0ff84..1944be78e9b0d 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -19,6 +19,7 @@ static unsigned __read_mostly afs_cell_gc_delay = 10; static unsigned __read_mostly afs_cell_min_ttl = 10 * 60; static unsigned __read_mostly afs_cell_max_ttl = 24 * 60 * 60; +static void afs_queue_cell_manager(struct afs_net *); static void afs_manage_cell_work(struct work_struct *); static void afs_dec_cells_outstanding(struct afs_net *net) @@ -37,6 +38,8 @@ static void afs_set_cell_timer(struct afs_net *net, time64_t delay) atomic_inc(&net->cells_outstanding); if (timer_reduce(&net->cells_timer, jiffies + delay * HZ)) afs_dec_cells_outstanding(net); + } else { + afs_queue_cell_manager(net); } }