Skip to content

Commit 208f3c2

Browse files
garlickericvh
authored andcommitted
net/9p: handle flushed Tclunk/Tremove
When a Tclunk or Tremove request is flushed, the fid is not freed on the server. p9_client_clunk() should retry once on interrupt, then if interrupted again, leak the fid for the duration of the connection. p9_client_remove() should call p9_client_clunk() on interrupt instead of unconditionally destroying the fid. Signed-off-by: Jim Garlick <garlick@llnl.gov> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
1 parent a314f27 commit 208f3c2

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎net/9p/client.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ int p9_client_clunk(struct p9_fid *fid)
14281428
int err;
14291429
struct p9_client *clnt;
14301430
struct p9_req_t *req;
1431+
int retries = 0;
14311432

14321433
if (!fid) {
14331434
pr_warn("%s (%d): Trying to clunk with NULL fid\n",
@@ -1436,7 +1437,9 @@ int p9_client_clunk(struct p9_fid *fid)
14361437
return 0;
14371438
}
14381439

1439-
p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d\n", fid->fid);
1440+
again:
1441+
p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d (try %d)\n", fid->fid,
1442+
retries);
14401443
err = 0;
14411444
clnt = fid->clnt;
14421445

@@ -1452,8 +1455,14 @@ int p9_client_clunk(struct p9_fid *fid)
14521455
error:
14531456
/*
14541457
* Fid is not valid even after a failed clunk
1458+
* If interrupted, retry once then give up and
1459+
* leak fid until umount.
14551460
*/
1456-
p9_fid_destroy(fid);
1461+
if (err == -ERESTARTSYS) {
1462+
if (retries++ == 0)
1463+
goto again;
1464+
} else
1465+
p9_fid_destroy(fid);
14571466
return err;
14581467
}
14591468
EXPORT_SYMBOL(p9_client_clunk);
@@ -1478,7 +1487,10 @@ int p9_client_remove(struct p9_fid *fid)
14781487

14791488
p9_free_req(clnt, req);
14801489
error:
1481-
p9_fid_destroy(fid);
1490+
if (err == -ERESTARTSYS)
1491+
p9_client_clunk(fid);
1492+
else
1493+
p9_fid_destroy(fid);
14821494
return err;
14831495
}
14841496
EXPORT_SYMBOL(p9_client_remove);

0 commit comments

Comments
 (0)