Skip to content

Commit b5303be

Browse files
Matthew WilcoxDominique Martinet
authored andcommitted
9p: Change p9_fid_create calling convention
Return NULL instead of ERR_PTR when we can't allocate a FID. The ENOSPC return value was getting all the way back to userspace, and that's confusing for a userspace program which isn't expecting read() to tell it there's no space left on the filesystem. The best error we can return to indicate a temporary failure caused by lack of client resources is ENOMEM. Maybe it would be better to sleep until a FID is available, but that's not a change I'm comfortable making. Link: http://lkml.kernel.org/r/20180711210225.19730-3-willy@infradead.org Signed-off-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Jun Piao <piaojun@huawei.com> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: Yiwen Jiang <jiangyiwen@huwei.com> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
1 parent 2d58f63 commit b5303be

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

‎net/9p/client.c‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,11 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
914914
p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
915915
fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL);
916916
if (!fid)
917-
return ERR_PTR(-ENOMEM);
917+
return NULL;
918918

919919
ret = p9_idpool_get(clnt->fidpool);
920-
if (ret < 0) {
921-
ret = -ENOSPC;
920+
if (ret < 0)
922921
goto error;
923-
}
924922
fid->fid = ret;
925923

926924
memset(&fid->qid, 0, sizeof(struct p9_qid));
@@ -936,7 +934,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
936934

937935
error:
938936
kfree(fid);
939-
return ERR_PTR(ret);
937+
return NULL;
940938
}
941939

942940
static void p9_fid_destroy(struct p9_fid *fid)
@@ -1138,9 +1136,8 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
11381136
p9_debug(P9_DEBUG_9P, ">>> TATTACH afid %d uname %s aname %s\n",
11391137
afid ? afid->fid : -1, uname, aname);
11401138
fid = p9_fid_create(clnt);
1141-
if (IS_ERR(fid)) {
1142-
err = PTR_ERR(fid);
1143-
fid = NULL;
1139+
if (!fid) {
1140+
err = -ENOMEM;
11441141
goto error;
11451142
}
11461143
fid->uid = n_uname;
@@ -1189,9 +1186,8 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
11891186
clnt = oldfid->clnt;
11901187
if (clone) {
11911188
fid = p9_fid_create(clnt);
1192-
if (IS_ERR(fid)) {
1193-
err = PTR_ERR(fid);
1194-
fid = NULL;
1189+
if (!fid) {
1190+
err = -ENOMEM;
11951191
goto error;
11961192
}
11971193

@@ -2019,9 +2015,8 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
20192015
err = 0;
20202016
clnt = file_fid->clnt;
20212017
attr_fid = p9_fid_create(clnt);
2022-
if (IS_ERR(attr_fid)) {
2023-
err = PTR_ERR(attr_fid);
2024-
attr_fid = NULL;
2018+
if (!attr_fid) {
2019+
err = -ENOMEM;
20252020
goto error;
20262021
}
20272022
p9_debug(P9_DEBUG_9P,

0 commit comments

Comments
 (0)