From: NeilBrown <neilb@suse.com>
To: Oleg Drokin <oleg.drokin@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
James Simmons <jsimmons@infradead.org>,
Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [PATCH 03/11] staging: lustre: move interval_insert call from ldlm_lock to ldlm_extent
Date: Wed, 06 Jun 2018 16:05:19 +1000 [thread overview]
Message-ID: <152826511899.16761.11963878471070889487.stgit@noble> (raw)
In-Reply-To: <152826510267.16761.14361003167157833896.stgit@noble>
Moving this call results in all interval-tree handling code
being in the one file. This will simplify conversion to
use Linux interval trees.
The addition of 'struct cb' is a little ugly, but will be gone
is a subsequent patch.
Signed-off-by: NeilBrown <neilb@suse.com>
---
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 27 ++++++++++++++++++++
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 4 +++
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 17 +++----------
3 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index 2f4c305bb340..eb1a9077a514 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -192,3 +192,30 @@ void ldlm_extent_policy_local_to_wire(const union ldlm_policy_data *lpolicy,
wpolicy->l_extent.end = lpolicy->l_extent.end;
wpolicy->l_extent.gid = lpolicy->l_extent.gid;
}
+
+struct cb {
+ void *arg;
+ bool (*found)(struct ldlm_lock *lock, void *arg);
+};
+
+static enum interval_iter itree_overlap_cb(struct interval_node *in, void *arg)
+{
+ struct cb *cb = arg;
+ struct ldlm_lock *lock = container_of(in, struct ldlm_lock,
+ l_tree_node);
+
+ return cb->found(lock, cb->arg) ?
+ INTERVAL_ITER_STOP : INTERVAL_ITER_CONT;
+}
+
+void ldlm_extent_search(struct interval_node *root,
+ struct interval_node_extent *ext,
+ bool (*matches)(struct ldlm_lock *lock, void *data),
+ void *data)
+{
+ struct cb cb = {
+ .arg = data,
+ .found = matches,
+ };
+ interval_search(root, ext, itree_overlap_cb, &cb);
+}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 159de8a59cbb..756fa3d9db3c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -169,6 +169,10 @@ extern struct kmem_cache *ldlm_lock_slab;
/* ldlm_extent.c */
void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_lock *lock);
void ldlm_extent_unlink_lock(struct ldlm_lock *lock);
+void ldlm_extent_search(struct interval_node *root,
+ struct interval_node_extent *ext,
+ bool (*matches)(struct ldlm_lock *lock, void *data),
+ void *data);
/* l_lock.c */
void l_check_ns_lock(struct ldlm_namespace *ns);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 034935e06393..4213fe047073 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1053,8 +1053,9 @@ struct lock_match_data {
* \param lock test-against this lock
* \param data parameters
*/
-static bool lock_matches(struct ldlm_lock *lock, struct lock_match_data *data)
+static bool lock_matches(struct ldlm_lock *lock, void *vdata)
{
+ struct lock_match_data *data = vdata;
union ldlm_policy_data *lpol = &lock->l_policy_data;
enum ldlm_mode match;
@@ -1135,16 +1136,6 @@ static bool lock_matches(struct ldlm_lock *lock, struct lock_match_data *data)
return true;
}
-static enum interval_iter itree_overlap_cb(struct interval_node *in, void *args)
-{
- struct lock_match_data *data = args;
- struct ldlm_lock *lock = container_of(in, struct ldlm_lock,
- l_tree_node);
-
- return lock_matches(lock, data) ?
- INTERVAL_ITER_STOP : INTERVAL_ITER_CONT;
-}
-
/**
* Search for a lock with given parameters in interval trees.
*
@@ -1171,8 +1162,8 @@ static struct ldlm_lock *search_itree(struct ldlm_resource *res,
if (!(tree->lit_mode & *data->lmd_mode))
continue;
- interval_search(tree->lit_root, &ext,
- itree_overlap_cb, data);
+ ldlm_extent_search(tree->lit_root, &ext,
+ lock_matches, data);
}
return data->lmd_lock;
}
next prev parent reply other threads:[~2018-06-06 6:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 6:05 [md PATCH 00/11] staging: More lustre cleanup - particularly interval-trees NeilBrown
2018-06-06 6:05 ` [PATCH 01/11] staging: lustre: simplify use of interval-tree NeilBrown
2018-06-16 3:00 ` James Simmons
2018-06-16 22:49 ` NeilBrown
2018-07-06 1:36 ` James Simmons
2018-06-06 6:05 ` [PATCH 02/11] staging: lustre: change lock_matches() to return bool NeilBrown
2018-06-06 6:05 ` [PATCH 10/11] staging: lustre: move ldlm into ptlrpc NeilBrown
[not found] ` <alpine.LFD.2.21.1806070546210.23188@casper.infradead.org>
2018-06-07 9:48 ` NeilBrown
2018-06-07 18:21 ` [lustre-devel] " Ben Evans
2018-06-07 20:50 ` NeilBrown
2018-06-08 6:59 ` NeilBrown
2018-06-06 6:05 ` [PATCH 05/11] staging: lustre: convert ldlm extent locks to linux extent-tree NeilBrown
2018-06-06 6:05 ` [PATCH 06/11] staging: lustre: remove interval_tree NeilBrown
2018-06-06 6:05 ` [PATCH 09/11] staging: lustre: discard WIRE_ATTR NeilBrown
2018-06-14 2:38 ` James Simmons
2018-06-06 6:05 ` NeilBrown [this message]
2018-06-06 6:05 ` [PATCH 04/11] staging: lustre: convert range_lock to linux interval_trees NeilBrown
2018-06-06 6:05 ` [PATCH 07/11] staging: lustre: fold lprocfs_call_handler functionality into lnet_debugfs_* NeilBrown
2018-06-14 2:38 ` James Simmons
2018-06-06 6:05 ` [PATCH 08/11] staging: lustre: obdclass: move linux/linux-foo.c to foo.c NeilBrown
2018-06-14 2:40 ` James Simmons
2018-06-06 6:05 ` [PATCH 11/11] staging: lustre: centralize setting of subdir-ccflags-y NeilBrown
2018-06-13 21:38 ` James Simmons
2018-06-13 23:21 ` NeilBrown
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=152826511899.16761.11963878471070889487.stgit@noble \
--to=neilb@suse.com \
--cc=andreas.dilger@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
/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).