@@ -238,6 +238,24 @@ void dlm_lockspace_exit(void)
kset_unregister(dlm_kset);
}
+struct dlm_ls *dlm_find_lockspace_name(const char *lsname)
+{
+ struct dlm_ls *ls;
+
+ spin_lock_bh(&lslist_lock);
+
+ list_for_each_entry(ls, &lslist, ls_list) {
+ if (!strncmp(ls->ls_name, lsname, DLM_LOCKSPACE_LEN)) {
+ atomic_inc(&ls->ls_count);
+ goto out;
+ }
+ }
+ ls = NULL;
+ out:
+ spin_unlock_bh(&lslist_lock);
+ return ls;
+}
+
struct dlm_ls *dlm_find_lockspace_global(uint32_t id)
{
struct dlm_ls *ls;
@@ -22,6 +22,7 @@
int dlm_lockspace_init(void);
void dlm_lockspace_exit(void);
+struct dlm_ls *dlm_find_lockspace_name(const char *lsname);
struct dlm_ls *dlm_find_lockspace_global(uint32_t id);
struct dlm_ls *dlm_find_lockspace_local(void *id);
struct dlm_ls *dlm_find_lockspace_device(int minor);
A DLM lockspace can be either identified by it's unique id or name. Later patches will introduce a new netlink api that is using a unique lockspace name to identify a lockspace in the lslist. This is mostly required for sysfs functionality that is currently solved by a per lockspace kobject allocation. The new netlink api cannot simple lookup the lockspace by a container_of() call to do whatever sysfs is providing so we introduce dlm_find_lockspace_name() to offer such functionality. Signed-off-by: Alexander Aring <aahringo@redhat.com> --- fs/dlm/lockspace.c | 18 ++++++++++++++++++ fs/dlm/lockspace.h | 1 + 2 files changed, 19 insertions(+)