@@ -1236,6 +1236,8 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
bool thrashing = false;
unsigned long pflags;
bool in_thrashing;
+ pgoff_t index = folio->index;
+ long timeout = 60 * HZ;
if (bit_nr == PG_locked &&
!folio_test_uptodate(folio) && folio_test_workingset(folio)) {
@@ -1305,7 +1307,14 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr,
if (signal_pending_state(state, current))
break;
- io_schedule();
+ if (timeout > 0) {
+ timeout = io_schedule_timeout(timeout);
+ if (timeout <= 0)
+ pr_warn("folio wait took too long (ix=%lx)\n",
+ index);
+ } else {
+ io_schedule();
+ }
continue;
}