]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/ocfs2/journal.c
Merge branch 'akpm' (patches from Andrew)
[mirror_ubuntu-jammy-kernel.git] / fs / ocfs2 / journal.c
index bd3475694e83a06501a055e73fd1403f81123eef..46fd3ef2cf212e4ae45ad0bf6f248b89612b9d6d 100644 (file)
@@ -1017,7 +1017,8 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
                        mlog_errno(status);
        }
 
-       if (status == 0) {
+       /* Shutdown the kernel journal system */
+       if (!jbd2_journal_destroy(journal->j_journal) && !status) {
                /*
                 * Do not toggle if flush was unsuccessful otherwise
                 * will leave dirty metadata in a "clean" journal
@@ -1026,9 +1027,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
                if (status < 0)
                        mlog_errno(status);
        }
-
-       /* Shutdown the kernel journal system */
-       jbd2_journal_destroy(journal->j_journal);
        journal->j_journal = NULL;
 
        OCFS2_I(inode)->ip_open_count--;
@@ -1378,15 +1376,23 @@ static int __ocfs2_recovery_thread(void *arg)
        int rm_quota_used = 0, i;
        struct ocfs2_quota_recovery *qrec;
 
+       /* Whether the quota supported. */
+       int quota_enabled = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb,
+                       OCFS2_FEATURE_RO_COMPAT_USRQUOTA)
+               || OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb,
+                       OCFS2_FEATURE_RO_COMPAT_GRPQUOTA);
+
        status = ocfs2_wait_on_mount(osb);
        if (status < 0) {
                goto bail;
        }
 
-       rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
-       if (!rm_quota) {
-               status = -ENOMEM;
-               goto bail;
+       if (quota_enabled) {
+               rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
+               if (!rm_quota) {
+                       status = -ENOMEM;
+                       goto bail;
+               }
        }
 restart:
        status = ocfs2_super_lock(osb, 1);
@@ -1422,9 +1428,14 @@ restart:
                 * then quota usage would be out of sync until some node takes
                 * the slot. So we remember which nodes need quota recovery
                 * and when everything else is done, we recover quotas. */
-               for (i = 0; i < rm_quota_used && rm_quota[i] != slot_num; i++);
-               if (i == rm_quota_used)
-                       rm_quota[rm_quota_used++] = slot_num;
+               if (quota_enabled) {
+                       for (i = 0; i < rm_quota_used
+                                       && rm_quota[i] != slot_num; i++)
+                               ;
+
+                       if (i == rm_quota_used)
+                               rm_quota[rm_quota_used++] = slot_num;
+               }
 
                status = ocfs2_recover_node(osb, node_num, slot_num);
 skip_recovery:
@@ -1452,16 +1463,19 @@ skip_recovery:
        /* Now it is right time to recover quotas... We have to do this under
         * superblock lock so that no one can start using the slot (and crash)
         * before we recover it */
-       for (i = 0; i < rm_quota_used; i++) {
-               qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
-               if (IS_ERR(qrec)) {
-                       status = PTR_ERR(qrec);
-                       mlog_errno(status);
-                       continue;
+       if (quota_enabled) {
+               for (i = 0; i < rm_quota_used; i++) {
+                       qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
+                       if (IS_ERR(qrec)) {
+                               status = PTR_ERR(qrec);
+                               mlog_errno(status);
+                               continue;
+                       }
+                       ocfs2_queue_recovery_completion(osb->journal,
+                                       rm_quota[i],
+                                       NULL, NULL, qrec,
+                                       ORPHAN_NEED_TRUNCATE);
                }
-               ocfs2_queue_recovery_completion(osb->journal, rm_quota[i],
-                                               NULL, NULL, qrec,
-                                               ORPHAN_NEED_TRUNCATE);
        }
 
        ocfs2_super_unlock(osb, 1);
@@ -1483,7 +1497,8 @@ bail:
 
        mutex_unlock(&osb->recovery_lock);
 
-       kfree(rm_quota);
+       if (quota_enabled)
+               kfree(rm_quota);
 
        /* no one is callint kthread_stop() for us so the kthread() api
         * requires that we call do_exit().  And it isn't exported, but