Commit 22b8077d authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'fscache-fixes-20230130' of...

Merge tag 'fscache-fixes-20230130' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

Pull fscache fixes from David Howells:
 "Fix two problems in fscache volume handling:

   - wake_up_bit() is incorrectly paired with wait_var_event(). The
     latter selects the waitqueue to use differently.

   - Missing barriers ordering between state bit and task state"

* tag 'fscache-fixes-20230130' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
  fscache: Use clear_and_wake_up_bit() in fscache_create_volume_work()
  fscache: Use wait_on_bit() to wait for the freeing of relinquished volume
parents 6d796c50 3288666c
...@@ -141,13 +141,14 @@ static bool fscache_is_acquire_pending(struct fscache_volume *volume) ...@@ -141,13 +141,14 @@ static bool fscache_is_acquire_pending(struct fscache_volume *volume)
static void fscache_wait_on_volume_collision(struct fscache_volume *candidate, static void fscache_wait_on_volume_collision(struct fscache_volume *candidate,
unsigned int collidee_debug_id) unsigned int collidee_debug_id)
{ {
wait_var_event_timeout(&candidate->flags, wait_on_bit_timeout(&candidate->flags, FSCACHE_VOLUME_ACQUIRE_PENDING,
!fscache_is_acquire_pending(candidate), 20 * HZ); TASK_UNINTERRUPTIBLE, 20 * HZ);
if (fscache_is_acquire_pending(candidate)) { if (fscache_is_acquire_pending(candidate)) {
pr_notice("Potential volume collision new=%08x old=%08x", pr_notice("Potential volume collision new=%08x old=%08x",
candidate->debug_id, collidee_debug_id); candidate->debug_id, collidee_debug_id);
fscache_stat(&fscache_n_volumes_collision); fscache_stat(&fscache_n_volumes_collision);
wait_var_event(&candidate->flags, !fscache_is_acquire_pending(candidate)); wait_on_bit(&candidate->flags, FSCACHE_VOLUME_ACQUIRE_PENDING,
TASK_UNINTERRUPTIBLE);
} }
} }
...@@ -279,8 +280,7 @@ static void fscache_create_volume_work(struct work_struct *work) ...@@ -279,8 +280,7 @@ static void fscache_create_volume_work(struct work_struct *work)
fscache_end_cache_access(volume->cache, fscache_end_cache_access(volume->cache,
fscache_access_acquire_volume_end); fscache_access_acquire_volume_end);
clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags); clear_and_wake_up_bit(FSCACHE_VOLUME_CREATING, &volume->flags);
wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING);
fscache_put_volume(volume, fscache_volume_put_create_work); fscache_put_volume(volume, fscache_volume_put_create_work);
} }
...@@ -347,8 +347,8 @@ static void fscache_wake_pending_volume(struct fscache_volume *volume, ...@@ -347,8 +347,8 @@ static void fscache_wake_pending_volume(struct fscache_volume *volume,
hlist_bl_for_each_entry(cursor, p, h, hash_link) { hlist_bl_for_each_entry(cursor, p, h, hash_link) {
if (fscache_volume_same(cursor, volume)) { if (fscache_volume_same(cursor, volume)) {
fscache_see_volume(cursor, fscache_volume_see_hash_wake); fscache_see_volume(cursor, fscache_volume_see_hash_wake);
clear_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &cursor->flags); clear_and_wake_up_bit(FSCACHE_VOLUME_ACQUIRE_PENDING,
wake_up_bit(&cursor->flags, FSCACHE_VOLUME_ACQUIRE_PENDING); &cursor->flags);
return; return;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment