* stripe.
*/
atomic64_t pad_decline_uncovered;
+ atomic64_t congestion_short;
} stripe_park_stats;
/*
* Park deadlines, ms (sysfs); 0 disables parking for that class. See
*/
u32 stripe_park_timeout_ms;
u32 stripe_park_sync_timeout_ms;
+ /* Parked-rbio backlog above which parks go short; 0 = off. */
+ u32 stripe_park_congestion;
+ /* Live count of currently-parked rbios (the backlog gauge). */
+ atomic_t stripe_parked_now;
/* Private scrub information */
struct mutex scrub_lock;
{
list_del_init(&rbio->parked_node);
clear_bit(RBIO_PARKED_BIT, &rbio->flags);
+ atomic_dec(&rbio->bioc->fs_info->stripe_parked_now);
}
/* Does any bio gathered in @rbio carry a sync hint (a blocked waiter)? */
timeout_ms == sync_timeout_ms)
return false;
+ /*
+ * Park-congestion feedback: when more rbios are parked than
+ * stripe_park_congestion allows (0 = off), merges are not arriving fast
+ * enough to clear the backlog, so give this write the short sync
+ * deadline (which also skips the stuck cap). Once the backlog drains
+ * below the knob, new writes get the full deadline again.
+ */
+ {
+ unsigned int congestion =
+ READ_ONCE(fs_info->stripe_park_congestion);
+
+ if (timeout_ms != sync_timeout_ms && sync_timeout_ms != 0 &&
+ congestion &&
+ atomic_read(&fs_info->stripe_parked_now) > (int)congestion) {
+ timeout_ms = sync_timeout_ms;
+ atomic64_inc(&fs_info->stripe_park_stats.congestion_short);
+ }
+ }
+
spin_lock(&table->parked_lock);
set_bit(RBIO_PARKED_BIT, &rbio->flags);
set_bit(RBIO_WAS_PARKED_BIT, &rbio->flags);
*/
refcount_inc(&rbio->refs);
list_add_tail(&rbio->parked_node, &table->parked);
+ atomic_inc(&fs_info->stripe_parked_now);
spin_unlock(&table->parked_lock);
atomic64_inc(&fs_info->stripe_park_stats.parked);
queue_delayed_work(system_percpu_wq, &table->parked_work,
BTRFS_PARK_TIMEOUT_ATTR(stripe_park_timeout_ms, stripe_park_timeout_ms);
BTRFS_PARK_TIMEOUT_ATTR(stripe_park_sync_timeout_ms, stripe_park_sync_timeout_ms);
+BTRFS_PARK_TIMEOUT_ATTR(stripe_park_congestion, stripe_park_congestion);
BTRFS_ATTR_PTR(, stripe_park_stats),
BTRFS_ATTR_PTR(, stripe_park_timeout_ms),
BTRFS_ATTR_PTR(, stripe_park_sync_timeout_ms),
+ BTRFS_ATTR_PTR(, stripe_park_congestion),
BTRFS_ATTR_PTR(, temp_fsid),
NULL,
};