Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ceph: refactor wake_up_bit() pattern of calling

The wake_up_bit() is called in ceph_async_unlink_cb(),
wake_async_create_waiters(), and ceph_finish_async_create().
It makes sense to switch on clear_bit() function, because
it makes the code much cleaner and easier to understand.
More important rework is the adding of smp_mb__after_atomic()
memory barrier after the bit modification and before
wake_up_bit() call. It can prevent potential race condition
of accessing the modified bit in other threads. Luckily,
clear_and_wake_up_bit() already implements the required
functionality pattern:

static inline void clear_and_wake_up_bit(int bit, unsigned long *word)
{
clear_bit_unlock(bit, word);
/* See wake_up_bit() for which memory barrier you need to use. */
smp_mb__after_atomic();
wake_up_bit(word, bit);
}

Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Reviewed-by: Alex Markuze <amarkuze@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Viacheslav Dubeyko and committed by
Ilya Dryomov
53db6f25 5824ccba

+3 -6
+1 -2
fs/ceph/dir.c
··· 1260 1260 spin_unlock(&fsc->async_unlink_conflict_lock); 1261 1261 1262 1262 spin_lock(&dentry->d_lock); 1263 - di->flags &= ~CEPH_DENTRY_ASYNC_UNLINK; 1264 - wake_up_bit(&di->flags, CEPH_DENTRY_ASYNC_UNLINK_BIT); 1263 + clear_and_wake_up_bit(CEPH_DENTRY_ASYNC_UNLINK_BIT, &di->flags); 1265 1264 spin_unlock(&dentry->d_lock); 1266 1265 1267 1266 synchronize_rcu();
+2 -4
fs/ceph/file.c
··· 579 579 580 580 spin_lock(&ci->i_ceph_lock); 581 581 if (ci->i_ceph_flags & CEPH_I_ASYNC_CREATE) { 582 - ci->i_ceph_flags &= ~CEPH_I_ASYNC_CREATE; 583 - wake_up_bit(&ci->i_ceph_flags, CEPH_ASYNC_CREATE_BIT); 582 + clear_and_wake_up_bit(CEPH_ASYNC_CREATE_BIT, &ci->i_ceph_flags); 584 583 585 584 if (ci->i_ceph_flags & CEPH_I_ASYNC_CHECK_CAPS) { 586 585 ci->i_ceph_flags &= ~CEPH_I_ASYNC_CHECK_CAPS; ··· 761 762 } 762 763 763 764 spin_lock(&dentry->d_lock); 764 - di->flags &= ~CEPH_DENTRY_ASYNC_CREATE; 765 - wake_up_bit(&di->flags, CEPH_DENTRY_ASYNC_CREATE_BIT); 765 + clear_and_wake_up_bit(CEPH_DENTRY_ASYNC_CREATE_BIT, &di->flags); 766 766 spin_unlock(&dentry->d_lock); 767 767 768 768 return ret;