[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190608163326.GA6573@andrea>
Date: Sat, 8 Jun 2019 18:33:26 +0200
From: Andrea Parri <andrea.parri@...rulasolutions.com>
To: Nikolay Borisov <nborisov@...e.com>
Cc: linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
peterz@...radead.org, paulmck@...ux.ibm.com
Subject: Re: [PATCH 1/2] btrfs: Implement DRW lock
On Thu, Jun 06, 2019 at 04:52:18PM +0300, Nikolay Borisov wrote:
> A (D)ouble (R)eader (W)riter lock is a locking primitive that allows
> to have multiple readers or multiple writers but not multiple readers
> and writers holding it concurrently. The code is factored out from
> the existing open-coded locking scheme used to exclude pending
> snapshots from nocow writers and vice-versa. Current implementation
> actually favors Readers (that is snapshot creaters) to writers (nocow
> writers of the filesystem).
>
> Signed-off-by: Nikolay Borisov <nborisov@...e.com>
Interesting! Thank you for sending this over, Nikolay.
I only have a couple of nits (below) to add:
[...]
> +
> +void btrfs_drw_read_unlock(struct btrfs_drw_lock *lock)
> +{
> + /*
> + * Atomic RMW operations imply full barrier, so woken up writers
> + * are guaranteed to see the decrement
> + */
Not every atomic RMW operations imply a full barrier (as exemplified,
e.g., by the atomic_inc() in btrfs_drw_read_lock()); maybe simply
s/Atomic RMW operations imply/atomic_dec_and_test() implies/
FYI, checkpatch.pl issues a few warnings on this patch (you may want
to address some of them in the next version).
Thanks,
Andrea
> + if (atomic_dec_and_test(&lock->readers))
> + wake_up(&lock->pending_writers);
> +}
> +
> +
Powered by blists - more mailing lists