net/9p: Handle get_user_pages_fast return properly
Subsystems (2)
PATCH 1/1 net/9p: Handle get_user_pages_fast return properly
Use proper data type to handle get_user_pages_fast error condition. Also do not treat EFAULT error as fatal.
--- net/9p/client.c | 2 +- net/9p/trans_common.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-)
net/9p/client.c +1 -1
@@ -614,7 +614,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) err = c->trans_mod->request (c, req);if (err <0 ) { -if (err != -ERESTARTSYS ) +if (err != -ERESTARTSYS && err != -EFAULT ) c->status = Disconnected; goto reterr; }
net/9p/trans_common.c +3 -8
@@ -63,7 +63,7 @@ p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, int nr_pages, u8 rw) { uint32_t first_page_bytes = 0; -uint32_t pdata_mapped_pages; +int32_t pdata_mapped_pages;struct trans_rpage_info *rpinfo; *pdata_off = (__force size_t )req->tc->pubuf & (PAGE_SIZE -1 );
@@ -75,14 +75,9 @@ p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, rpinfo = req->tc->private; pdata_mapped_pages =get_user_pages_fast ((unsigned long )req->tc->pubuf, nr_pages, rw, &rpinfo->rp_data[0 ]); +if (pdata_mapped_pages <=0 ) +return pdata_mapped_pages; -if (pdata_mapped_pages <0 ) { -printk (KERN_ERR "get_user_pages_fast failed:%d udata:%p" -"nr_pages:%d\n" , pdata_mapped_pages, - req->tc->pubuf, nr_pages); - pdata_mapped_pages =0 ; -return -EIO ; - } rpinfo->rp_nr_pages = pdata_mapped_pages;if (*pdata_off) { *pdata_len = first_page_bytes;
Signature · 1 line
1.7.4
Quoted 14 lines · M. Mohan Kumar
Use proper data type to handle
get_user_pages_fasterror condition. Also do not treat EFAULT error as fatal.Signed-off-by M. Mohan Kumar<[email protected]>--- net/9p/client.c | 2 +- net/9p/trans_common.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-)net/9p/client.c +0
-0
net/9p/client.c p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) · line 617
Quoted 5 lines
net/9p/client.c +1
-1@@ -614,7 +614,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...) err = c->trans_mod->request (c, req);if (err<0 ) { -if (err != -ERESTARTSYS ) +if (err != -ERESTARTSYS && err != -EFAULT )
Please analyze other errors that could be returned by c->trans_mod->request() if they need any handling here.
Quoted 20 lines
net/9p/client.c +0
-0c->status = Disconnected; goto reterr; }net/9p/trans_common.c +1
-1@@ -63,7 +63,7 @@ p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, int nr_pages, u8 rw) { uint32_t first_page_bytes = 0; -uint32_t pdata_mapped_pages; +int32_t pdata_mapped_pages;struct trans_rpage_info *rpinfo; *pdata_off = (__force size_t )req->tc->pubuf& (PAGE_SIZE -1 );@@ -75,14 +75,9 @@ p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, rpinfo = req->tc->private; pdata_mapped_pages =get_user_pages_fast ((unsigned long )req->tc->pubuf, nr_pages, rw,&rpinfo->rp_data[0 ]);
net/9p/trans_common.c p9_payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, · line 85
Quoted 10 lines
net/9p/trans_common.c +2
-7+if (pdata_mapped_pages<=0 ) +return pdata_mapped_pages; -if (pdata_mapped_pages<0 ) { -printk (KERN_ERR "get_user_pages_fast failed:%d udata:%p" -"nr_pages:%d\n" , pdata_mapped_pages, - req->tc->pubuf, nr_pages); - pdata_mapped_pages =0 ; -return -EIO ; - }
I would keep the printk and return the pdata_mapped_pages inside the if condition.
Thanks,
JV
Quoted 3 lines
net/9p/trans_common.c +0
-0rpinfo->rp_nr_pages = pdata_mapped_pages;if (*pdata_off) { *pdata_len = first_page_bytes;
Quoted 7 lines · Venkateswararao Jujjuri
Review
Quoted 3 lines
(quoted diff) +1
-1- if (err != -ERESTARTSYS) + if (err != -ERESTARTSYS&& err != -EFAULT)Please analyze other errors that could be returned by
c->trans_mod->request()
if they need any handling here.
Thanks JV, but we don't need to handle other errors as of now.
I will post a V2 patch with retaining printing error message.
----
M. Mohan Kumar
Quoted 7 lines · M. Mohan Kumar
Quoted 5 lines · Venkateswararao Jujjuri
Review
Quoted 2 lines
(quoted diff) +1
-1- if (err != -ERESTARTSYS) + if (err != -ERESTARTSYS&& err != -EFAULT)Please analyze other errors that could be returned by
c->trans_mod->request()
if they need any handling here.Thanks JV, but we don't need to handle other errors as of now.
*request could also return -EIO and -ENOMEM.
As you said, may be we should leave the default behavior on these errors(suspend the channel).
Thanks,
JV
Quoted 3 lines
I will post a V2 patch with retaining printing error message.
----
M. Mohan Kumar