Re: [RFC] get_write_access()/deny_write_access() withoutinode->i_lock
From: Al Viro
Date: Mon Jun 20 2011 - 09:18:26 EST
On Mon, Jun 20, 2011 at 01:47:17PM +0100, David Howells wrote:
> Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> > + for (v = atomic_read(&inode->i_writecount); v >= 0; v = v1) {
> > + v1 = atomic_cmpxchg(&inode->i_writecount, v, v + 1);
> > + if (likely(v1 == v))
> > + return 0;
> > + }
>
> You don't need to reissue the atomic_read(). atomic_cmpxchg() returns the
> current value of the memory location. Just set v to v1 before going round the
> loop again.
That's precisely what that loop is doing...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/