aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/revoke.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd2/revoke.c')
-rw-r--r--fs/jbd2/revoke.c60
1 files changed, 19 insertions, 41 deletions
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 705ae577882b..91171dc352cb 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -122,11 +122,11 @@ struct jbd2_revoke_table_s
122 122
123 123
124#ifdef __KERNEL__ 124#ifdef __KERNEL__
125static void write_one_revoke_record(journal_t *, transaction_t *, 125static void write_one_revoke_record(transaction_t *,
126 struct list_head *, 126 struct list_head *,
127 struct buffer_head **, int *, 127 struct buffer_head **, int *,
128 struct jbd2_revoke_record_s *, int); 128 struct jbd2_revoke_record_s *);
129static void flush_descriptor(journal_t *, struct buffer_head *, int, int); 129static void flush_descriptor(journal_t *, struct buffer_head *, int);
130#endif 130#endif
131 131
132/* Utility functions to maintain the revoke table */ 132/* Utility functions to maintain the revoke table */
@@ -519,11 +519,10 @@ void jbd2_journal_switch_revoke_table(journal_t *journal)
519 * Write revoke records to the journal for all entries in the current 519 * Write revoke records to the journal for all entries in the current
520 * revoke hash, deleting the entries as we go. 520 * revoke hash, deleting the entries as we go.
521 */ 521 */
522void jbd2_journal_write_revoke_records(journal_t *journal, 522void jbd2_journal_write_revoke_records(transaction_t *transaction,
523 transaction_t *transaction, 523 struct list_head *log_bufs)
524 struct list_head *log_bufs,
525 int write_op)
526{ 524{
525 journal_t *journal = transaction->t_journal;
527 struct buffer_head *descriptor; 526 struct buffer_head *descriptor;
528 struct jbd2_revoke_record_s *record; 527 struct jbd2_revoke_record_s *record;
529 struct jbd2_revoke_table_s *revoke; 528 struct jbd2_revoke_table_s *revoke;
@@ -544,16 +543,15 @@ void jbd2_journal_write_revoke_records(journal_t *journal,
544 while (!list_empty(hash_list)) { 543 while (!list_empty(hash_list)) {
545 record = (struct jbd2_revoke_record_s *) 544 record = (struct jbd2_revoke_record_s *)
546 hash_list->next; 545 hash_list->next;
547 write_one_revoke_record(journal, transaction, log_bufs, 546 write_one_revoke_record(transaction, log_bufs,
548 &descriptor, &offset, 547 &descriptor, &offset, record);
549 record, write_op);
550 count++; 548 count++;
551 list_del(&record->hash); 549 list_del(&record->hash);
552 kmem_cache_free(jbd2_revoke_record_cache, record); 550 kmem_cache_free(jbd2_revoke_record_cache, record);
553 } 551 }
554 } 552 }
555 if (descriptor) 553 if (descriptor)
556 flush_descriptor(journal, descriptor, offset, write_op); 554 flush_descriptor(journal, descriptor, offset);
557 jbd_debug(1, "Wrote %d revoke records\n", count); 555 jbd_debug(1, "Wrote %d revoke records\n", count);
558} 556}
559 557
@@ -562,18 +560,16 @@ void jbd2_journal_write_revoke_records(journal_t *journal,
562 * block if the old one is full or if we have not already created one. 560 * block if the old one is full or if we have not already created one.
563 */ 561 */
564 562
565static void write_one_revoke_record(journal_t *journal, 563static void write_one_revoke_record(transaction_t *transaction,
566 transaction_t *transaction,
567 struct list_head *log_bufs, 564 struct list_head *log_bufs,
568 struct buffer_head **descriptorp, 565 struct buffer_head **descriptorp,
569 int *offsetp, 566 int *offsetp,
570 struct jbd2_revoke_record_s *record, 567 struct jbd2_revoke_record_s *record)
571 int write_op)
572{ 568{
569 journal_t *journal = transaction->t_journal;
573 int csum_size = 0; 570 int csum_size = 0;
574 struct buffer_head *descriptor; 571 struct buffer_head *descriptor;
575 int sz, offset; 572 int sz, offset;
576 journal_header_t *header;
577 573
578 /* If we are already aborting, this all becomes a noop. We 574 /* If we are already aborting, this all becomes a noop. We
579 still need to go round the loop in 575 still need to go round the loop in
@@ -587,7 +583,7 @@ static void write_one_revoke_record(journal_t *journal,
587 583
588 /* Do we need to leave space at the end for a checksum? */ 584 /* Do we need to leave space at the end for a checksum? */
589 if (jbd2_journal_has_csum_v2or3(journal)) 585 if (jbd2_journal_has_csum_v2or3(journal))
590 csum_size = sizeof(struct jbd2_journal_revoke_tail); 586 csum_size = sizeof(struct jbd2_journal_block_tail);
591 587
592 if (jbd2_has_feature_64bit(journal)) 588 if (jbd2_has_feature_64bit(journal))
593 sz = 8; 589 sz = 8;
@@ -597,19 +593,16 @@ static void write_one_revoke_record(journal_t *journal,
597 /* Make sure we have a descriptor with space left for the record */ 593 /* Make sure we have a descriptor with space left for the record */
598 if (descriptor) { 594 if (descriptor) {
599 if (offset + sz > journal->j_blocksize - csum_size) { 595 if (offset + sz > journal->j_blocksize - csum_size) {
600 flush_descriptor(journal, descriptor, offset, write_op); 596 flush_descriptor(journal, descriptor, offset);
601 descriptor = NULL; 597 descriptor = NULL;
602 } 598 }
603 } 599 }
604 600
605 if (!descriptor) { 601 if (!descriptor) {
606 descriptor = jbd2_journal_get_descriptor_buffer(journal); 602 descriptor = jbd2_journal_get_descriptor_buffer(transaction,
603 JBD2_REVOKE_BLOCK);
607 if (!descriptor) 604 if (!descriptor)
608 return; 605 return;
609 header = (journal_header_t *)descriptor->b_data;
610 header->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
611 header->h_blocktype = cpu_to_be32(JBD2_REVOKE_BLOCK);
612 header->h_sequence = cpu_to_be32(transaction->t_tid);
613 606
614 /* Record it so that we can wait for IO completion later */ 607 /* Record it so that we can wait for IO completion later */
615 BUFFER_TRACE(descriptor, "file in log_bufs"); 608 BUFFER_TRACE(descriptor, "file in log_bufs");
@@ -630,21 +623,6 @@ static void write_one_revoke_record(journal_t *journal,
630 *offsetp = offset; 623 *offsetp = offset;
631} 624}
632 625
633static void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh)
634{
635 struct jbd2_journal_revoke_tail *tail;
636 __u32 csum;
637
638 if (!jbd2_journal_has_csum_v2or3(j))
639 return;
640
641 tail = (struct jbd2_journal_revoke_tail *)(bh->b_data + j->j_blocksize -
642 sizeof(struct jbd2_journal_revoke_tail));
643 tail->r_checksum = 0;
644 csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize);
645 tail->r_checksum = cpu_to_be32(csum);
646}
647
648/* 626/*
649 * Flush a revoke descriptor out to the journal. If we are aborting, 627 * Flush a revoke descriptor out to the journal. If we are aborting,
650 * this is a noop; otherwise we are generating a buffer which needs to 628 * this is a noop; otherwise we are generating a buffer which needs to
@@ -654,7 +632,7 @@ static void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh)
654 632
655static void flush_descriptor(journal_t *journal, 633static void flush_descriptor(journal_t *journal,
656 struct buffer_head *descriptor, 634 struct buffer_head *descriptor,
657 int offset, int write_op) 635 int offset)
658{ 636{
659 jbd2_journal_revoke_header_t *header; 637 jbd2_journal_revoke_header_t *header;
660 638
@@ -665,12 +643,12 @@ static void flush_descriptor(journal_t *journal,
665 643
666 header = (jbd2_journal_revoke_header_t *)descriptor->b_data; 644 header = (jbd2_journal_revoke_header_t *)descriptor->b_data;
667 header->r_count = cpu_to_be32(offset); 645 header->r_count = cpu_to_be32(offset);
668 jbd2_revoke_csum_set(journal, descriptor); 646 jbd2_descriptor_block_csum_set(journal, descriptor);
669 647
670 set_buffer_jwrite(descriptor); 648 set_buffer_jwrite(descriptor);
671 BUFFER_TRACE(descriptor, "write"); 649 BUFFER_TRACE(descriptor, "write");
672 set_buffer_dirty(descriptor); 650 set_buffer_dirty(descriptor);
673 write_dirty_buffer(descriptor, write_op); 651 write_dirty_buffer(descriptor, WRITE_SYNC);
674} 652}
675#endif 653#endif
676 654