public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails
@ 2014-03-14 23:49 Rakesh Pandit
  2014-03-15  0:29 ` Rakesh Pandit
  0 siblings, 1 reply; 3+ messages in thread
From: Rakesh Pandit @ 2014-03-14 23:49 UTC (permalink / raw)
  To: linux-btrfs

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

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
---
 cmds-scrub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmds-scrub.c b/cmds-scrub.c
index 128537b..ca11fb5 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -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;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails
  2014-03-14 23:49 [PATCH] Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails Rakesh Pandit
@ 2014-03-15  0:29 ` Rakesh Pandit
  2014-03-17 12:44   ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Rakesh Pandit @ 2014-03-15  0:29 UTC (permalink / raw)
  To: linux-btrfs

Hi,

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

On Sat, Mar 15, 2014 at 01:49:45AM +0200, Rakesh Pandit wrote:
> 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.
 
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>

regards,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails
  2014-03-15  0:29 ` Rakesh Pandit
@ 2014-03-17 12:44   ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2014-03-17 12:44 UTC (permalink / raw)
  To: Rakesh Pandit; +Cc: linux-btrfs

On Sat, Mar 15, 2014 at 02:29:33AM +0200, Rakesh Pandit wrote:
> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-17 12:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-14 23:49 [PATCH] Btrfs-progs: scrub: don't call unlock if pthread_mutex_lock fails Rakesh Pandit
2014-03-15  0:29 ` Rakesh Pandit
2014-03-17 12:44   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox