Whamcloud - gitweb
LU-17402 kernel: RHEL 8.10 client and server support
[fs/lustre-release.git] / lustre / obdclass / kernelcomm.c
index 8407825..c08c85c 100644 (file)
@@ -170,12 +170,14 @@ static int lustre_device_list_dump(struct sk_buff *msg,
 {
        struct genl_dev_list *glist = device_dump_ctx(cb);
        struct obd_device *filter = glist->gdl_target;
+       struct obd_device *obd = NULL;
 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
        struct netlink_ext_ack *extack = NULL;
 #endif
        int portid = NETLINK_CB(cb->skb).portid;
        int seq = cb->nlh->nlmsg_seq;
-       int idx, rc = 0;
+       unsigned long idx = 0;
+       int rc = 0;
 
 #ifdef HAVE_NL_DUMP_WITH_EXT_ACK
        extack = cb->extack;
@@ -195,15 +197,11 @@ static int lustre_device_list_dump(struct sk_buff *msg,
                }
        }
 
-       for (idx = glist->gdl_start; idx < class_devno_max(); idx++) {
-               struct obd_device *obd;
+       obd_device_lock();
+       obd_device_for_each_start(idx, obd, glist->gdl_start) {
                const char *status;
                void *hdr;
 
-               obd = class_num2obd(idx);
-               if (!obd)
-                       continue;
-
                if (filter && filter != obd)
                        continue;
 
@@ -251,13 +249,15 @@ static int lustre_device_list_dump(struct sk_buff *msg,
                               obd->obd_uuid.uuid);
 
                nla_put_u32(msg, LUSTRE_DEVICE_ATTR_REFCOUNT,
-                           atomic_read(&obd->obd_refcount));
+                           kref_read(&obd->obd_refcount));
 
                genlmsg_end(msg, hdr);
        }
+       obd_device_unlock();
 
-       glist->gdl_start = idx;
+       glist->gdl_start = idx + 1;
        rc = lnet_nl_send_error(cb->skb, portid, seq, rc);
+
        return rc < 0 ? rc : msg->len;
 }
 
@@ -276,7 +276,7 @@ int lustre_old_device_list_dump(struct sk_buff *msg,
 }
 #endif
 
-int lustre_device_done(struct netlink_callback *cb)
+static int lustre_device_done(struct netlink_callback *cb)
 {
        struct genl_dev_list *glist;
 
@@ -314,6 +314,9 @@ static struct genl_family lustre_family = {
        .n_ops          = ARRAY_SIZE(lustre_genl_ops),
        .mcgrps         = lustre_mcast_grps,
        .n_mcgrps       = ARRAY_SIZE(lustre_mcast_grps),
+#ifdef GENL_FAMILY_HAS_RESV_START_OP
+       .resv_start_op  = __LUSTRE_CMD_MAX_PLUS_ONE,
+#endif
 };
 
 /**
@@ -485,7 +488,7 @@ int libcfs_kkuc_group_put(const struct obd_uuid *uuid, int group, void *payload)
        down_write(&kg_sem);
 
        if (unlikely(list_empty(&kkuc_groups[group])) ||
-           unlikely(OBD_FAIL_CHECK(OBD_FAIL_MDS_HSM_CT_REGISTER_NET))) {
+           unlikely(CFS_FAIL_CHECK(OBD_FAIL_MDS_HSM_CT_REGISTER_NET))) {
                /* no agent have fully registered, CDT will retry */
                up_write(&kg_sem);
                RETURN(-EAGAIN);