Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-4189

Strange code in mdc_changelog_send_thread

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • Lustre 2.8.0
    • Lustre 2.6.0
    • 3
    • 11329

      Playing with the stack tool, it uncovered this strange piece in mdc_changelog_send_thread:

              /* Send EOF no matter what our result */
              if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
                                            cs->cs_flags))) {
                      kuch->kuc_msgtype = CL_EOF;
                      libcfs_kkuc_msg_put(cs->cs_fp, kuch);
              }
      

      Now, the thing is that changelog_kuc_hdr never returns NULL as we pass the pointer into it already and if it's zero, we'd totally die before even returning:

      static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
      {
              struct kuc_hdr *lh = (struct kuc_hdr *)buf;
      
              LASSERT(len <= KUC_CHANGELOG_MSG_MAXSIZE);
      
              lh->kuc_magic = KUC_MAGIC;
              lh->kuc_transport = KUC_TRANSPORT_CHANGELOG;
              lh->kuc_flags = flags;
              lh->kuc_msgtype = CL_RECORD;
              lh->kuc_msglen = len;
              return lh;
      }
      

      So I guess weeither should do away with the if here and make for a more readable code, or actually insert some checks into changelog_kuc_hdr

            wc-triage WC Triage
            green Oleg Drokin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: