On Wed, Mar 18, 2009 at 10:40:41PM +0200, Benny Halevy wrote: > On Mar. 18, 2009, 22:28 +0200, "J. Bruce Fields" <bfields@xxxxxxxxxxxx> wrote: > > static inline void > > put_nfs4_file(struct nfs4_file *fi) > > { > > - kref_put(&fi->fi_ref, free_nfs4_file); > > missing spin_lock(&recall_lock);? > > > > + if (atomic_dec_and_lock(&fi->fi_ref, &recall_lock)) { > > + list_del(&fi->fi_hash); > > + spin_unlock(&recall_lock); > > + iput(fi->fi_inode); > > + kmem_cache_free(file_slab, fi); > > + } > > } else { > spin_unlock(&recall_lock); > } > > or am I missing something? >From include/linux/spinlock.h: /** * atomic_dec_and_lock - lock on reaching reference count zero * @atomic: the atomic counter * @lock: the spinlock in question * * Decrements @atomic by 1. If the result is 0, returns true and locks * @lock. Returns false for all other cases. */ So it's useful for cases such as this, when a reference-counted object is reachable from some data structure visible to others, and you want to remove it from that structure on dropping the last reference (as opposed to keeping one reference for the structure itself, and requiring the object to be explicitly removed). (Unless I'm missing something else.) --b. -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html