mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: linux-afs@lists.infradead.org
Cc: dhowells@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/9] afs: Wait for outstanding async calls before closing rxrpc socket
Date: Thu, 07 Apr 2016 17:23:03 +0100	[thread overview]
Message-ID: <20160407162303.21283.63145.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20160407162256.21283.47849.stgit@warthog.procyon.org.uk>

The afs filesystem needs to wait for any outstanding asynchronous calls
(such as FS.GiveUpCallBacks cleaning up the callbacks lodged with a server)
to complete before closing the AF_RXRPC socket when unloading the module.

This may occur if the module is removed too quickly after unmounting all
filesystems.  This will produce an error report that looks like:

	AFS: Assertion failed
	1 == 0 is false
	0x1 == 0x0 is false
	------------[ cut here ]------------
	kernel BUG at ../fs/afs/rxrpc.c:135!
	...
	RIP: 0010:[<ffffffffa004111c>] afs_close_socket+0xec/0x107 [kafs]
	...
	Call Trace:
	 [<ffffffffa004a160>] afs_exit+0x1f/0x57 [kafs]
	 [<ffffffff810c30a0>] SyS_delete_module+0xec/0x17d
	 [<ffffffff81610417>] entry_SYSCALL_64_fastpath+0x12/0x6b

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/afs/rxrpc.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index b50642870a43..7c2567a711ea 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -65,6 +65,12 @@ static void afs_async_workfn(struct work_struct *work)
 	call->async_workfn(call);
 }
 
+static int afs_wait_atomic_t(atomic_t *p)
+{
+	schedule();
+	return 0;
+}
+
 /*
  * open an RxRPC socket and bind it to be a server for callback notifications
  * - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
@@ -126,13 +132,16 @@ void afs_close_socket(void)
 {
 	_enter("");
 
+	wait_on_atomic_t(&afs_outstanding_calls, afs_wait_atomic_t,
+			 TASK_UNINTERRUPTIBLE);
+	_debug("no outstanding calls");
+	
 	sock_release(afs_socket);
 
 	_debug("dework");
 	destroy_workqueue(afs_async_calls);
 
 	ASSERTCMP(atomic_read(&afs_outstanding_skbs), ==, 0);
-	ASSERTCMP(atomic_read(&afs_outstanding_calls), ==, 0);
 	_leave("");
 }
 
@@ -178,8 +187,6 @@ static void afs_free_call(struct afs_call *call)
 {
 	_debug("DONE %p{%s} [%d]",
 	       call, call->type->name, atomic_read(&afs_outstanding_calls));
-	if (atomic_dec_return(&afs_outstanding_calls) == -1)
-		BUG();
 
 	ASSERTCMP(call->rxcall, ==, NULL);
 	ASSERT(!work_pending(&call->async_work));
@@ -188,6 +195,9 @@ static void afs_free_call(struct afs_call *call)
 
 	kfree(call->request);
 	kfree(call);
+
+	if (atomic_dec_and_test(&afs_outstanding_calls))
+		wake_up_atomic_t(&afs_outstanding_calls);
 }
 
 /*

  reply	other threads:[~2016-04-07 16:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 16:22 [PATCH 0/9] RxRPC: 2nd rewrite part 1 David Howells
2016-04-07 16:23 ` David Howells [this message]
2016-04-07 16:23 ` [PATCH 2/9] rxrpc: Disable a debugging statement that has been left enabled David Howells
2016-04-07 16:31   ` Joe Perches
2016-04-07 17:38     ` David Miller
2016-04-07 19:45     ` David Howells
2016-04-07 20:36       ` David Miller
2016-04-07 20:47       ` David Howells
2016-04-07 20:50         ` David Miller
2016-04-07 21:24         ` David Howells
2016-04-07 17:05   ` David Howells
2016-04-07 17:19     ` Joe Perches
2016-04-07 19:43     ` David Howells
2016-04-07 20:21       ` Joe Perches
2016-04-07 20:42       ` David Howells
2016-04-07 16:23 ` [PATCH 3/9] rxrpc: Move some miscellaneous bits out into their own file David Howells
2016-04-07 16:23 ` [PATCH 4/9] rxrpc: Static arrays of strings should be const char *const[] David Howells
2016-04-07 16:23 ` [PATCH 5/9] rxrpc: Differentiate local and remote abort codes in structs David Howells
2016-04-07 16:23 ` [PATCH 6/9] rxrpc: Don't pass gfp around in incoming call handling functions David Howells
2016-04-07 16:23 ` [PATCH 7/9] rxrpc: Don't assume transport address family and size when using it David Howells
2016-04-07 16:23 ` [PATCH 8/9] rxrpc: Absorb the rxkad security module David Howells
2016-04-07 16:23 ` [PATCH 9/9] rxrpc: Create a null security type and get rid of conditional calls David Howells
2016-04-11 19:35 ` [PATCH 0/9] RxRPC: 2nd rewrite part 1 David Miller
2016-04-11 20:38 ` David Howells
2016-04-11 22:01 ` David Howells
2016-04-12  1:26   ` David Miller
2016-04-11 22:29 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160407162303.21283.63145.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®