Skip to content

Commit 21158ca

Browse files
Guozhonghuatorvalds
authored andcommitted
ocfs2: without quota support, avoid calling quota recovery
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]>
1 parent a634644 commit 21158ca

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

fs/ocfs2/journal.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,15 +1378,23 @@ static int __ocfs2_recovery_thread(void *arg)
13781378
int rm_quota_used = 0, i;
13791379
struct ocfs2_quota_recovery *qrec;
13801380

1381+
/* Whether the quota supported. */
1382+
int quota_enabled = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb,
1383+
OCFS2_FEATURE_RO_COMPAT_USRQUOTA)
1384+
|| OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb,
1385+
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA);
1386+
13811387
status = ocfs2_wait_on_mount(osb);
13821388
if (status < 0) {
13831389
goto bail;
13841390
}
13851391

1386-
rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
1387-
if (!rm_quota) {
1388-
status = -ENOMEM;
1389-
goto bail;
1392+
if (quota_enabled) {
1393+
rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
1394+
if (!rm_quota) {
1395+
status = -ENOMEM;
1396+
goto bail;
1397+
}
13901398
}
13911399
restart:
13921400
status = ocfs2_super_lock(osb, 1);
@@ -1422,9 +1430,14 @@ static int __ocfs2_recovery_thread(void *arg)
14221430
* then quota usage would be out of sync until some node takes
14231431
* the slot. So we remember which nodes need quota recovery
14241432
* and when everything else is done, we recover quotas. */
1425-
for (i = 0; i < rm_quota_used && rm_quota[i] != slot_num; i++);
1426-
if (i == rm_quota_used)
1427-
rm_quota[rm_quota_used++] = slot_num;
1433+
if (quota_enabled) {
1434+
for (i = 0; i < rm_quota_used
1435+
&& rm_quota[i] != slot_num; i++)
1436+
;
1437+
1438+
if (i == rm_quota_used)
1439+
rm_quota[rm_quota_used++] = slot_num;
1440+
}
14281441

14291442
status = ocfs2_recover_node(osb, node_num, slot_num);
14301443
skip_recovery:
@@ -1452,16 +1465,19 @@ static int __ocfs2_recovery_thread(void *arg)
14521465
/* Now it is right time to recover quotas... We have to do this under
14531466
* superblock lock so that no one can start using the slot (and crash)
14541467
* before we recover it */
1455-
for (i = 0; i < rm_quota_used; i++) {
1456-
qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
1457-
if (IS_ERR(qrec)) {
1458-
status = PTR_ERR(qrec);
1459-
mlog_errno(status);
1460-
continue;
1468+
if (quota_enabled) {
1469+
for (i = 0; i < rm_quota_used; i++) {
1470+
qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
1471+
if (IS_ERR(qrec)) {
1472+
status = PTR_ERR(qrec);
1473+
mlog_errno(status);
1474+
continue;
1475+
}
1476+
ocfs2_queue_recovery_completion(osb->journal,
1477+
rm_quota[i],
1478+
NULL, NULL, qrec,
1479+
ORPHAN_NEED_TRUNCATE);
14611480
}
1462-
ocfs2_queue_recovery_completion(osb->journal, rm_quota[i],
1463-
NULL, NULL, qrec,
1464-
ORPHAN_NEED_TRUNCATE);
14651481
}
14661482

14671483
ocfs2_super_unlock(osb, 1);
@@ -1483,7 +1499,8 @@ static int __ocfs2_recovery_thread(void *arg)
14831499

14841500
mutex_unlock(&osb->recovery_lock);
14851501

1486-
kfree(rm_quota);
1502+
if (quota_enabled)
1503+
kfree(rm_quota);
14871504

14881505
/* no one is callint kthread_stop() for us so the kthread() api
14891506
* requires that we call do_exit(). And it isn't exported, but

0 commit comments

Comments
 (0)