@@ -341,7 +341,8 @@ xlog_grant_head_check(
struct xlog *log,
struct xlog_grant_head *head,
struct xlog_ticket *tic,
- int *need_bytes)
+ int *need_bytes,
+ bool nowait)
{
int free_bytes;
int error = 0;
@@ -360,13 +361,15 @@ xlog_grant_head_check(
spin_lock(&head->lock);
if (!xlog_grant_head_wake(log, head, &free_bytes) ||
free_bytes < *need_bytes) {
- error = xlog_grant_head_wait(log, head, tic,
- *need_bytes);
+ error = nowait ?
+ -EAGAIN : xlog_grant_head_wait(log, head, tic,
+ *need_bytes);
}
spin_unlock(&head->lock);
} else if (free_bytes < *need_bytes) {
spin_lock(&head->lock);
- error = xlog_grant_head_wait(log, head, tic, *need_bytes);
+ error = nowait ? -EAGAIN : xlog_grant_head_wait(log, head, tic,
+ *need_bytes);
spin_unlock(&head->lock);
}
@@ -428,7 +431,7 @@ xfs_log_regrant(
trace_xfs_log_regrant(log, tic);
error = xlog_grant_head_check(log, &log->l_write_head, tic,
- &need_bytes);
+ &need_bytes, false);
if (error)
goto out_error;
@@ -487,7 +490,7 @@ xfs_log_reserve(
trace_xfs_log_reserve(log, tic);
error = xlog_grant_head_check(log, &log->l_reserve_head, tic,
- &need_bytes);
+ &need_bytes, nowait);
if (error)
goto out_error;