From patchwork Fri Oct 7 12:48:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 13001076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 477D1C433F5 for ; Fri, 7 Oct 2022 12:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=bSiUE7PfnYYITexc1reF3QI0wqDNYYJ0AAZDTTLwQUs=; b=Vz+2NB0M67w3L9sxo8z/KT4kTDnExjRnKcq0Qd7VPQQkcyYGAk7idE0wb5pTGWIWtnG36tEkRlg5 g12+Qco8OKuuMM9b12z8Nm7ZbRQJEchqC8+z4ghI0q7kBFNeCKB6+HEPbuHtqnvD2y1SG2U/jygk dIjVHNCW7CnKwAbmDDJQ4NEK0ZcTaZWDtaKRUvO5OzodDOIU1YtIh/wF4XLTPmZYaTOpV+ar0bhG syDatsfTfNbfMzcv4i99uasDcIE0u3upFoVM2b94lnWh/h68M6714JZVi5tHHxIX2+KF1OeuzO3M 1hfLQp/xJ8hpd7CP1O47jbcBQ7feh3HVQpy/ZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=bSiUE7PfnYYITexc1reF3QI0wqDNYYJ0AAZDTTLwQUs=; b=hnRTlVyPi8I3lPx8ff92gvqiJF0cZp0MDYC9bzO8/iP1jL5BySZniU20Uz/8VbOeWz98QbH+VA0D z5QvOPBV+bXeBVwV1l+P1AHwg9NDzkaDVdU3MItLxmnkISLrhm9ZvbH6Wnf6zZwuDkbXR4JYdZCP M7+RwAgndDoR826iAwZ9pwltexpJxNxfF5ZtQsJDaDylYELUFEegq5TBt34i7zqPYXZtl3KTTfiI GLbmB0K4KYIicMyOWtANN1KencrTJq/5X7H0KdsO8CM2ir+yCohufsMCp2akOkcoZPQoCR9zWGmB ZyohX23WKgtqWoOM6Uvjor5Y8QFs5kZ9IUebNw== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RJD008J9VLTD770@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 07 Oct 2022 12:49:05 +0000 (GMT) To: ocfs2-devel@oss.oracle.com Date: Fri, 7 Oct 2022 20:48:44 +0800 Message-id: <20221007124846.186453-1-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 MIME-version: 1.0 X-Source-IP: 115.124.30.57 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10492 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 adultscore=0 impostorscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=82 mlxlogscore=999 mlxscore=0 priorityscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210070076 domainage_hfrom=8576 Subject: [Ocfs2-devel] [PATCH 1/3] ocfs2/cluster: use bitmap API instead of hand-writing it X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Joseph Qi via Ocfs2-devel Reply-to: Joseph Qi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R501e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046051; MF=joseph.qi@linux.alibaba.com; NM=1; PH=DS; RN=2; SR=0; TI=SMTPD_---0VRUAmEQ_1665146926; X-ServerName: out30-57.freemail.mail.aliyun.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf1.service.alibaba.com include:spf2.service.alibaba.com include:spf1.ocm.aliyun.com include:spf2.ocm.aliyun.com include:spf1.staff.mail.aliyun.com include:a.hichina.mail.aliyun.com include:b.hichina.mail.aliyun.com -all X-Spam: Clean X-Proofpoint-GUID: QMyBptIG9WK-doRFUMn_8TMI2V9n6M37 X-Proofpoint-ORIG-GUID: QMyBptIG9WK-doRFUMn_8TMI2V9n6M37 Reporting-Meta: AAF43HHTOW51WquGRJJJmw08DrJvt1I+FT/W5EI7EGe1DMT0CzQHoQ+/zLVTCDBn EwemfYEYqmemPbeR6igtwtjsrVZWE7X8Ap88qrZkhQxjD6jHcBOx0kdCw+NmjRH1 TltMzlV+l2amXcVkrS5yVcHiY7ij2VRI7kDmsD7vrKczGf/gp1Q/c6s6K4hHTIRj mVUF0MJVSijm9A5HjZAvZ9CQcY2rwshPMKLOTDH0N/XIHpRDmv/NCda+JgPihOC3 bVvOLc4RGLUqzLoAlENopIsmlyQMId2aDjk2KyVFwsFZVgz7sUAQ5voLj8lMmTxC jnU07OoybNbr6mDz9DLnVNjCHXzt+zbPpgBIE0uW7XpEpI8ll2q4LYB37OVYIGbm O9fMpigJjbOBVuTNZ5k2vgUQ/DieegEYwcX/pwIyvgKhwXmwH1m1aqWEn8XkzR6k aCbR34ZErLcFq0K/8P+pa8yO6CmHVsy3YNkn9JDaZlECDGL9BuGCONSZdThWc+o1 WoZCgA9kuZjaC/m3MwypsjNMmhLM1oZW5k263QhkA7D0 Use bitmap_zero/bitmap_copy/bitmap_equal directly for bitmap operations. Signed-off-by: Joseph Qi --- fs/ocfs2/cluster/heartbeat.c | 20 ++++++++++---------- fs/ocfs2/cluster/nodemanager.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index b13d344d40b6..8fe6031f60e3 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -335,7 +335,7 @@ static void o2hb_arm_timeout(struct o2hb_region *reg) /* negotiate timeout must be less than write timeout. */ schedule_delayed_work(®->hr_nego_timeout_work, msecs_to_jiffies(O2HB_NEGO_TIMEOUT_MS)); - memset(reg->hr_nego_node_bitmap, 0, sizeof(reg->hr_nego_node_bitmap)); + bitmap_zero(reg->hr_nego_node_bitmap, O2NM_MAX_NODES); } static void o2hb_disarm_timeout(struct o2hb_region *reg) @@ -386,8 +386,8 @@ static void o2hb_nego_timeout(struct work_struct *work) config_item_name(®->hr_item), reg->hr_bdev); set_bit(master_node, reg->hr_nego_node_bitmap); } - if (memcmp(reg->hr_nego_node_bitmap, live_node_bitmap, - sizeof(reg->hr_nego_node_bitmap))) { + if (!bitmap_equal(reg->hr_nego_node_bitmap, live_node_bitmap, + O2NM_MAX_NODES)) { /* check negotiate bitmap every second to do timeout * approve decision. */ @@ -856,8 +856,8 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg) * live nodes heartbeat on it. In other words, the region has been * added to all nodes. */ - if (memcmp(reg->hr_live_node_bitmap, o2hb_live_node_bitmap, - sizeof(o2hb_live_node_bitmap))) + if (!bitmap_equal(reg->hr_live_node_bitmap, o2hb_live_node_bitmap, + O2NM_MAX_NODES)) goto unlock; printk(KERN_NOTICE "o2hb: Region %s (%pg) is now a quorum device\n", @@ -1437,11 +1437,11 @@ void o2hb_init(void) for (i = 0; i < ARRAY_SIZE(o2hb_live_slots); i++) INIT_LIST_HEAD(&o2hb_live_slots[i]); - memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); - memset(o2hb_region_bitmap, 0, sizeof(o2hb_region_bitmap)); - memset(o2hb_live_region_bitmap, 0, sizeof(o2hb_live_region_bitmap)); - memset(o2hb_quorum_region_bitmap, 0, sizeof(o2hb_quorum_region_bitmap)); - memset(o2hb_failed_region_bitmap, 0, sizeof(o2hb_failed_region_bitmap)); + bitmap_zero(o2hb_live_node_bitmap, O2NM_MAX_NODES); + bitmap_zero(o2hb_region_bitmap, O2NM_MAX_REGIONS); + bitmap_zero(o2hb_live_region_bitmap, O2NM_MAX_REGIONS); + bitmap_zero(o2hb_quorum_region_bitmap, O2NM_MAX_REGIONS); + bitmap_zero(o2hb_failed_region_bitmap, O2NM_MAX_REGIONS); o2hb_dependent_users = 0; diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 27fee68f860a..2f61d39e4e50 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -54,7 +54,7 @@ int o2nm_configured_node_map(unsigned long *map, unsigned bytes) return -EINVAL; read_lock(&cluster->cl_nodes_lock); - memcpy(map, cluster->cl_nodes_bitmap, sizeof(cluster->cl_nodes_bitmap)); + bitmap_copy(map, cluster->cl_nodes_bitmap, O2NM_MAX_NODES); read_unlock(&cluster->cl_nodes_lock); return 0; From patchwork Fri Oct 7 12:48:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 13001078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc254.phx1.oracleemaildelivery.com (aib29ajc254.phx1.oracleemaildelivery.com [192.29.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62BADC433FE for ; Fri, 7 Oct 2022 12:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=/xjAf5LvuDdaEAljC78kyfM3aZtzZHIv76KCcJH/j34=; b=meXnntILUCsQxZ95+QXDbD0YCYGJxdGEIpu46/Ibb36i9MvhFBdn7yLH7C4geksSY8ogVX3XViwD tAKzgLoJinQ9SH0onCDBv0fldSjELIWKh0lmh5nmEtxw3sH9R2mJfwrOTweDj44LXNiPlezKmFiM ZCLCnrKNGyKY7ypC1cmzfImItbbGPt7O1sglLYhZ90karVaGoBbb9vLhqHUbaekVHibJSXHpW6hh 3hP8RwqxTfWy811dXF6biqGgiBqUR6GpmwHHSKg/LZlDNZkAEkAiyTVvETV/121NsvBOE2VZDP+F mK5aXy+ArMPdnGf3dXA6PWkAXzR5kxt0Thp2MA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=/xjAf5LvuDdaEAljC78kyfM3aZtzZHIv76KCcJH/j34=; b=meLXQJ1IW8FRvLv9QK0c+5ko1cEJI4iNJih5L/Y4F/B2em+jIl4JMYOkeQbxWAni8ZuBxqK1SmS7 Lp/gKCNWEwJYv2/w0dy1pfqGY9evRYLFr1uFWea8oTjqrV/chovFTNThHe8PrV3sAmr3LiXGMay2 vIJWKGYbmHZ8hPg50acg+ap9eKHbwUDwLxQjAWIE8yHiyfiJqD9dfr8ei25xw8jevKbidZyMQl3E XGibA/jfOqJ7AaaahlR07+84hm35/aoXHiaWRNfnxQVbBEZI+CQuY5VE7bFKVM1ougRiPlPfMF1i N3OM9dlwOxqaCvh8zIHYiZEGxgxUjZvAfSQykw== Received: by omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RJD009M8VMSS0D0@omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 07 Oct 2022 12:49:40 +0000 (GMT) To: ocfs2-devel@oss.oracle.com Date: Fri, 7 Oct 2022 20:48:45 +0800 Message-id: <20221007124846.186453-2-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-reply-to: <20221007124846.186453-1-joseph.qi@linux.alibaba.com> References: <20221007124846.186453-1-joseph.qi@linux.alibaba.com> MIME-version: 1.0 X-Source-IP: 115.124.30.43 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10492 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 mlxlogscore=999 impostorscore=0 malwarescore=0 suspectscore=0 mlxscore=0 clxscore=197 phishscore=0 priorityscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210070076 domainage_hfrom=8576 Subject: [Ocfs2-devel] [PATCH 2/3] ocfs2: use bitmap API in fill_node_map X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Joseph Qi via Ocfs2-devel Reply-to: Joseph Qi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R131e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=joseph.qi@linux.alibaba.com; NM=1; PH=DS; RN=2; SR=0; TI=SMTPD_---0VRUAmF9_1665146928; X-ServerName: out30-43.freemail.mail.aliyun.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf1.service.alibaba.com include:spf2.service.alibaba.com include:spf1.ocm.aliyun.com include:spf2.ocm.aliyun.com include:spf1.staff.mail.aliyun.com include:a.hichina.mail.aliyun.com include:b.hichina.mail.aliyun.com -all X-Spam: Clean X-Proofpoint-GUID: OBzqEYfssV0M5Aq7NzeoDen5rowQPl8h X-Proofpoint-ORIG-GUID: OBzqEYfssV0M5Aq7NzeoDen5rowQPl8h Reporting-Meta: AAHD0N/HQaeefYi33kgKCwuU+qCbEuZw21pIpR0j4SokOwNKC2pLwnFbXl0q5YmW FiSuS5SdQq7pfhdJzYSFPyKKubxi8b5yTSH6qeTOxWJhUQ2NUkM0zSWY4gSDSq72 dWud4QJte1GTku8enmbEH/6y+8v2tA1onThpSelHD/hsOaS2f449bIQtaXqvg03X KHKSOHOq25yKlO0iMunVRfma/iH/o/JxbkkqM/TzvYlvzd4kREunpJ3GcBD69VxI ixoqdeqGvQOi4HBGqoro37YiRkeEdWq2lIS9YpZJN7hgGtoD6W5+cA0jlWedmwKi ANhQokSmrMH4RQXRbWkrZLK9+P/F/jVjy/aMBR9jD87C0eWLI6yS3H93oSzHL5aT 1NcXPyz22/MtajCKUev10DMLWxJ2e8AAQUgqcqBIpxhta5lDwoE3JoS0k6oi7I6t eZfrWNdsJxnScR8vtjKB7JmqcOMxAsUvmHFg46Hy1no2PhsD88blfvxw7eQFo82W ZpqVU6r12GXRHA/AG7f4men87V4woWg47gFMCPPKP6mCow== Pass bits directly into fill_node_map helper and use bitmap API directly to simplify code. Signed-off-by: Joseph Qi --- fs/ocfs2/cluster/heartbeat.c | 18 ++++++++---------- fs/ocfs2/cluster/heartbeat.h | 2 +- fs/ocfs2/cluster/netdebug.c | 2 +- fs/ocfs2/cluster/tcp.c | 6 ++---- fs/ocfs2/dlm/dlmdomain.c | 2 +- fs/ocfs2/stack_o2cb.c | 6 +++--- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 8fe6031f60e3..60b97c92e2b2 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -375,7 +375,7 @@ static void o2hb_nego_timeout(struct work_struct *work) if (reg->hr_last_hb_status) return; - o2hb_fill_node_map(live_node_bitmap, sizeof(live_node_bitmap)); + o2hb_fill_node_map(live_node_bitmap, O2NM_MAX_NODES); /* lowest node as master node to make negotiate decision. */ master_node = find_first_bit(live_node_bitmap, O2NM_MAX_NODES); @@ -1087,7 +1087,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) * If a node is not configured but is in the livemap, we still need * to read the slot so as to be able to remove it from the livemap. */ - o2hb_fill_node_map(live_node_bitmap, sizeof(live_node_bitmap)); + o2hb_fill_node_map(live_node_bitmap, O2NM_MAX_NODES); i = -1; while ((i = find_next_bit(live_node_bitmap, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) { @@ -1450,23 +1450,21 @@ void o2hb_init(void) /* if we're already in a callback then we're already serialized by the sem */ static void o2hb_fill_node_map_from_callback(unsigned long *map, - unsigned bytes) + unsigned int bits) { - BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long))); - - memcpy(map, &o2hb_live_node_bitmap, bytes); + bitmap_copy(map, o2hb_live_node_bitmap, bits); } /* * get a map of all nodes that are heartbeating in any regions */ -void o2hb_fill_node_map(unsigned long *map, unsigned bytes) +void o2hb_fill_node_map(unsigned long *map, unsigned int bits) { /* callers want to serialize this map and callbacks so that they * can trust that they don't miss nodes coming to the party */ down_read(&o2hb_callback_sem); spin_lock(&o2hb_live_lock); - o2hb_fill_node_map_from_callback(map, bytes); + o2hb_fill_node_map_from_callback(map, bits); spin_unlock(&o2hb_live_lock); up_read(&o2hb_callback_sem); } @@ -2460,7 +2458,7 @@ int o2hb_check_node_heartbeating_no_sem(u8 node_num) unsigned long testing_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; spin_lock(&o2hb_live_lock); - o2hb_fill_node_map_from_callback(testing_map, sizeof(testing_map)); + o2hb_fill_node_map_from_callback(testing_map, O2NM_MAX_NODES); spin_unlock(&o2hb_live_lock); if (!test_bit(node_num, testing_map)) { mlog(ML_HEARTBEAT, @@ -2477,7 +2475,7 @@ int o2hb_check_node_heartbeating_from_callback(u8 node_num) { unsigned long testing_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; - o2hb_fill_node_map_from_callback(testing_map, sizeof(testing_map)); + o2hb_fill_node_map_from_callback(testing_map, O2NM_MAX_NODES); if (!test_bit(node_num, testing_map)) { mlog(ML_HEARTBEAT, "node (%u) does not have heartbeating enabled.\n", diff --git a/fs/ocfs2/cluster/heartbeat.h b/fs/ocfs2/cluster/heartbeat.h index 1d4100abf6f8..8ef8c1b9eeb7 100644 --- a/fs/ocfs2/cluster/heartbeat.h +++ b/fs/ocfs2/cluster/heartbeat.h @@ -59,7 +59,7 @@ int o2hb_register_callback(const char *region_uuid, void o2hb_unregister_callback(const char *region_uuid, struct o2hb_callback_func *hc); void o2hb_fill_node_map(unsigned long *map, - unsigned bytes); + unsigned int bits); void o2hb_exit(void); void o2hb_init(void); int o2hb_check_node_heartbeating_no_sem(u8 node_num); diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c index 7524994e3199..35c05c18de59 100644 --- a/fs/ocfs2/cluster/netdebug.c +++ b/fs/ocfs2/cluster/netdebug.c @@ -438,7 +438,7 @@ static int o2net_fill_bitmap(char *buf, int len) unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)]; int i = -1, out = 0; - o2net_fill_node_map(map, sizeof(map)); + o2net_fill_node_map(map, O2NM_MAX_NODES); while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i); diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index f660c0dbdb63..6f5a3fb97c7f 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -990,14 +990,12 @@ static int o2net_tx_can_proceed(struct o2net_node *nn, } /* Get a map of all nodes to which this node is currently connected to */ -void o2net_fill_node_map(unsigned long *map, unsigned bytes) +void o2net_fill_node_map(unsigned long *map, unsigned int bits) { struct o2net_sock_container *sc; int node, ret; - BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long))); - - memset(map, 0, bytes); + bitmap_zero(map, bits); for (node = 0; node < O2NM_MAX_NODES; ++node) { if (!o2net_tx_can_proceed(o2net_nn_from_num(node), &sc, &ret)) continue; diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index c4eccd499db8..f46941ff665d 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -1604,7 +1604,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) /* group sem locking should work for us here -- we're already * registered for heartbeat events so filling this should be * atomic wrt getting those handlers called. */ - o2hb_fill_node_map(dlm->live_nodes_map, sizeof(dlm->live_nodes_map)); + o2hb_fill_node_map(dlm->live_nodes_map, O2NM_MAX_NODES); spin_lock(&dlm->spinlock); memcpy(ctxt->live_map, dlm->live_nodes_map, sizeof(ctxt->live_map)); diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index 88f75f7f02d7..c973c03f6fd8 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c @@ -273,17 +273,17 @@ static int o2cb_cluster_check(void) */ #define O2CB_MAP_STABILIZE_COUNT 60 for (i = 0; i < O2CB_MAP_STABILIZE_COUNT; ++i) { - o2hb_fill_node_map(hbmap, sizeof(hbmap)); + o2hb_fill_node_map(hbmap, O2NM_MAX_NODES); if (!test_bit(node_num, hbmap)) { printk(KERN_ERR "o2cb: %s heartbeat has not been " "started.\n", (o2hb_global_heartbeat_active() ? "Global" : "Local")); return -EINVAL; } - o2net_fill_node_map(netmap, sizeof(netmap)); + o2net_fill_node_map(netmap, O2NM_MAX_NODES); /* Force set the current node to allow easy compare */ set_bit(node_num, netmap); - if (!memcmp(hbmap, netmap, sizeof(hbmap))) + if (bitmap_equal(hbmap, netmap, O2NM_MAX_NODES)) return 0; if (i < O2CB_MAP_STABILIZE_COUNT - 1) msleep(1000); From patchwork Fri Oct 7 12:48:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Qi X-Patchwork-Id: 13001077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aib29ajc249.phx1.oracleemaildelivery.com (aib29ajc249.phx1.oracleemaildelivery.com [192.29.103.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 345C9C4332F for ; Fri, 7 Oct 2022 12:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=rfPYfrTyq2E0RB0mpNybjnqvid9La0/rY1gY7BUupFI=; b=mrKrBe75PCpeTgRhTTzyH2OWtV3EM4ZWN5tC9oqkJowhzCE/TIc/Iy95J8YHfH6Fg2iP8f+NgAcg wBIyRxqnm2Jz0lz7bpFcwuzfT3AQxP0icZLQhZ+RQ5YpFNfkDJUS1lQ3TUraSsEF/ElYd6zqQHBk Rvnm5EiC4mPcEzTuGlx+a5OE3WdH+8xckAkoQMH0734HtFcQ2vdoGydYuqrWS/L3aWN54m8y8zny DiRYc1dxZoyp5rvtekfigRzrSHvLlmkjFvUwDImaawRSkMvaS6UZOTnVuIjstYIVsBy2/O5BTSwv 62ZAhV+zhq/dbMpDl9DDmueTyejHJ3Pm3y0IUw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=rfPYfrTyq2E0RB0mpNybjnqvid9La0/rY1gY7BUupFI=; b=rjpGSRLH3jYPe4PaW+9RWGznMe5Zv1kemCParawy58TJHuwx+yWVxQtinzgRPHU9jpWHZAnfaTV0 9Wc7B+z0rN36SAY5fuH++EjTNkzDuwp94ZS35/tL2CbRi5x/6tziEkBSys7K374W1ee/7QGSq2eo 5v1zWMaX9tjC1ntNczk4gnE+9F4T1dwKZ1Y7mS1TbinWD/gcY2SZylC0Auhx2CNngYn0qBX3cnWs 52vQC7qWtolDIlNtlo4UVu3Htz8sJSk9RxVSGhhlM0RKY0hBwF5xpk/cNLWDW1ICz7ZlC+JtH/h6 PiIbfg4maqK9TJvv55GXeBZqlujCklnQiupJpg== Received: by omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20220914 64bit (built Sep 14 2022)) with ESMTPS id <0RJD007RSVLU23A0@omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Fri, 07 Oct 2022 12:49:06 +0000 (GMT) To: ocfs2-devel@oss.oracle.com Date: Fri, 7 Oct 2022 20:48:46 +0800 Message-id: <20221007124846.186453-3-joseph.qi@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-reply-to: <20221007124846.186453-1-joseph.qi@linux.alibaba.com> References: <20221007124846.186453-1-joseph.qi@linux.alibaba.com> MIME-version: 1.0 X-Source-IP: 115.124.30.131 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10492 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=834 clxscore=-63 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210070076 domainage_hfrom=8576 Subject: [Ocfs2-devel] [PATCH 3/3] ocfs2/dlm: use bitmap API instead of hand-writing it X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Joseph Qi via Ocfs2-devel Reply-to: Joseph Qi Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R161e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=joseph.qi@linux.alibaba.com; NM=1; PH=DS; RN=2; SR=0; TI=SMTPD_---0VRU9Gyx_1665146929; X-ServerName: out30-131.freemail.mail.aliyun.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf1.service.alibaba.com include:spf2.service.alibaba.com include:spf1.ocm.aliyun.com include:spf2.ocm.aliyun.com include:spf1.staff.mail.aliyun.com include:a.hichina.mail.aliyun.com include:b.hichina.mail.aliyun.com -all X-Spam: Clean X-Proofpoint-GUID: RLJF27xgIbmkq6MDk5Epf5A25qClF0-0 X-Proofpoint-ORIG-GUID: RLJF27xgIbmkq6MDk5Epf5A25qClF0-0 Reporting-Meta: AAFa6ZkpaR9wi/DgGjfXimn9M9ojUDrir1qTPYISZNUA1v0EiSoxxowfgiyQvSCn VF14ztzAqx31YzB09PBvm/FzdqFPzjfEb/ml7MtORj0bV9AfaPqEzgNSVq4lJ/eI 4qPteWQxzRLHNDThKB/6TUkpacN4kY8PZ3qzOA2mPPN2Jb6QCQHijA2vVk6v0xZ6 FLiaZeArqCLwF6le9W3ip3LrKx+OECv+C37BJYKX7XAh71BissfjAM5LJ6HFvryt zrAJc+ZtXL/Xy7mTr3NC1ODwoHl6PYNAUhaU/PIQNQts6uPrz/hKgyx53/e9a+z6 +Pm9hrL/kPRygxRfWZZZ941K2aLfWB5yC3idL+RbyKfTFHB9mG6Ayjzk0mTj2VaG he5IQHa+PJPGGJYPAyeRdbcR+TpKWB1iJicSDPN9BoCSI4fcRnhEIJ8at0GgjlRA si9LdKFEL2MRkG5VU2KdE5amSP0k0FEjxuQ3PbZt+pcR1sssazx44CLvFrxaRMt3 yRExJ5coaMBRBTaESy0Pi93F6la0CsgMsavkfvjS46+Q Use bitmap_zero/bitmap_copy/bitmap_qeual directly for bitmap operations. Signed-off-by: Joseph Qi --- fs/ocfs2/dlm/dlmcommon.h | 2 +- fs/ocfs2/dlm/dlmdomain.c | 17 +++++++---------- fs/ocfs2/dlm/dlmmaster.c | 30 +++++++++++++++--------------- fs/ocfs2/dlm/dlmrecovery.c | 2 +- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index fd2022712167..20f790a47484 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h @@ -1094,7 +1094,7 @@ static inline enum dlm_status dlm_err_to_dlm_status(int err) static inline void dlm_node_iter_init(unsigned long *map, struct dlm_node_iter *iter) { - memcpy(iter->node_map, map, sizeof(iter->node_map)); + bitmap_copy(iter->node_map, map, O2NM_MAX_NODES); iter->curnode = -1; } diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index f46941ff665d..5c04dde99981 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -1576,8 +1576,8 @@ static int dlm_should_restart_join(struct dlm_ctxt *dlm, spin_lock(&dlm->spinlock); /* For now, we restart the process if the node maps have * changed at all */ - ret = memcmp(ctxt->live_map, dlm->live_nodes_map, - sizeof(dlm->live_nodes_map)); + ret = !bitmap_equal(ctxt->live_map, dlm->live_nodes_map, + O2NM_MAX_NODES); spin_unlock(&dlm->spinlock); if (ret) @@ -1607,10 +1607,8 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) o2hb_fill_node_map(dlm->live_nodes_map, O2NM_MAX_NODES); spin_lock(&dlm->spinlock); - memcpy(ctxt->live_map, dlm->live_nodes_map, sizeof(ctxt->live_map)); - + bitmap_copy(ctxt->live_map, dlm->live_nodes_map, O2NM_MAX_NODES); __dlm_set_joining_node(dlm, dlm->node_num); - spin_unlock(&dlm->spinlock); node = -1; @@ -1643,8 +1641,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) * yes_resp_map. Copy that into our domain map and send a join * assert message to clean up everyone elses state. */ spin_lock(&dlm->spinlock); - memcpy(dlm->domain_map, ctxt->yes_resp_map, - sizeof(ctxt->yes_resp_map)); + bitmap_copy(dlm->domain_map, ctxt->yes_resp_map, O2NM_MAX_NODES); set_bit(dlm->node_num, dlm->domain_map); spin_unlock(&dlm->spinlock); @@ -2009,9 +2006,9 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, mlog(0, "dlm->recovery_map=%p, &(dlm->recovery_map[0])=%p\n", dlm->recovery_map, &(dlm->recovery_map[0])); - memset(dlm->recovery_map, 0, sizeof(dlm->recovery_map)); - memset(dlm->live_nodes_map, 0, sizeof(dlm->live_nodes_map)); - memset(dlm->domain_map, 0, sizeof(dlm->domain_map)); + bitmap_zero(dlm->recovery_map, O2NM_MAX_NODES); + bitmap_zero(dlm->live_nodes_map, O2NM_MAX_NODES); + bitmap_zero(dlm->domain_map, O2NM_MAX_NODES); dlm->dlm_thread_task = NULL; dlm->dlm_reco_thread_task = NULL; diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 227da5b1b6ab..d610da8e2f24 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -258,12 +258,12 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, mle->type = type; INIT_HLIST_NODE(&mle->master_hash_node); INIT_LIST_HEAD(&mle->hb_events); - memset(mle->maybe_map, 0, sizeof(mle->maybe_map)); + bitmap_zero(mle->maybe_map, O2NM_MAX_NODES); spin_lock_init(&mle->spinlock); init_waitqueue_head(&mle->wq); atomic_set(&mle->woken, 0); kref_init(&mle->mle_refs); - memset(mle->response_map, 0, sizeof(mle->response_map)); + bitmap_zero(mle->response_map, O2NM_MAX_NODES); mle->master = O2NM_MAX_NODES; mle->new_master = O2NM_MAX_NODES; mle->inuse = 0; @@ -290,8 +290,8 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, atomic_inc(&dlm->mle_cur_count[mle->type]); /* copy off the node_map and register hb callbacks on our copy */ - memcpy(mle->node_map, dlm->domain_map, sizeof(mle->node_map)); - memcpy(mle->vote_map, dlm->domain_map, sizeof(mle->vote_map)); + bitmap_copy(mle->node_map, dlm->domain_map, O2NM_MAX_NODES); + bitmap_copy(mle->vote_map, dlm->domain_map, O2NM_MAX_NODES); clear_bit(dlm->node_num, mle->vote_map); clear_bit(dlm->node_num, mle->node_map); @@ -572,7 +572,7 @@ static void dlm_init_lockres(struct dlm_ctxt *dlm, spin_unlock(&dlm->track_lock); memset(res->lvb, 0, DLM_LVB_LEN); - memset(res->refmap, 0, sizeof(res->refmap)); + bitmap_zero(res->refmap, O2NM_MAX_NODES); } struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, @@ -1036,10 +1036,10 @@ static int dlm_wait_for_lock_mastery(struct dlm_ctxt *dlm, spin_lock(&mle->spinlock); m = mle->master; - map_changed = (memcmp(mle->vote_map, mle->node_map, - sizeof(mle->vote_map)) != 0); - voting_done = (memcmp(mle->vote_map, mle->response_map, - sizeof(mle->vote_map)) == 0); + map_changed = !bitmap_equal(mle->vote_map, mle->node_map, + O2NM_MAX_NODES); + voting_done = bitmap_equal(mle->vote_map, mle->response_map, + O2NM_MAX_NODES); /* restart if we hit any errors */ if (map_changed) { @@ -1277,11 +1277,11 @@ static int dlm_restart_lock_mastery(struct dlm_ctxt *dlm, /* now blank out everything, as if we had never * contacted anyone */ - memset(mle->maybe_map, 0, sizeof(mle->maybe_map)); - memset(mle->response_map, 0, sizeof(mle->response_map)); + bitmap_zero(mle->maybe_map, O2NM_MAX_NODES); + bitmap_zero(mle->response_map, O2NM_MAX_NODES); /* reset the vote_map to the current node_map */ - memcpy(mle->vote_map, mle->node_map, - sizeof(mle->node_map)); + bitmap_copy(mle->vote_map, mle->node_map, + O2NM_MAX_NODES); /* put myself into the maybe map */ if (mle->type != DLM_MLE_BLOCK) set_bit(dlm->node_num, mle->maybe_map); @@ -2094,7 +2094,7 @@ static void dlm_assert_master_worker(struct dlm_work_item *item, void *data) flags = item->u.am.flags; spin_lock(&dlm->spinlock); - memcpy(nodemap, dlm->domain_map, sizeof(nodemap)); + bitmap_copy(nodemap, dlm->domain_map, O2NM_MAX_NODES); spin_unlock(&dlm->spinlock); clear_bit(dlm->node_num, nodemap); @@ -3447,7 +3447,7 @@ int dlm_finish_migration(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, ret = 0; } - memset(iter.node_map, 0, sizeof(iter.node_map)); + bitmap_zero(iter.node_map, O2NM_MAX_NODES); set_bit(old_master, iter.node_map); mlog(0, "doing assert master of %.*s back to %u\n", res->lockname.len, res->lockname.name, old_master); diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 52ad342fec3e..50da8af988c1 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -733,7 +733,7 @@ static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node) struct dlm_reco_node_data *ndata; spin_lock(&dlm->spinlock); - memcpy(dlm->reco.node_map, dlm->domain_map, sizeof(dlm->domain_map)); + bitmap_copy(dlm->reco.node_map, dlm->domain_map, O2NM_MAX_NODES); /* nodes can only be removed (by dying) after dropping * this lock, and death will be trapped later, so this should do */ spin_unlock(&dlm->spinlock);