X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fjbd%2Frevoke.c;h=a56144183462e20d06ad756a5b6d062c44333838;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=1564a48163d285d4ba111357e52fdab5a759c463;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c index 1564a4816..a56144183 100644 --- a/fs/jbd/revoke.c +++ b/fs/jbd/revoke.c @@ -116,7 +116,8 @@ static inline int hash(journal_t *journal, unsigned long block) (block << (hash_shift - 12))) & (table->hash_size - 1); } -int insert_revoke_hash(journal_t *journal, unsigned long blocknr, tid_t seq) +static int insert_revoke_hash(journal_t *journal, unsigned long blocknr, + tid_t seq) { struct list_head *hash_list; struct jbd_revoke_record_s *record; @@ -187,9 +188,9 @@ int __init journal_init_revoke_caches(void) void journal_destroy_revoke_caches(void) { kmem_cache_destroy(revoke_record_cache); - revoke_record_cache = 0; + revoke_record_cache = NULL; kmem_cache_destroy(revoke_table_cache); - revoke_table_cache = 0; + revoke_table_cache = NULL; } /* Initialise the revoke table for a given journal to a given size. */ @@ -332,6 +333,7 @@ int journal_revoke(handle_t *handle, unsigned long blocknr, struct block_device *bdev; int err; + might_sleep(); if (bh_in) BUFFER_TRACE(bh_in, "enter"); @@ -375,7 +377,12 @@ int journal_revoke(handle_t *handle, unsigned long blocknr, first having the revoke cancelled: it's illegal to free a block twice without allocating it in between! */ if (bh) { - J_ASSERT_BH(bh, !buffer_revoked(bh)); + if (!J_EXPECT_BH(bh, !buffer_revoked(bh), + "inconsistent data on disk")) { + if (!bh_in) + brelse(bh); + return -EIO; + } set_buffer_revoked(bh); set_buffer_revokevalid(bh); if (bh_in) { @@ -522,7 +529,7 @@ void journal_write_revoke_records(journal_t *journal, kmem_cache_free(revoke_record_cache, record); } } - if (descriptor) + if (descriptor) flush_descriptor(journal, descriptor, offset); jbd_debug(1, "Wrote %d revoke records\n", count); } @@ -565,9 +572,9 @@ static void write_one_revoke_record(journal_t *journal, if (!descriptor) return; header = (journal_header_t *) &jh2bh(descriptor)->b_data[0]; - header->h_magic = htonl(JFS_MAGIC_NUMBER); - header->h_blocktype = htonl(JFS_REVOKE_BLOCK); - header->h_sequence = htonl(transaction->t_tid); + header->h_magic = cpu_to_be32(JFS_MAGIC_NUMBER); + header->h_blocktype = cpu_to_be32(JFS_REVOKE_BLOCK); + header->h_sequence = cpu_to_be32(transaction->t_tid); /* Record it so that we can wait for IO completion later */ JBUFFER_TRACE(descriptor, "file as BJ_LogCtl"); @@ -577,8 +584,8 @@ static void write_one_revoke_record(journal_t *journal, *descriptorp = descriptor; } - * ((unsigned int *)(&jh2bh(descriptor)->b_data[offset])) = - htonl(record->blocknr); + * ((__be32 *)(&jh2bh(descriptor)->b_data[offset])) = + cpu_to_be32(record->blocknr); offset += 4; *offsetp = offset; } @@ -603,11 +610,11 @@ static void flush_descriptor(journal_t *journal, } header = (journal_revoke_header_t *) jh2bh(descriptor)->b_data; - header->r_count = htonl(offset); + header->r_count = cpu_to_be32(offset); set_buffer_jwrite(bh); BUFFER_TRACE(bh, "write"); - set_buffer_uptodate(bh); - ll_rw_block(WRITE, 1, &bh); + set_buffer_dirty(bh); + ll_rw_block(SWRITE, 1, &bh); } #endif