fscache fixes

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEqG5UsNXhtOCrfGQP+7dXa6fLC2sFAmPXvZYACgkQ+7dXa6fL
 C2vJAA//b5ApjHLzYq8rOh0aYEXaG7WAebrLOgc67TYALQFEVfXyNY6OAV+5ELbQ
 3mOyuPMnt2rQc20RmTw3LzS8qSXe1+aNR76uTyNSJ3+04p4bdzkxj7wz9uSkyato
 bCeJCwUIL/AcMv4HDlvM/+b7XvCY1tMAtnZqRLw4IXtw+6ZjPhXmf+NhLNY1iJ/2
 pL4wijtMmg/auAB6bvZlQeBelgCp+N5mqb473cuTKibYFMoe7JG2dESdC7rUqVpH
 dH1r9IHirkP0WS3eQnOqt0nhHRSvQZhtRzAszGTzBUc6knZ7GFs27JVfuJXeEmoh
 YubJjGrY3yRF3T8VK3eI44imu3/Yb66bC2+Ykk8nHs8q4PpaQ//QWfN2ff8eXtlf
 DGjRaD1abRBIPrFW2FujV4v8R7G0x0gnCrpJaoiOwn2pzwgu8XTC35MGFtd2yv19
 WAsGMyzPrdfCWieiQ3WnQNy5F5MENPrXxVemi+cPlIuSfuPy9U67san/TpfCv3t9
 hnv2BnIGcjy5xaayMHSKpO263J7PpX6vAlIXnDlurqYNNxjIbQkfAOz24Da3qHLE
 jx4vkh5R8dgLoM3LLjOwv+AbyAAudfhYBemLBt0itmQuKerYWfQ+xjsgGMETQfPe
 GrZtdEjceFpoy5yVBnFuBgv3m8q1pgWZ0LkPdKhjgFPW2bCVAgI=
 =+bON
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2023-01-30 11:58:53 -08:00
commit 22b8077d0f

View file

@ -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,
unsigned int collidee_debug_id)
{
wait_var_event_timeout(&candidate->flags,
!fscache_is_acquire_pending(candidate), 20 * HZ);
wait_on_bit_timeout(&candidate->flags, FSCACHE_VOLUME_ACQUIRE_PENDING,
TASK_UNINTERRUPTIBLE, 20 * HZ);
if (fscache_is_acquire_pending(candidate)) {
pr_notice("Potential volume collision new=%08x old=%08x",
candidate->debug_id, collidee_debug_id);
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)
fscache_end_cache_access(volume->cache,
fscache_access_acquire_volume_end);
clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags);
wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING);
clear_and_wake_up_bit(FSCACHE_VOLUME_CREATING, &volume->flags);
fscache_put_volume(volume, fscache_volume_put_create_work);
}
@ -347,8 +347,8 @@ static void fscache_wake_pending_volume(struct fscache_volume *volume,
hlist_bl_for_each_entry(cursor, p, h, hash_link) {
if (fscache_volume_same(cursor, volume)) {
fscache_see_volume(cursor, fscache_volume_see_hash_wake);
clear_bit(FSCACHE_VOLUME_ACQUIRE_PENDING, &cursor->flags);
wake_up_bit(&cursor->flags, FSCACHE_VOLUME_ACQUIRE_PENDING);
clear_and_wake_up_bit(FSCACHE_VOLUME_ACQUIRE_PENDING,
&cursor->flags);
return;
}
}