dlm: remove unnecessary error check
PATCH 1/1 dlm: remove unnecessary error check
We don't need the redundant logic since send_message always returns 0.
--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
fs/dlm/lock.c +2 -8
@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)send_args (r, lkb, ms); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:remove_from_waiters (lkb,msg_reply_type (mstype));
@@ -3763,10 +3760,7 @@ static int send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb)send_args (r, lkb, ms); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:remove_from_waiters (lkb,DLM_MSG_LOOKUP_REPLY );
Signature · 1 line
1.7.12.4
----- Original Message -----
Quoted 36 lines
We don't need the redundant logic since
send_messagealways returns 0.Signed-off-by Guoqing Jiang <[email protected]>--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/dlm/lock.c +1
-4@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:fs/dlm/lock.c +1
-4remove_from_waiters (lkb,msg_reply_type (mstype));@@ -3763,10 +3760,7 @@ static int send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:
Quoted 3 lines
remove_from_waiters(lkb, DLM_MSG_LOOKUP_REPLY);
--
1.7.12.4
Hi,
The patch looks okay, but if remove_from_waiters() always returns 0, wouldn't it be better to change the function from int to void and return 0 here? The advantage is that code spelunkers wouldn't need to back-track one more level (not to mention the instruction or two it might save).
Regards,
Bob Peterson
Red Hat File Systems
Hi Bob,
Quoted 45 lines · Bob Peterson
----- Original Message -----
Quoted 36 lines
We don't need the redundant logic since
send_messagealways returns 0.Signed-off-by Guoqing Jiang <[email protected]>--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/dlm/lock.c +1
-4@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:fs/dlm/lock.c +1
-4remove_from_waiters (lkb,msg_reply_type (mstype));@@ -3763,10 +3760,7 @@ static int send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:Quoted 4 lines
remove_from_waiters(lkb, DLM_MSG_LOOKUP_REPLY);
--
1.7.12.4Hi,
Quoted 7 lines
The patch looks okay, but if
remove_from_waiters()always returns 0, wouldn't it be better to change the function from int to void and return 0 here? The advantage is that code spelunkers wouldn't need to back-track one more level (not to mention the instruction or two it might save).
Seems remove_from_waiters is not always returns 0, the return value could be -1 or 0 which depends on _remove_from_waiters.
BTW, I found that there are no big difference between send_common and send_lookup, since the send_common can also be use to send lookup message, I guess send_lookup can be removed as well.
Thanks,
Guoqing
----- Original Message -----
Quoted 58 lines
Hi Bob,
Quoted 45 lines · Bob Peterson
----- Original Message -----
Quoted 36 lines
We don't need the redundant logic since
send_messagealways returns 0.Signed-off-by Guoqing Jiang <[email protected]>--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/dlm/lock.c +1
-4@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:fs/dlm/lock.c +1
-4remove_from_waiters (lkb,msg_reply_type (mstype));@@ -3763,10 +3760,7 @@ static int send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:Quoted 4 lines
remove_from_waiters(lkb, DLM_MSG_LOOKUP_REPLY);
--
1.7.12.4Hi,
Quoted 7 lines
The patch looks okay, but if
remove_from_waiters()always returns 0, wouldn't it be better to change the function from int to void and return 0 here? The advantage is that code spelunkers wouldn't need to back-track one more level (not to mention the instruction or two it might save).Seems
remove_from_waitersis not always returns 0, the return value could be -1 or 0 which depends on_remove_from_waiters.
Quoted 6 lines
BTW, I found that there are no big difference between
send_commonandsend_lookup, since thesend_commoncan also be use to send lookup message, I guesssend_lookupcan be removed as well.Thanks,
Guoqing
Hi Guoqing,
If remove_from_waiters can return -1, then the patch would prevent the code from calling remove_from_waiters. So the patch still doesn't look right to me.
Regards,
Bob Peterson
Red Hat File Systems
Quoted 71 lines · Bob Peterson
----- Original Message -----
Quoted 61 lines
Hi Bob,
Quoted 46 lines · Bob Peterson
----- Original Message -----
Quoted 36 lines
We don't need the redundant logic since
send_messagealways returns 0.Signed-off-by Guoqing Jiang <[email protected]>--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/dlm/lock.c +1
-4@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:fs/dlm/lock.c +1
-4remove_from_waiters (lkb,msg_reply_type (mstype));@@ -3763,10 +3760,7 @@ static int send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb)send_args (r ,lkb ,ms ); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms); fail:Quoted 5 lines
remove_from_waiters(lkb, DLM_MSG_LOOKUP_REPLY);
--
1.7.12.4Hi,
Quoted 8 lines
The patch looks okay, but if
remove_from_waiters()always returns 0, wouldn't it be better to change the function from int to void and return 0 here? The advantage is that code spelunkers wouldn't need to back-track one more level (not to mention the instruction or two it might save).Seems
remove_from_waitersis not always returns 0, the return value could be -1 or 0 which depends on_remove_from_waiters.Quoted 7 lines
BTW, I found that there are no big difference between
send_commonandsend_lookup, since thesend_commoncan also be use to send lookup message, I guesssend_lookupcan be removed as well.Thanks,
Guoqing
Quoted 7 lines
Hi Guoqing,
If
remove_from_waiterscan return -1, then the patch would prevent the code from callingremove_from_waiters. So the patch still doesn't look right to me.
Hi Bob,
The remove_from_waiters could only be invoked after failed to create_message, right?
Since send_message always returns 0, this patch doesn't touch anything about the failure
path, and it also doesn't change the original semantic.
Thanks,
Guoqing
----- Original Message -----
Quoted 24 lines
Quoted 23 lines · Bob Peterson
----- Original Message -----
Quoted 21 lines
Hi Bob,
Quoted 17 lines · Bob Peterson
----- Original Message -----
Quoted 14 lines
We don't need the redundant logic since
send_messagealways returns 0.Signed-off-by Guoqing Jiang <[email protected]>--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/dlm/lock.c +0
-0@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
fs/dlm/lock.c static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype) · line 3659
Quoted 7 lines
fs/dlm/lock.c +1
-4send_args (r, lkb, ms); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms);
Hi Guoqing,
Sorry, I was momentarily confused. I think you misunderstood what I was saying. What I meant was: Instead of doing:
+ return send_message(mh, ms);
...where send_message returns 0, it might be better to have:
static void send_message(struct dlm_mhandle *mh, struct dlm_message *ms)
{
dlm_message_out(ms);
dlm_lowcomms_commit_buffer(mh);
}...And in send_common, do (in both places):
+ send_message(mh, ms);
+ return 0;
Since it's so short, it might even be better to code send_message as a macro, or at least an "inline" function.
Regards,
Bob Peterson
Red Hat File Systems
Quoted 48 lines · Bob Peterson
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
----- Original Message -----
Quoted 14 lines
We don't need the redundant logic since
send_messagealways returns 0.Signed-off-by Guoqing Jiang <[email protected]>--- fs/dlm/lock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)fs/dlm/lock.c +0
-0@@ -3656,10 +3656,7 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/dlm/lock.c static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype) · line 3660
Quoted 8 lines
fs/dlm/lock.c +1
-4send_args (r, lkb, ms); - error =send_message (mh, ms); -if (error) - goto fail; -return 0 ; +return send_message (mh, ms);Hi Guoqing,
Sorry, I was momentarily confused. I think you misunderstood what I was saying. What I meant was: Instead of doing:
(quoted diff) +1
-0+ return send_message(mh, ms);...where
send_messagereturns 0, it might be better to have:static void
send_message(struct dlm_mhandle *mh, struct dlm_message *ms){ dlm_message_out(ms); dlm_lowcomms_commit_buffer(mh); }...And in
send_common, do (in both places):(quoted diff) +2
-0+ send_message(mh, ms); + return 0;
Quoted 4 lines
Since it's so short, it might even be better to code
send_messageas a macro, or at least an "inline" function.
Hi Bob,
Got it, thanks. It is a better solution but it is not a bug fix or similar thing, so maybe just leave it as it is.
Regards,
Guoqing
David Teigland
maintainerQuoted 5 lines · Guoqing Jiang
The
remove_from_waiterscould only be invoked after failed tocreate_message, right?
Sincesend_messagealways returns 0, this patch doesn't touch anything about the failure
path, and it also doesn't change the original semantic.
I'm not inclined to take any patches unless there's a problem identified.
Hi David,
Quoted 9 lines · David Teigland
Quoted 6 lines · Guoqing Jiang
The
remove_from_waiterscould only be invoked after failed tocreate_message, right?
Sincesend_messagealways returns 0, this patch doesn't touch anything about the failure
path, and it also doesn't change the original semantic.
Quoted 4 lines
I'm not inclined to take any patches unless there's a problem identified.
.
Do you consider take the following clean up? If yes, I will send a formal patch,
otherwise pls ignore it.
fs/dlm/lock.c +0 -0
@@ -3747,30 +3747,7 @@ static int send_bast(struct dlm_rsb *r, struct
dlm_lkb *lkb, int mode)
static int send_lookup(struct dlm_rsb *r, struct dlm_lkb *lkb) {
- struct dlm_message *ms; - struct dlm_mhandle *mh; - int to_nodeid, error;
-
- to_nodeid = dlm_dir_nodeid(r);
-
- error = add_to_waiters(lkb, DLM_MSG_LOOKUP, to_nodeid);
- if (error)
- return error;
-
- error = create_message(r, NULL, to_nodeid, DLM_MSG_LOOKUP, &ms,
&mh);
- if (error)
- goto fail;
-
- send_args(r, lkb, ms);
-
- error = send_message(mh, ms);
- if (error)
- goto fail;
- return 0;
-
- fail:
- remove_from_waiters(lkb, DLM_MSG_LOOKUP_REPLY); - return error; + return send_common(r, lkb, DLM_MSG_LOOKUP);
}
Thanks,
Guoqing
David Teigland
maintainerQuoted 2 lines · Guoqing Jiang
Do you consider take the following clean up? If yes, I will send a formal patch, otherwise pls ignore it.
On first glance, the old and new code do not appear to do the same thing, so let's leave it as it is.
Quoted 1 line
-
to_nodeid=dlm_dir_nodeid(r);
Hi David,
Quoted 12 lines · David Teigland
Quoted 3 lines · Guoqing Jiang
Do you consider take the following clean up? If yes, I will send a formal patch, otherwise pls ignore it.
On first glance, the old and new code do not appear to do the same thing, so let's leave it as it is.
Quoted 2 lines
-
to_nodeid=dlm_dir_nodeid(r);
Sorry, seems it is the only different thing, if combines previous change with below modification, then the behavior is same.
@@ -3644,7 +3644,10 @@ static int send_common(struct dlm_rsb *r, struct dlm_lkb *lkb, int mstype)
struct dlm_mhandle *mh;
int to_nodeid, error;- to_nodeid = r->res_nodeid;
+ if (mstype == DLM_MSG_LOOKUP)
+ to_nodeid = dlm_dir_nodeid(r);
+ else
+ to_nodeid = r->res_nodeid;
And for create_message, the second parameter (lkb) is not effective to create three type msgs (REQUEST/LOOKUP/REMOVE).
Thanks,
Guoqing