From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] btrfs: Implement DRW lock
Date: Thu, 30 Jan 2020 15:37:26 +0200 [thread overview]
Message-ID: <7c1530e7-85a0-e4c7-3ae5-770c5f9c18b2@suse.com> (raw)
In-Reply-To: <20200130125945.7383-5-nborisov@suse.com>
On 30.01.20 г. 14:59 ч., 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@suse.com>
> ---
> fs/btrfs/ctree.h | 1 +
> fs/btrfs/locking.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++
> fs/btrfs/locking.h | 21 +++++++++++
> 3 files changed, 109 insertions(+)
>
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index f90b82050d2d..908430f563fa 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -33,6 +33,7 @@
> #include "extent_map.h"
> #include "async-thread.h"
> #include "block-rsv.h"
> +#include "locking.h"
>
> struct btrfs_trans_handle;
> struct btrfs_transaction;
> diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
> index 571c4826c428..66d7d1279535 100644
> --- a/fs/btrfs/locking.c
> +++ b/fs/btrfs/locking.c
> @@ -523,3 +523,90 @@ void btrfs_unlock_up_safe(struct btrfs_path *path, int level)
> path->locks[i] = 0;
> }
> }
> +
> +int btrfs_drw_lock_init(struct btrfs_drw_lock *lock)
> +{
> + int ret;
> +
> + ret = percpu_counter_init(&lock->writers, 0, GFP_KERNEL);
> + if (ret)
> + return ret;
> +
> + atomic_set(&lock->readers, 0);
> + init_waitqueue_head(&lock->pending_readers);
> + init_waitqueue_head(&lock->pending_writers);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(btrfs_drw_lock_init);
I have the functions EXPORT_SYMBOL since I have an internal patch which
is hooking this code to locktorture. SO they can be removed.
next prev parent reply other threads:[~2020-01-30 13:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 12:59 [PATCH 0/2] Refactor snapshot vs nocow writers locking Nikolay Borisov
2020-01-30 12:59 ` [PATCH 1/2] btrfs: Implement DRW lock Nikolay Borisov
2020-01-30 13:41 ` Christoph Hellwig
2020-01-30 13:42 ` Nikolay Borisov
2020-01-30 13:43 ` Christoph Hellwig
2020-01-30 12:59 ` [PATCH 2/2] btrfs: convert snapshot/nocow exlcusion to drw lock Nikolay Borisov
2020-01-30 12:59 ` [RESEND PATCH v2 0/2] Refactor snapshot vs nocow writers locking Nikolay Borisov
2020-01-30 14:21 ` David Sterba
2020-02-21 14:51 ` David Sterba
2020-01-30 12:59 ` [PATCH v2 1/2] btrfs: Implement DRW lock Nikolay Borisov
2020-01-30 13:37 ` Nikolay Borisov [this message]
2020-01-30 14:06 ` David Sterba
2020-01-30 14:11 ` Nikolay Borisov
2020-01-30 12:59 ` [PATCH v2 2/2] btrfs: convert snapshot/nocow exlcusion to drw lock Nikolay Borisov
-- strict thread matches above, loose matches on Subject: below --
2019-07-19 8:39 [PATCH v2 0/2] Refactor snapshot vs nocow writers locking Nikolay Borisov
2019-07-19 8:39 ` [PATCH v2 1/2] btrfs: Implement DRW lock Nikolay Borisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c1530e7-85a0-e4c7-3ae5-770c5f9c18b2@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).