+static void lustre_swab_hai(struct hsm_action_item *h)
+{
+ __swab32s(&h->hai_len);
+ __swab32s(&h->hai_action);
+ lustre_swab_lu_fid(&h->hai_fid);
+ __swab64s(&h->hai_cookie);
+ __swab64s(&h->hai_extent_start);
+ __swab64s(&h->hai_extent_end);
+ __swab64s(&h->hai_gid);
+}
+
+static void lustre_swab_hal(struct hsm_action_list *h)
+{
+ struct hsm_action_item *hai;
+ int i;
+
+ __swab32s(&h->hal_version);
+ __swab32s(&h->hal_count);
+ __swab32s(&h->hal_archive_num);
+ hai = hai_zero(h);
+ for (i = 0; i < h->hal_count; i++) {
+ lustre_swab_hai(hai);
+ hai = hai_next(hai);
+ }
+}
+
+/**
+ * Send a message to any listening copytools, nonblocking
+ * @param val LNL message (lnl_hdr + hsm_action_list)
+ * @param len total length of message
+ */
+static int mdc_hsm_copytool_send(int len, void *val)
+{
+ struct lnl_hdr *lh = (struct lnl_hdr *)val;
+ struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1);
+ int rc;
+ ENTRY;
+
+ if (len < sizeof(*lh) + sizeof(*hal)) {
+ CERROR("Short HSM message %d < %d\n", len,
+ sizeof(*lh) + sizeof(*hal));
+ RETURN(-EPROTO);
+ }
+ if (lh->lnl_magic == __swab16(LNL_MAGIC)) {
+ lustre_swab_lnlh(lh);
+ lustre_swab_hal(hal);
+ } else if (lh->lnl_magic != LNL_MAGIC) {
+ CERROR("Bad magic %x!=%x\n", lh->lnl_magic, LNL_MAGIC);
+ RETURN(-EPROTO);
+ }
+
+ CDEBUG(D_IOCTL, " Received message mg=%x t=%d m=%d l=%d actions=%d\n",
+ lh->lnl_magic, lh->lnl_transport, lh->lnl_msgtype,
+ lh->lnl_msglen, hal->hal_count);
+
+ /* Broadcast to HSM listeners */
+ rc = libcfs_klnl_msg_put(0, LNL_GRP_HSM, lh);
+
+ RETURN(rc);
+}
+