Whamcloud - gitweb
LU-5687 dt: propagate errors from failed declarations
[fs/lustre-release.git] / lustre / obdclass / llog.c
index 78ba445..a4fbc25 100644 (file)
@@ -204,6 +204,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
                     int flags, struct obd_uuid *uuid)
 {
        struct llog_log_hdr     *llh;
+       enum llog_flag           fmt = flags & LLOG_F_EXT_MASK;
        int                      rc;
 
        ENTRY;
@@ -258,6 +259,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
                       flags, LLOG_F_IS_CAT, LLOG_F_IS_PLAIN);
                rc = -EINVAL;
        }
+       llh->llh_flags |= fmt;
 out:
        if (rc) {
                OBD_FREE_PTR(llh);
@@ -322,15 +324,15 @@ repeat:
                 if (rc)
                         GOTO(out, rc);
 
-                /* NB: when rec->lrh_len is accessed it is already swabbed
-                 * since it is used at the "end" of the loop and the rec
-                 * swabbing is done at the beginning of the loop. */
-                for (rec = (struct llog_rec_hdr *)buf;
-                     (char *)rec < buf + LLOG_CHUNK_SIZE;
-                     rec = (struct llog_rec_hdr *)((char *)rec + rec->lrh_len)){
+               /* NB: when rec->lrh_len is accessed it is already swabbed
+                * since it is used at the "end" of the loop and the rec
+                * swabbing is done at the beginning of the loop. */
+               for (rec = (struct llog_rec_hdr *)buf;
+                    (char *)rec < buf + LLOG_CHUNK_SIZE;
+                    rec = llog_rec_hdr_next(rec)) {
 
-                        CDEBUG(D_OTHER, "processing rec 0x%p type %#x\n",
-                               rec, rec->lrh_type);
+                       CDEBUG(D_OTHER, "processing rec 0x%p type %#x\n",
+                              rec, rec->lrh_type);
 
                         if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
                                lustre_swab_llog_rec(rec);
@@ -396,12 +398,12 @@ out:
         if (cd != NULL)
                 cd->lpcd_last_idx = last_called_index;
 
-       if (unlikely(rc == -EIO)) {
-               /* something bad happened to the processing, probably I/O
-                * error or the log got corrupted..
+       if (unlikely(rc == -EIO && loghandle->lgh_obj != NULL)) {
+               /* something bad happened to the processing of a local
+                * llog file, probably I/O error or the log got corrupted..
                 * to be able to finally release the log we discard any
                 * remaining bits in the header */
-               CERROR("llog found corrupted\n");
+               CERROR("Local llog found corrupted\n");
                while (index <= last_index) {
                        if (ext2_test_bit(index, llh->llh_bitmap) != 0)
                                llog_cancel_rec(lpi->lpi_env, loghandle, index);