Whamcloud - gitweb
LU-14688 mdt: changelog purge deletes plain llog
[fs/lustre-release.git] / lustre / obdclass / llog.c
index 4ac4d20..12e179e 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/obdclass/llog.c
  *
@@ -104,7 +103,7 @@ int llog_handle_put(const struct lu_env *env, struct llog_handle *loghandle)
        int rc = 0;
 
        if (refcount_dec_and_test(&loghandle->lgh_refcount)) {
-               struct llog_operations *lop;
+               const struct llog_operations *lop;
 
                rc = llog_handle2ops(loghandle, &lop);
                if (!rc) {
@@ -122,7 +121,7 @@ static int llog_declare_destroy(const struct lu_env *env,
                                struct llog_handle *handle,
                                struct thandle *th)
 {
-       struct llog_operations *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -141,7 +140,7 @@ static int llog_declare_destroy(const struct lu_env *env,
 int llog_trans_destroy(const struct lu_env *env, struct llog_handle *handle,
                       struct thandle *th)
 {
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
        ENTRY;
 
@@ -162,9 +161,9 @@ int llog_trans_destroy(const struct lu_env *env, struct llog_handle *handle,
 
 int llog_destroy(const struct lu_env *env, struct llog_handle *handle)
 {
-       struct llog_operations  *lop;
-       struct dt_device        *dt;
-       struct thandle          *th;
+       const struct llog_operations *lop;
+       struct dt_device *dt;
+       struct thandle *th;
        int rc;
 
        ENTRY;
@@ -313,13 +312,22 @@ int llog_cancel_arr_rec(const struct lu_env *env, struct llog_handle *loghandle,
        }
 
 out_unlock:
+       if (rc < 0) {
+               /* restore bitmap while holding a mutex */
+               if (subtract_count) {
+                       loghandle->lgh_hdr->llh_count += num;
+                       subtract_count = false;
+               }
+               for (i = i - 1; i >= 0; i--)
+                       set_bit_le(index[i], LLOG_HDR_BITMAP(llh));
+       }
        mutex_unlock(&loghandle->lgh_hdr_mutex);
        up_write(&loghandle->lgh_lock);
 out_trans:
        rc1 = dt_trans_stop(env, dt, th);
        if (rc == 0)
                rc = rc1;
-       if (rc < 0) {
+       if (rc1 < 0) {
                mutex_lock(&loghandle->lgh_hdr_mutex);
                if (subtract_count)
                        loghandle->lgh_hdr->llh_count += num;
@@ -339,7 +347,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle,
 int llog_read_header(const struct lu_env *env, struct llog_handle *handle,
                     const struct obd_uuid *uuid)
 {
-       struct llog_operations *lop;
+       const struct llog_operations *lop;
        int rc;
        ENTRY;
 
@@ -552,6 +560,8 @@ repeat:
                        CDEBUG(D_OTHER, "cur_offset %llu, chunk_offset %llu,"
                               " buf_offset %u, rc = %d\n", cur_offset,
                               (__u64)chunk_offset, buf_offset, rc);
+               if (rc == -ESTALE)
+                       GOTO(out, rc = 0);
                /* we`ve tried to reread the chunk, but there is no
                 * new records */
                if (rc == -EIO && repeated && (chunk_offset + buf_offset) ==
@@ -728,6 +738,12 @@ repeat:
                                        rc = llog_cancel_rec(lpi->lpi_env,
                                                             loghandle,
                                                             rec->lrh_index);
+                                       /* Allow parallel cancelling, ENOENT
+                                        * means record was canceled at another
+                                        * processing thread or callback
+                                        */
+                                       if (rc == -ENOENT)
+                                               rc = 0;
                                }
                                if (rc)
                                        GOTO(out, rc);
@@ -1024,8 +1040,8 @@ EXPORT_SYMBOL(llog_reverse_process);
  */
 int llog_exist(struct llog_handle *loghandle)
 {
-       struct llog_operations  *lop;
-       int                      rc;
+       const struct llog_operations *lop;
+       int rc;
 
        ENTRY;
 
@@ -1044,7 +1060,7 @@ int llog_declare_create(const struct lu_env *env,
                        struct llog_handle *loghandle, struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -1065,7 +1081,7 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle,
                struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -1088,7 +1104,7 @@ int llog_declare_write_rec(const struct lu_env *env,
                           struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc;
 
        ENTRY;
@@ -1111,7 +1127,7 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle,
                   int idx, struct thandle *th)
 {
        const struct cred *old_cred;
-       struct llog_operations  *lop;
+       const struct llog_operations *lop;
        int rc, buflen;
 
        ENTRY;