[PATCH] ceph: return result directly from wait_for_completion_killable()

Qianqiang Liu posted 1 patch 1 month, 1 week ago
fs/ceph/locks.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] ceph: return result directly from wait_for_completion_killable()
Posted by Qianqiang Liu 1 month, 1 week ago
Simplify the code by returning the result of
wait_for_completion_killable() directly, instead of calling it
separately and then returning 0.

No functional changes are introduced, this is a simple refactor
to streamline the code.

Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
 fs/ceph/locks.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index ebf4ac0055dd..0d48a85f5397 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -221,8 +221,7 @@ static int ceph_lock_wait_for_completion(struct ceph_mds_client *mdsc,
 	if (err && err != -ERESTARTSYS)
 		return err;
 
-	wait_for_completion_killable(&req->r_safe_completion);
-	return 0;
+	return wait_for_completion_killable(&req->r_safe_completion);
 }
 
 static int try_unlock_file(struct file *file, struct file_lock *fl)
-- 
2.39.2 (Apple Git-143)
Re: [PATCH] ceph: return result directly from wait_for_completion_killable()
Posted by Ilya Dryomov 1 month ago
On Mon, Oct 14, 2024 at 1:40 PM Qianqiang Liu <qianqiang.liu@163.com> wrote:
>
> Simplify the code by returning the result of
> wait_for_completion_killable() directly, instead of calling it
> separately and then returning 0.
>
> No functional changes are introduced, this is a simple refactor

Hi Qianqiang,

I don't think this statement is true.  If the wait is interrupted,
wait_for_completion_killable() returns -ERESTARTSYS and currently
ceph_lock_wait_for_completion() swallows it, similar to how -ERESTARTSYS
coming from ceph_mdsc_do_request() is ignored a few lines above.

Thanks,

                Ilya