If the async windows size is set as zero, then the LFSCK main engine
on the MDT will pre-load objects as fast as possible. Under such case,
if the peer server(s) cannot handle the pre-load requests in time, it
will cause a lot of pre-load requests waiting on the MDT as to memory
pressure. To avoid such trouble, we will forbid to set the LFSCK async
windows size as zero or other too large (> LFSCK_ASYNC_WIN_MAX) valid.
Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I3468236a4a0705ea60b49704583b051c99c77cd5
Reviewed-on: http://review.whamcloud.com/13818
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lfsck->li_bookmark_obj = obj;
rc = lfsck_bookmark_load(env, lfsck);
lfsck->li_bookmark_obj = obj;
rc = lfsck_bookmark_load(env, lfsck);
+ if (rc == 0) {
+ struct lfsck_bookmark *mb = &lfsck->li_bookmark_ram;
+
+ /* It is upgraded from old release, set it as
+ * LFSCK_ASYNC_WIN_DEFAULT to avoid memory pressure. */
+ if (unlikely(mb->lb_async_windows == 0)) {
+ mb->lb_async_windows = LFSCK_ASYNC_WIN_DEFAULT;
+ mutex_lock(&lfsck->li_mutex);
+ rc = lfsck_bookmark_store(env, lfsck);
+ mutex_unlock(&lfsck->li_mutex);
+ }
+ } else if (rc == -ENODATA) {
rc = lfsck_bookmark_init(env, lfsck);
rc = lfsck_bookmark_init(env, lfsck);
}
if (start->ls_valid & LSV_ASYNC_WINDOWS) {
}
if (start->ls_valid & LSV_ASYNC_WINDOWS) {
+ if (start->ls_async_windows < 1 ||
+ start->ls_async_windows > LFSCK_ASYNC_WIN_MAX)
+ return -EINVAL;
+
if (bk->lb_async_windows != start->ls_async_windows) {
bk->lb_async_windows = start->ls_async_windows;
dirty = true;
if (bk->lb_async_windows != start->ls_async_windows) {
bk->lb_async_windows = start->ls_async_windows;
dirty = true;
/* Wake up the main engine thread only when the list
* is empty or half of the prefetched items have been
* handled to avoid too frequent thread schedule. */
/* Wake up the main engine thread only when the list
* is empty or half of the prefetched items have been
* handled to avoid too frequent thread schedule. */
- if (lad->lad_prefetched == 0 ||
- (bk->lb_async_windows != 0 &&
- bk->lb_async_windows / 2 ==
- lad->lad_prefetched))
+ if (lad->lad_prefetched <= (bk->lb_async_windows / 2))
wakeup = true;
spin_unlock(&lad->lad_lock);
if (wakeup)
wakeup = true;
spin_unlock(&lad->lad_lock);
if (wakeup)
continue;
l_wait_event(mthread->t_ctl_waitq,
continue;
l_wait_event(mthread->t_ctl_waitq,
- bk->lb_async_windows == 0 ||
lad->lad_prefetched < bk->lb_async_windows ||
!thread_is_running(mthread) ||
thread_is_stopped(athread),
lad->lad_prefetched < bk->lb_async_windows ||
!thread_is_running(mthread) ||
thread_is_stopped(athread),
lfsck = lfsck_instance_find(key, true, false);
if (likely(lfsck != NULL)) {
lfsck = lfsck_instance_find(key, true, false);
if (likely(lfsck != NULL)) {
- if (val > LFSCK_ASYNC_WIN_MAX) {
- CWARN("%s: Too large async window size, which "
- "may cause memory issues. The valid range "
- "is [0 - %u]. If you do not want to restrict "
- "the window size for async requests pipeline, "
- "just set it as 0.\n",
+ if (val < 1 || val > LFSCK_ASYNC_WIN_MAX) {
+ CWARN("%s: invalid async windows size that may "
+ "cause memory issues. The valid range is "
+ "[1 - %u].\n",
lfsck_lfsck2name(lfsck), LFSCK_ASYNC_WIN_MAX);
rc = -EINVAL;
} else if (lfsck->li_bookmark_ram.lb_async_windows != val) {
lfsck_lfsck2name(lfsck), LFSCK_ASYNC_WIN_MAX);
rc = -EINVAL;
} else if (lfsck->li_bookmark_ram.lb_async_windows != val) {
bool wakeup = false;
l_wait_event(mthread->t_ctl_waitq,
bool wakeup = false;
l_wait_event(mthread->t_ctl_waitq,
- bk->lb_async_windows == 0 ||
lad->lad_prefetched < bk->lb_async_windows ||
!thread_is_running(mthread) ||
thread_is_stopped(athread),
lad->lad_prefetched < bk->lb_async_windows ||
!thread_is_running(mthread) ||
thread_is_stopped(athread),
}
case 'w':
val = atoi(optarg);
}
case 'w':
val = atoi(optarg);
- if (val < 0 || val > LFSCK_ASYNC_WIN_MAX) {
+ if (val < 1 || val > LFSCK_ASYNC_WIN_MAX) {
- "Too large async window size, "
- "which may cause memory issues. "
- "The valid range is [0 - %u]. "
- "If you do not want to restrict "
- "the window size for async reqeusts "
- "pipeline, just set it as 0.\n",
+ "Invalid async window size that "
+ "may cause memory issues. The valid "
+ "range is [1 - %u].\n",
LFSCK_ASYNC_WIN_MAX);
return -EINVAL;
}
LFSCK_ASYNC_WIN_MAX);
return -EINVAL;
}