Whamcloud - gitweb
LU-6602 obdclass: variable llog chunk size
[fs/lustre-release.git] / lustre / ptlrpc / llog_client.c
index b514727..e618714 100644 (file)
@@ -310,23 +310,31 @@ static int llog_client_read_header(const struct lu_env *env,
         if (hdr == NULL)
                 GOTO(out, rc =-EFAULT);
 
-        memcpy(handle->lgh_hdr, hdr, sizeof (*hdr));
-        handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index;
-
-        /* sanity checks */
-        llh_hdr = &handle->lgh_hdr->llh_hdr;
-        if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
-                CERROR("bad log header magic: %#x (expecting %#x)\n",
-                       llh_hdr->lrh_type, LLOG_HDR_MAGIC);
-                rc = -EIO;
-        } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) {
-                CERROR("incorrectly sized log header: %#x "
-                       "(expecting %#x)\n",
-                       llh_hdr->lrh_len, LLOG_CHUNK_SIZE);
-                CERROR("you may need to re-run lconf --write_conf.\n");
-                rc = -EIO;
-        }
-        EXIT;
+       if (handle->lgh_hdr_size < hdr->llh_hdr.lrh_len)
+               GOTO(out, rc = -EFAULT);
+
+       memcpy(handle->lgh_hdr, hdr, hdr->llh_hdr.lrh_len);
+       handle->lgh_last_idx = LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_index;
+
+       /* sanity checks */
+       llh_hdr = &handle->lgh_hdr->llh_hdr;
+       if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
+               CERROR("bad log header magic: %#x (expecting %#x)\n",
+                      llh_hdr->lrh_type, LLOG_HDR_MAGIC);
+               rc = -EIO;
+       } else if (llh_hdr->lrh_len !=
+                  LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_len ||
+                  (llh_hdr->lrh_len & (llh_hdr->lrh_len - 1)) != 0 ||
+                  llh_hdr->lrh_len < LLOG_MIN_CHUNK_SIZE ||
+                  llh_hdr->lrh_len > handle->lgh_hdr_size) {
+               CERROR("incorrectly sized log header: %#x, "
+                      "expecting %#x (power of two > 8192)\n",
+                      llh_hdr->lrh_len,
+                      LLOG_HDR_TAIL(handle->lgh_hdr)->lrt_len);
+               CERROR("you may need to re-run lconf --write_conf.\n");
+               rc = -EIO;
+       }
+       EXIT;
 out:
         ptlrpc_req_finished(req);
 err_exit: