Skip to content

Commit

Permalink
ocfs2: without quota support, avoid calling quota recovery
Browse files Browse the repository at this point in the history
During one dead node's recovery by other node, quota recovery work will
be queued.  We should avoid calling quota when it is not supported, so
check the quota flags.

Link: http://lkml.kernel.org/r/71604351584F6A4EBAE558C676F37CA401071AC9FB@H3CMLB12-EX.srv.huawei-3com.com
Signed-off-by: guozhonghua <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Joseph Qi <[email protected]>
Cc: Changwei Ge <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Guozhonghua authored and torvalds committed Nov 3, 2018
1 parent a634644 commit 21158ca
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions fs/ocfs2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,15 +1378,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);
Expand Down Expand Up @@ -1422,9 +1430,14 @@ static int __ocfs2_recovery_thread(void *arg)
* 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:
Expand Down Expand Up @@ -1452,16 +1465,19 @@ static int __ocfs2_recovery_thread(void *arg)
/* 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);
Expand All @@ -1483,7 +1499,8 @@ static int __ocfs2_recovery_thread(void *arg)

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
Expand Down

0 comments on commit 21158ca

Please sign in to comment.