--- x/include/net/9p/client.h +++ y/include/net/9p/client.h @@ -11,6 +11,7 @@ #include #include +#include #include /* Number of requests per row */ @@ -122,6 +123,7 @@ struct p9_client { struct idr fids; struct idr reqs; + struct mutex destroy_mutex; char name[__NEW_UTS_LEN + 1]; }; --- x/net/9p/client.c +++ y/net/9p/client.c @@ -1041,6 +1041,7 @@ struct p9_client *p9_client_create(const 0, 0, P9_HDRSZ + 4, clnt->msize - (P9_HDRSZ + 4), NULL); + mutex_init(&clnt->destroy_mutex); return clnt; @@ -1058,6 +1059,7 @@ void p9_client_destroy(struct p9_client { struct p9_fid *fid; int id; + int clean; p9_debug(P9_DEBUG_MUX, "clnt %p\n", clnt); @@ -1066,9 +1068,18 @@ void p9_client_destroy(struct p9_client v9fs_put_trans(clnt->trans_mod); +again: + clean = 1; + mutex_lock(&clnt->destroy_mutex); idr_for_each_entry(&clnt->fids, fid, id) { pr_info("Found fid %d not clunked\n", fid->fid); - p9_fid_destroy(fid); + clean = 0; + break; + } + mutex_unlock(&clnt->destroy_mutex); + if (!clean) { + schedule_timeout_idle(2); + goto again; } p9_tag_cleanup(clnt); @@ -1454,7 +1465,9 @@ error: if (retries++ == 0) goto again; } else { + mutex_lock(&clnt->destroy_mutex); p9_fid_destroy(fid); + mutex_unlock(&clnt->destroy_mutex); } return err; }