fix r324011, MFV of r323535, 8585 improve batching done in zil_commit()

I managed to commit an older version of the change.
Plus, even the latest version was not ready for userland compilation.

Reported by:	"O. Hartmann" <ohartmann@walstatt.org>,
		cy
MFC after:	1 week
X-MFC with:	r324011
This commit is contained in:
Andriy Gapon 2017-09-26 15:38:16 +00:00
parent 92e73ccc73
commit 443efc868c
2 changed files with 10 additions and 3 deletions

View File

@ -40,6 +40,9 @@
#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
#define USEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MICROSEC))
#define NSEC2USEC(n) ((n) / (NANOSEC / MICROSEC))
#define NSEC2SEC(n) ((n) / (NANOSEC / SEC))
#define SEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / SEC))

View File

@ -2283,8 +2283,13 @@ zil_commit_waiter(zilog_t *zilog, zil_commit_waiter_t *zcw)
* zil_process_commit_list() function.
*/
int pct = MAX(zfs_commit_timeout_pct, 1);
#if defined(illumos) || !defined(_KERNEL)
hrtime_t sleep = (zilog->zl_last_lwb_latency * pct) / 100;
hrtime_t wakeup = gethrtime() + sleep;
#else
sbintime_t sleep = nstosbt((zilog->zl_last_lwb_latency * pct) / 100);
sbintime_t wakeup = getsbinuptime() + sleep;
#endif
boolean_t timedout = B_FALSE;
while (!zcw->zcw_done) {
@ -2322,7 +2327,7 @@ zil_commit_waiter(zilog_t *zilog, zil_commit_waiter_t *zcw)
* timeout is reached; responsibility (2) from
* the comment above this function.
*/
#ifdef illumos
#if defined(illumos) || !defined(_KERNEL)
clock_t timeleft = cv_timedwait_hires(&zcw->zcw_cv,
&zcw->zcw_lock, wakeup, USEC2NSEC(1),
CALLOUT_FLAG_ABSOLUTE);
@ -2331,8 +2336,7 @@ zil_commit_waiter(zilog_t *zilog, zil_commit_waiter_t *zcw)
continue;
#else
int wait_err = cv_timedwait_sbt(&zcw->zcw_cv,
&zcw->zcw_lock, wakeup * SBT_1NS, SBT_1NS,
C_ABSOLUTE);
&zcw->zcw_lock, wakeup, SBT_1NS, C_ABSOLUTE);
if (wait_err != EWOULDBLOCK || zcw->zcw_done)
continue;
#endif