From patchwork Mon Sep 30 20:13:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 13816992 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03FEF1A2548 for ; Mon, 30 Sep 2024 20:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727727259; cv=none; b=W46t9KssUUR96x5gZlteUYxPxRkQwuo0wXSUSi1A9gHyIdLQ5sYDSiQO7Z9hpGml/Gh2ssczcRxaEF4W7AP1yQ6iGOkZa7UVo0K8gkndhv2MnACZO/Yr8EOKWkEE80BfKHpu8zttycTauF8q25+3hMztjznUYrpWHemil7MR2DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727727259; c=relaxed/simple; bh=7+E295+fTdtFYJE7SO/shAHSrnEGhOeeX5vu6OAwvNI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yr7KuQTO1i1F+WZ0dNO6UhjJuS0tkzaDpUu71Y8Wk1BD2vg9yVSqK4vKCtle4Sgte2MiPbaU6F0bTzqGXLsqbIleMVJyn4TYeg6IVdLMD5OJfnQ6T3aF0o/iUtsKHgTe4A2tXx8xcIPQKLM1JDlHw9y7f3y+5LJ+DbSmoR3EOVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZQ7fyl2j; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZQ7fyl2j" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727727255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f+k9OgWsKdKtc2JL0VLbtqiJHf8Tzgl+WMY1WPT70Ug=; b=ZQ7fyl2jC4pCKYzUky6R7IwCwTtmDwBBKLHb8110dDg7prXRGEw3/CQ79mmzxuxHvb5SZI xFRs3z/IJQZiae9GfOrYCe6LVzkg8eAYZYeS/z5ZLfpdu9l/lk0uaI0ZKiEGw+ibe6neUu FqN5bLk4epBEdWtBnr8j6ebiit+UmGY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-375-IIx2CHq2NJ2ZqCw6aEiNow-1; Mon, 30 Sep 2024 16:14:12 -0400 X-MC-Unique: IIx2CHq2NJ2ZqCw6aEiNow-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 909B3197703B; Mon, 30 Sep 2024 20:14:08 +0000 (UTC) Received: from fs-i40c-03.mgmt.fast.eng.rdu2.dc.redhat.com (unknown [10.6.24.150]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2FFB61955DC7; Mon, 30 Sep 2024 20:14:06 +0000 (UTC) From: Alexander Aring To: teigland@redhat.com Cc: gfs2@lists.linux.dev, song@kernel.org, yukuai3@huawei.com, agruenba@redhat.com, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, ocfs2-devel@lists.linux.dev, netdev@vger.kernel.org, vvidic@valentin-vidic.from.hr, heming.zhao@suse.com, lucien.xin@gmail.com, donald.hunter@gmail.com, aahringo@redhat.com Subject: [PATCHv2 dlm/next 01/12] dlm: introduce dlm_find_lockspace_name() Date: Mon, 30 Sep 2024 16:13:47 -0400 Message-ID: <20240930201358.2638665-2-aahringo@redhat.com> In-Reply-To: <20240930201358.2638665-1-aahringo@redhat.com> References: <20240930201358.2638665-1-aahringo@redhat.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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 --- fs/dlm/lockspace.c | 18 ++++++++++++++++++ fs/dlm/lockspace.h | 1 + 2 files changed, 19 insertions(+) diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index 8afac6e2dff0..00d37125bc44 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c @@ -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; diff --git a/fs/dlm/lockspace.h b/fs/dlm/lockspace.h index 47ebd4411926..7898a906aab9 100644 --- a/fs/dlm/lockspace.h +++ b/fs/dlm/lockspace.h @@ -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);