Skip to contentSkip to conversation

Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails

PATCH In review Rakesh Pandit 2 participants 3 messages Mar 14, 2014 – Mar 17, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails

If pthread_mutex_lock fails (rare but fix it anyway), don't call pthread_mutex_unlock on mutex.

---
 cmds-scrub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
cmds-scrub.c +2 -1
index 128537b..ca11fb5 100644
@@ -776,7 +776,7 @@ static int scrub_write_progress(pthread_mutex_t *m, const char *fsid,
 	ret = pthread_mutex_lock(m);
 	if (ret) {
 		err = -ret;
-		goto out;
+		goto fail;
 	}
 
 	ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
@@ -808,6 +808,7 @@ out:
 	if (ret && !err)
 		err = -ret;
 
+fail:
 	ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old);
 	if (ret && !err)
 		err = -ret;
Signature · 1 line
1.8.5.3
#1 lore raw

Hi,

Forgot to mention the reason for change. If accepted this can be included in commit message:

Quoted 3 lines · Rakesh Pandit

If pthread_mutex_lock fails (rare but fix it anyway), don't call pthread_mutex_unlock on mutex.

Rationale being that if pthread_mutex_lock fails pthread_mutex_unlock will always fail and overwrite actual error value in err.

Quoted 1 line

regards,

#2 lore raw
Quoted 5 lines · Rakesh Pandit

Forgot to mention the reason for change. If accepted this can be included in commit message:

Rationale being that if pthread_mutex_lock fails pthread_mutex_unlock will always fail and overwrite actual error value in err.

Thanks, updated.