Message ID | 20240515084601.3240503-3-libaokun@huaweicloud.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | cachefiles: some bugfixes and cleanups for ondemand requests | expand |
On 2024/5/15 16:45, libaokun@huaweicloud.com wrote: > From: Baokun Li <libaokun1@huawei.com> > > The err_put_fd tag is only used once, so remove it to make the code more The err_put_fd label .. Also the subject line needs to be updated too. ("C goto label") > readable. > > Signed-off-by: Baokun Li <libaokun1@huawei.com> > Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Thanks, Gao Xiang > --- > fs/cachefiles/ondemand.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c > index 4ba42f1fa3b4..fd49728d8bae 100644 > --- a/fs/cachefiles/ondemand.c > +++ b/fs/cachefiles/ondemand.c > @@ -347,7 +347,9 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, > > if (copy_to_user(_buffer, msg, n) != 0) { > ret = -EFAULT; > - goto err_put_fd; > + if (msg->opcode == CACHEFILES_OP_OPEN) > + close_fd(((struct cachefiles_open *)msg->data)->fd); > + goto error; > } > > /* CLOSE request has no reply */ > @@ -358,9 +360,6 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, > > return n; > > -err_put_fd: > - if (msg->opcode == CACHEFILES_OP_OPEN) > - close_fd(((struct cachefiles_open *)msg->data)->fd); > error: > xa_erase(&cache->reqs, id); > req->error = ret;
On 2024/5/20 10:23, Gao Xiang wrote: > > > On 2024/5/15 16:45, libaokun@huaweicloud.com wrote: >> From: Baokun Li <libaokun1@huawei.com> >> >> The err_put_fd tag is only used once, so remove it to make the code more > > The err_put_fd label .. > > Also the subject line needs to be updated too. ("C goto label") > Sorry about that, and thank you very much for the correction! I will correct "tag" to "label" in the next iteration. >> readable. >> >> Signed-off-by: Baokun Li <libaokun1@huawei.com> >> Reviewed-by: Jia Zhu <zhujia.zj@bytedance.com> > > Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> > > Thanks, > Gao Xiang Thank you very much for your review! Regards, Baokun > >> --- >> fs/cachefiles/ondemand.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c >> index 4ba42f1fa3b4..fd49728d8bae 100644 >> --- a/fs/cachefiles/ondemand.c >> +++ b/fs/cachefiles/ondemand.c >> @@ -347,7 +347,9 @@ ssize_t cachefiles_ondemand_daemon_read(struct >> cachefiles_cache *cache, >> if (copy_to_user(_buffer, msg, n) != 0) { >> ret = -EFAULT; >> - goto err_put_fd; >> + if (msg->opcode == CACHEFILES_OP_OPEN) >> + close_fd(((struct cachefiles_open *)msg->data)->fd); >> + goto error; >> } >> /* CLOSE request has no reply */ >> @@ -358,9 +360,6 @@ ssize_t cachefiles_ondemand_daemon_read(struct >> cachefiles_cache *cache, >> return n; >> -err_put_fd: >> - if (msg->opcode == CACHEFILES_OP_OPEN) >> - close_fd(((struct cachefiles_open *)msg->data)->fd); >> error: >> xa_erase(&cache->reqs, id); >> req->error = ret;
diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c index 4ba42f1fa3b4..fd49728d8bae 100644 --- a/fs/cachefiles/ondemand.c +++ b/fs/cachefiles/ondemand.c @@ -347,7 +347,9 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, if (copy_to_user(_buffer, msg, n) != 0) { ret = -EFAULT; - goto err_put_fd; + if (msg->opcode == CACHEFILES_OP_OPEN) + close_fd(((struct cachefiles_open *)msg->data)->fd); + goto error; } /* CLOSE request has no reply */ @@ -358,9 +360,6 @@ ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, return n; -err_put_fd: - if (msg->opcode == CACHEFILES_OP_OPEN) - close_fd(((struct cachefiles_open *)msg->data)->fd); error: xa_erase(&cache->reqs, id); req->error = ret;