aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuozhonghua <guozhonghua@h3c.com>2018-11-02 18:48:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-11-03 13:09:37 -0400
commit21158ca85b73ddd0088076a5209cfd040513a8b5 (patch)
tree0b20da72f945e516d377405d4ebf395cdbac8ba1
parenta634644751c46238df58bbfe992e30c1668388db (diff)
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 <guozhonghua@h3c.com> Reviewed-by: Jan Kara <jack@suse.cz> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Joseph Qi <jiangqi903@gmail.com> Cc: Changwei Ge <ge.changwei@h3c.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ocfs2/journal.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index bd3475694e83..b63c97f4318e 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1378,15 +1378,23 @@ static int __ocfs2_recovery_thread(void *arg)
1378 int rm_quota_used = 0, i; 1378 int rm_quota_used = 0, i;
1379 struct ocfs2_quota_recovery *qrec; 1379 struct ocfs2_quota_recovery *qrec;
1380 1380
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
1381 status = ocfs2_wait_on_mount(osb); 1387 status = ocfs2_wait_on_mount(osb);
1382 if (status < 0) { 1388 if (status < 0) {
1383 goto bail; 1389 goto bail;
1384 } 1390 }
1385 1391
1386 rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS); 1392 if (quota_enabled) {
1387 if (!rm_quota) { 1393 rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
1388 status = -ENOMEM; 1394 if (!rm_quota) {
1389 goto bail; 1395 status = -ENOMEM;
1396 goto bail;
1397 }
1390 } 1398 }
1391restart: 1399restart:
1392 status = ocfs2_super_lock(osb, 1); 1400 status = ocfs2_super_lock(osb, 1);
@@ -1422,9 +1430,14 @@ restart:
1422 * then quota usage would be out of sync until some node takes 1430 * then quota usage would be out of sync until some node takes
1423 * the slot. So we remember which nodes need quota recovery 1431 * the slot. So we remember which nodes need quota recovery
1424 * and when everything else is done, we recover quotas. */ 1432 * and when everything else is done, we recover quotas. */
1425 for (i = 0; i < rm_quota_used && rm_quota[i] != slot_num; i++); 1433 if (quota_enabled) {
1426 if (i == rm_quota_used) 1434 for (i = 0; i < rm_quota_used
1427 rm_quota[rm_quota_used++] = slot_num; 1435 && rm_quota[i] != slot_num; i++)
1436 ;
1437
1438 if (i == rm_quota_used)
1439 rm_quota[rm_quota_used++] = slot_num;
1440 }
1428 1441
1429 status = ocfs2_recover_node(osb, node_num, slot_num); 1442 status = ocfs2_recover_node(osb, node_num, slot_num);
1430skip_recovery: 1443skip_recovery:
@@ -1452,16 +1465,19 @@ skip_recovery:
1452 /* Now it is right time to recover quotas... We have to do this under 1465 /* Now it is right time to recover quotas... We have to do this under
1453 * superblock lock so that no one can start using the slot (and crash) 1466 * superblock lock so that no one can start using the slot (and crash)
1454 * before we recover it */ 1467 * before we recover it */
1455 for (i = 0; i < rm_quota_used; i++) { 1468 if (quota_enabled) {
1456 qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]); 1469 for (i = 0; i < rm_quota_used; i++) {
1457 if (IS_ERR(qrec)) { 1470 qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
1458 status = PTR_ERR(qrec); 1471 if (IS_ERR(qrec)) {
1459 mlog_errno(status); 1472 status = PTR_ERR(qrec);
1460 continue; 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);
1461 } 1480 }
1462 ocfs2_queue_recovery_completion(osb->journal, rm_quota[i],
1463 NULL, NULL, qrec,
1464 ORPHAN_NEED_TRUNCATE);
1465 } 1481 }
1466 1482
1467 ocfs2_super_unlock(osb, 1); 1483 ocfs2_super_unlock(osb, 1);
@@ -1483,7 +1499,8 @@ bail:
1483 1499
1484 mutex_unlock(&osb->recovery_lock); 1500 mutex_unlock(&osb->recovery_lock);
1485 1501
1486 kfree(rm_quota); 1502 if (quota_enabled)
1503 kfree(rm_quota);
1487 1504
1488 /* no one is callint kthread_stop() for us so the kthread() api 1505 /* no one is callint kthread_stop() for us so the kthread() api
1489 * requires that we call do_exit(). And it isn't exported, but 1506 * requires that we call do_exit(). And it isn't exported, but