Tighten lock range error handling

If lock_range returns an error then the caller won't unlock the range.
Make sure to unlock the range if we have it locked when we get errors
that we're going to return to the caller.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-04-18 13:51:10 -07:00
parent 104bbb06a9
commit 86d3090982
+3 -3
View File
@@ -211,9 +211,6 @@ int scoutfs_lock_range_lvb(struct super_block *sb, int mode,
goto out;
if (linf->shutdown) {
/* unlocked, but we own it */
if (!list_empty(&lck->head))
unlock(held, lck);
ret = -ESHUTDOWN;
goto out;
}
@@ -231,8 +228,11 @@ int scoutfs_lock_range_lvb(struct super_block *sb, int mode,
memcpy(caller_lvb, held->fake_lvb, lvb_len);
}
}
ret = 0;
out:
if (ret < 0 && !list_empty(&lck->head))
unlock(held, lck);
return ret;
}