Commit 9c28cbcc authored by Jan Kara's avatar Jan Kara

jbd: Journal block numbers can ever be only 32-bit use unsigned int for them

It does not make sense to store block number for journal as unsigned long
since they can be only 32-bit (because of on-disk format limitation). So
change in-memory structures and variables to use unsigned int instead.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 19003c18
...@@ -456,7 +456,7 @@ int cleanup_journal_tail(journal_t *journal) ...@@ -456,7 +456,7 @@ int cleanup_journal_tail(journal_t *journal)
{ {
transaction_t * transaction; transaction_t * transaction;
tid_t first_tid; tid_t first_tid;
unsigned long blocknr, freed; unsigned int blocknr, freed;
if (is_journal_aborted(journal)) if (is_journal_aborted(journal))
return 1; return 1;
...@@ -502,8 +502,8 @@ int cleanup_journal_tail(journal_t *journal) ...@@ -502,8 +502,8 @@ int cleanup_journal_tail(journal_t *journal)
freed = freed + journal->j_last - journal->j_first; freed = freed + journal->j_last - journal->j_first;
jbd_debug(1, jbd_debug(1,
"Cleaning journal tail from %d to %d (offset %lu), " "Cleaning journal tail from %d to %d (offset %u), "
"freeing %lu\n", "freeing %u\n",
journal->j_tail_sequence, first_tid, blocknr, freed); journal->j_tail_sequence, first_tid, blocknr, freed);
journal->j_free += freed; journal->j_free += freed;
......
...@@ -308,7 +308,7 @@ void journal_commit_transaction(journal_t *journal) ...@@ -308,7 +308,7 @@ void journal_commit_transaction(journal_t *journal)
int bufs; int bufs;
int flags; int flags;
int err; int err;
unsigned long blocknr; unsigned int blocknr;
ktime_t start_time; ktime_t start_time;
u64 commit_time; u64 commit_time;
char *tagp = NULL; char *tagp = NULL;
......
...@@ -276,7 +276,7 @@ static void journal_kill_thread(journal_t *journal) ...@@ -276,7 +276,7 @@ static void journal_kill_thread(journal_t *journal)
int journal_write_metadata_buffer(transaction_t *transaction, int journal_write_metadata_buffer(transaction_t *transaction,
struct journal_head *jh_in, struct journal_head *jh_in,
struct journal_head **jh_out, struct journal_head **jh_out,
unsigned long blocknr) unsigned int blocknr)
{ {
int need_copy_out = 0; int need_copy_out = 0;
int done_copy_out = 0; int done_copy_out = 0;
...@@ -567,9 +567,9 @@ int log_wait_commit(journal_t *journal, tid_t tid) ...@@ -567,9 +567,9 @@ int log_wait_commit(journal_t *journal, tid_t tid)
* Log buffer allocation routines: * Log buffer allocation routines:
*/ */
int journal_next_log_block(journal_t *journal, unsigned long *retp) int journal_next_log_block(journal_t *journal, unsigned int *retp)
{ {
unsigned long blocknr; unsigned int blocknr;
spin_lock(&journal->j_state_lock); spin_lock(&journal->j_state_lock);
J_ASSERT(journal->j_free > 1); J_ASSERT(journal->j_free > 1);
...@@ -590,11 +590,11 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp) ...@@ -590,11 +590,11 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp)
* this is a no-op. If needed, we can use j_blk_offset - everything is * this is a no-op. If needed, we can use j_blk_offset - everything is
* ready. * ready.
*/ */
int journal_bmap(journal_t *journal, unsigned long blocknr, int journal_bmap(journal_t *journal, unsigned int blocknr,
unsigned long *retp) unsigned int *retp)
{ {
int err = 0; int err = 0;
unsigned long ret; unsigned int ret;
if (journal->j_inode) { if (journal->j_inode) {
ret = bmap(journal->j_inode, blocknr); ret = bmap(journal->j_inode, blocknr);
...@@ -604,7 +604,7 @@ int journal_bmap(journal_t *journal, unsigned long blocknr, ...@@ -604,7 +604,7 @@ int journal_bmap(journal_t *journal, unsigned long blocknr,
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
printk(KERN_ALERT "%s: journal block not found " printk(KERN_ALERT "%s: journal block not found "
"at offset %lu on %s\n", "at offset %u on %s\n",
__func__, __func__,
blocknr, blocknr,
bdevname(journal->j_dev, b)); bdevname(journal->j_dev, b));
...@@ -630,7 +630,7 @@ int journal_bmap(journal_t *journal, unsigned long blocknr, ...@@ -630,7 +630,7 @@ int journal_bmap(journal_t *journal, unsigned long blocknr,
struct journal_head *journal_get_descriptor_buffer(journal_t *journal) struct journal_head *journal_get_descriptor_buffer(journal_t *journal)
{ {
struct buffer_head *bh; struct buffer_head *bh;
unsigned long blocknr; unsigned int blocknr;
int err; int err;
err = journal_next_log_block(journal, &blocknr); err = journal_next_log_block(journal, &blocknr);
...@@ -774,7 +774,7 @@ journal_t * journal_init_inode (struct inode *inode) ...@@ -774,7 +774,7 @@ journal_t * journal_init_inode (struct inode *inode)
journal_t *journal = journal_init_common(); journal_t *journal = journal_init_common();
int err; int err;
int n; int n;
unsigned long blocknr; unsigned int blocknr;
if (!journal) if (!journal)
return NULL; return NULL;
...@@ -846,12 +846,12 @@ static void journal_fail_superblock (journal_t *journal) ...@@ -846,12 +846,12 @@ static void journal_fail_superblock (journal_t *journal)
static int journal_reset(journal_t *journal) static int journal_reset(journal_t *journal)
{ {
journal_superblock_t *sb = journal->j_superblock; journal_superblock_t *sb = journal->j_superblock;
unsigned long first, last; unsigned int first, last;
first = be32_to_cpu(sb->s_first); first = be32_to_cpu(sb->s_first);
last = be32_to_cpu(sb->s_maxlen); last = be32_to_cpu(sb->s_maxlen);
if (first + JFS_MIN_JOURNAL_BLOCKS > last + 1) { if (first + JFS_MIN_JOURNAL_BLOCKS > last + 1) {
printk(KERN_ERR "JBD: Journal too short (blocks %lu-%lu).\n", printk(KERN_ERR "JBD: Journal too short (blocks %u-%u).\n",
first, last); first, last);
journal_fail_superblock(journal); journal_fail_superblock(journal);
return -EINVAL; return -EINVAL;
...@@ -885,7 +885,7 @@ static int journal_reset(journal_t *journal) ...@@ -885,7 +885,7 @@ static int journal_reset(journal_t *journal)
**/ **/
int journal_create(journal_t *journal) int journal_create(journal_t *journal)
{ {
unsigned long blocknr; unsigned int blocknr;
struct buffer_head *bh; struct buffer_head *bh;
journal_superblock_t *sb; journal_superblock_t *sb;
int i, err; int i, err;
...@@ -969,14 +969,14 @@ void journal_update_superblock(journal_t *journal, int wait) ...@@ -969,14 +969,14 @@ void journal_update_superblock(journal_t *journal, int wait)
if (sb->s_start == 0 && journal->j_tail_sequence == if (sb->s_start == 0 && journal->j_tail_sequence ==
journal->j_transaction_sequence) { journal->j_transaction_sequence) {
jbd_debug(1,"JBD: Skipping superblock update on recovered sb " jbd_debug(1,"JBD: Skipping superblock update on recovered sb "
"(start %ld, seq %d, errno %d)\n", "(start %u, seq %d, errno %d)\n",
journal->j_tail, journal->j_tail_sequence, journal->j_tail, journal->j_tail_sequence,
journal->j_errno); journal->j_errno);
goto out; goto out;
} }
spin_lock(&journal->j_state_lock); spin_lock(&journal->j_state_lock);
jbd_debug(1,"JBD: updating superblock (start %ld, seq %d, errno %d)\n", jbd_debug(1,"JBD: updating superblock (start %u, seq %d, errno %d)\n",
journal->j_tail, journal->j_tail_sequence, journal->j_errno); journal->j_tail, journal->j_tail_sequence, journal->j_errno);
sb->s_sequence = cpu_to_be32(journal->j_tail_sequence); sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
...@@ -1371,7 +1371,7 @@ int journal_flush(journal_t *journal) ...@@ -1371,7 +1371,7 @@ int journal_flush(journal_t *journal)
{ {
int err = 0; int err = 0;
transaction_t *transaction = NULL; transaction_t *transaction = NULL;
unsigned long old_tail; unsigned int old_tail;
spin_lock(&journal->j_state_lock); spin_lock(&journal->j_state_lock);
......
...@@ -70,7 +70,7 @@ static int do_readahead(journal_t *journal, unsigned int start) ...@@ -70,7 +70,7 @@ static int do_readahead(journal_t *journal, unsigned int start)
{ {
int err; int err;
unsigned int max, nbufs, next; unsigned int max, nbufs, next;
unsigned long blocknr; unsigned int blocknr;
struct buffer_head *bh; struct buffer_head *bh;
struct buffer_head * bufs[MAXBUF]; struct buffer_head * bufs[MAXBUF];
...@@ -132,7 +132,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal, ...@@ -132,7 +132,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
unsigned int offset) unsigned int offset)
{ {
int err; int err;
unsigned long blocknr; unsigned int blocknr;
struct buffer_head *bh; struct buffer_head *bh;
*bhp = NULL; *bhp = NULL;
...@@ -314,7 +314,7 @@ static int do_one_pass(journal_t *journal, ...@@ -314,7 +314,7 @@ static int do_one_pass(journal_t *journal,
struct recovery_info *info, enum passtype pass) struct recovery_info *info, enum passtype pass)
{ {
unsigned int first_commit_ID, next_commit_ID; unsigned int first_commit_ID, next_commit_ID;
unsigned long next_log_block; unsigned int next_log_block;
int err, success = 0; int err, success = 0;
journal_superblock_t * sb; journal_superblock_t * sb;
journal_header_t * tmp; journal_header_t * tmp;
...@@ -367,14 +367,14 @@ static int do_one_pass(journal_t *journal, ...@@ -367,14 +367,14 @@ static int do_one_pass(journal_t *journal,
if (tid_geq(next_commit_ID, info->end_transaction)) if (tid_geq(next_commit_ID, info->end_transaction))
break; break;
jbd_debug(2, "Scanning for sequence ID %u at %lu/%lu\n", jbd_debug(2, "Scanning for sequence ID %u at %u/%u\n",
next_commit_ID, next_log_block, journal->j_last); next_commit_ID, next_log_block, journal->j_last);
/* Skip over each chunk of the transaction looking /* Skip over each chunk of the transaction looking
* either the next descriptor block or the final commit * either the next descriptor block or the final commit
* record. */ * record. */
jbd_debug(3, "JBD: checking block %ld\n", next_log_block); jbd_debug(3, "JBD: checking block %u\n", next_log_block);
err = jread(&bh, journal, next_log_block); err = jread(&bh, journal, next_log_block);
if (err) if (err)
goto failed; goto failed;
...@@ -429,7 +429,7 @@ static int do_one_pass(journal_t *journal, ...@@ -429,7 +429,7 @@ static int do_one_pass(journal_t *journal,
tagp = &bh->b_data[sizeof(journal_header_t)]; tagp = &bh->b_data[sizeof(journal_header_t)];
while ((tagp - bh->b_data +sizeof(journal_block_tag_t)) while ((tagp - bh->b_data +sizeof(journal_block_tag_t))
<= journal->j_blocksize) { <= journal->j_blocksize) {
unsigned long io_block; unsigned int io_block;
tag = (journal_block_tag_t *) tagp; tag = (journal_block_tag_t *) tagp;
flags = be32_to_cpu(tag->t_flags); flags = be32_to_cpu(tag->t_flags);
...@@ -443,10 +443,10 @@ static int do_one_pass(journal_t *journal, ...@@ -443,10 +443,10 @@ static int do_one_pass(journal_t *journal,
success = err; success = err;
printk (KERN_ERR printk (KERN_ERR
"JBD: IO error %d recovering " "JBD: IO error %d recovering "
"block %ld in log\n", "block %u in log\n",
err, io_block); err, io_block);
} else { } else {
unsigned long blocknr; unsigned int blocknr;
J_ASSERT(obh != NULL); J_ASSERT(obh != NULL);
blocknr = be32_to_cpu(tag->t_blocknr); blocknr = be32_to_cpu(tag->t_blocknr);
...@@ -581,7 +581,7 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, ...@@ -581,7 +581,7 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh,
max = be32_to_cpu(header->r_count); max = be32_to_cpu(header->r_count);
while (offset < max) { while (offset < max) {
unsigned long blocknr; unsigned int blocknr;
int err; int err;
blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset))); blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset)));
......
...@@ -101,7 +101,7 @@ struct jbd_revoke_record_s ...@@ -101,7 +101,7 @@ struct jbd_revoke_record_s
{ {
struct list_head hash; struct list_head hash;
tid_t sequence; /* Used for recovery only */ tid_t sequence; /* Used for recovery only */
unsigned long blocknr; unsigned int blocknr;
}; };
...@@ -126,7 +126,7 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int); ...@@ -126,7 +126,7 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int);
/* Utility functions to maintain the revoke table */ /* Utility functions to maintain the revoke table */
/* Borrowed from buffer.c: this is a tried and tested block hash function */ /* Borrowed from buffer.c: this is a tried and tested block hash function */
static inline int hash(journal_t *journal, unsigned long block) static inline int hash(journal_t *journal, unsigned int block)
{ {
struct jbd_revoke_table_s *table = journal->j_revoke; struct jbd_revoke_table_s *table = journal->j_revoke;
int hash_shift = table->hash_shift; int hash_shift = table->hash_shift;
...@@ -136,7 +136,7 @@ static inline int hash(journal_t *journal, unsigned long block) ...@@ -136,7 +136,7 @@ static inline int hash(journal_t *journal, unsigned long block)
(block << (hash_shift - 12))) & (table->hash_size - 1); (block << (hash_shift - 12))) & (table->hash_size - 1);
} }
static int insert_revoke_hash(journal_t *journal, unsigned long blocknr, static int insert_revoke_hash(journal_t *journal, unsigned int blocknr,
tid_t seq) tid_t seq)
{ {
struct list_head *hash_list; struct list_head *hash_list;
...@@ -166,7 +166,7 @@ static int insert_revoke_hash(journal_t *journal, unsigned long blocknr, ...@@ -166,7 +166,7 @@ static int insert_revoke_hash(journal_t *journal, unsigned long blocknr,
/* Find a revoke record in the journal's hash table. */ /* Find a revoke record in the journal's hash table. */
static struct jbd_revoke_record_s *find_revoke_record(journal_t *journal, static struct jbd_revoke_record_s *find_revoke_record(journal_t *journal,
unsigned long blocknr) unsigned int blocknr)
{ {
struct list_head *hash_list; struct list_head *hash_list;
struct jbd_revoke_record_s *record; struct jbd_revoke_record_s *record;
...@@ -332,7 +332,7 @@ void journal_destroy_revoke(journal_t *journal) ...@@ -332,7 +332,7 @@ void journal_destroy_revoke(journal_t *journal)
* by one. * by one.
*/ */
int journal_revoke(handle_t *handle, unsigned long blocknr, int journal_revoke(handle_t *handle, unsigned int blocknr,
struct buffer_head *bh_in) struct buffer_head *bh_in)
{ {
struct buffer_head *bh = NULL; struct buffer_head *bh = NULL;
...@@ -401,7 +401,7 @@ int journal_revoke(handle_t *handle, unsigned long blocknr, ...@@ -401,7 +401,7 @@ int journal_revoke(handle_t *handle, unsigned long blocknr,
} }
} }
jbd_debug(2, "insert revoke for block %lu, bh_in=%p\n", blocknr, bh_in); jbd_debug(2, "insert revoke for block %u, bh_in=%p\n", blocknr, bh_in);
err = insert_revoke_hash(journal, blocknr, err = insert_revoke_hash(journal, blocknr,
handle->h_transaction->t_tid); handle->h_transaction->t_tid);
BUFFER_TRACE(bh_in, "exit"); BUFFER_TRACE(bh_in, "exit");
...@@ -644,7 +644,7 @@ static void flush_descriptor(journal_t *journal, ...@@ -644,7 +644,7 @@ static void flush_descriptor(journal_t *journal,
*/ */
int journal_set_revoke(journal_t *journal, int journal_set_revoke(journal_t *journal,
unsigned long blocknr, unsigned int blocknr,
tid_t sequence) tid_t sequence)
{ {
struct jbd_revoke_record_s *record; struct jbd_revoke_record_s *record;
...@@ -668,7 +668,7 @@ int journal_set_revoke(journal_t *journal, ...@@ -668,7 +668,7 @@ int journal_set_revoke(journal_t *journal,
*/ */
int journal_test_revoke(journal_t *journal, int journal_test_revoke(journal_t *journal,
unsigned long blocknr, unsigned int blocknr,
tid_t sequence) tid_t sequence)
{ {
struct jbd_revoke_record_s *record; struct jbd_revoke_record_s *record;
......
...@@ -446,7 +446,7 @@ struct transaction_s ...@@ -446,7 +446,7 @@ struct transaction_s
/* /*
* Where in the log does this transaction's commit start? [no locking] * Where in the log does this transaction's commit start? [no locking]
*/ */
unsigned long t_log_start; unsigned int t_log_start;
/* Number of buffers on the t_buffers list [j_list_lock] */ /* Number of buffers on the t_buffers list [j_list_lock] */
int t_nr_buffers; int t_nr_buffers;
...@@ -701,26 +701,26 @@ struct journal_s ...@@ -701,26 +701,26 @@ struct journal_s
* Journal head: identifies the first unused block in the journal. * Journal head: identifies the first unused block in the journal.
* [j_state_lock] * [j_state_lock]
*/ */
unsigned long j_head; unsigned int j_head;
/* /*
* Journal tail: identifies the oldest still-used block in the journal. * Journal tail: identifies the oldest still-used block in the journal.
* [j_state_lock] * [j_state_lock]
*/ */
unsigned long j_tail; unsigned int j_tail;
/* /*
* Journal free: how many free blocks are there in the journal? * Journal free: how many free blocks are there in the journal?
* [j_state_lock] * [j_state_lock]
*/ */
unsigned long j_free; unsigned int j_free;
/* /*
* Journal start and end: the block numbers of the first usable block * Journal start and end: the block numbers of the first usable block
* and one beyond the last usable block in the journal. [j_state_lock] * and one beyond the last usable block in the journal. [j_state_lock]
*/ */
unsigned long j_first; unsigned int j_first;
unsigned long j_last; unsigned int j_last;
/* /*
* Device, blocksize and starting block offset for the location where we * Device, blocksize and starting block offset for the location where we
...@@ -728,7 +728,7 @@ struct journal_s ...@@ -728,7 +728,7 @@ struct journal_s
*/ */
struct block_device *j_dev; struct block_device *j_dev;
int j_blocksize; int j_blocksize;
unsigned long j_blk_offset; unsigned int j_blk_offset;
/* /*
* Device which holds the client fs. For internal journal this will be * Device which holds the client fs. For internal journal this will be
...@@ -859,7 +859,7 @@ extern void __journal_clean_data_list(transaction_t *transaction); ...@@ -859,7 +859,7 @@ extern void __journal_clean_data_list(transaction_t *transaction);
/* Log buffer allocation */ /* Log buffer allocation */
extern struct journal_head * journal_get_descriptor_buffer(journal_t *); extern struct journal_head * journal_get_descriptor_buffer(journal_t *);
int journal_next_log_block(journal_t *, unsigned long *); int journal_next_log_block(journal_t *, unsigned int *);
/* Commit management */ /* Commit management */
extern void journal_commit_transaction(journal_t *); extern void journal_commit_transaction(journal_t *);
...@@ -874,7 +874,7 @@ extern int ...@@ -874,7 +874,7 @@ extern int
journal_write_metadata_buffer(transaction_t *transaction, journal_write_metadata_buffer(transaction_t *transaction,
struct journal_head *jh_in, struct journal_head *jh_in,
struct journal_head **jh_out, struct journal_head **jh_out,
unsigned long blocknr); unsigned int blocknr);
/* Transaction locking */ /* Transaction locking */
extern void __wait_on_journal (journal_t *); extern void __wait_on_journal (journal_t *);
...@@ -942,7 +942,7 @@ extern void journal_abort (journal_t *, int); ...@@ -942,7 +942,7 @@ extern void journal_abort (journal_t *, int);
extern int journal_errno (journal_t *); extern int journal_errno (journal_t *);
extern void journal_ack_err (journal_t *); extern void journal_ack_err (journal_t *);
extern int journal_clear_err (journal_t *); extern int journal_clear_err (journal_t *);
extern int journal_bmap(journal_t *, unsigned long, unsigned long *); extern int journal_bmap(journal_t *, unsigned int, unsigned int *);
extern int journal_force_commit(journal_t *); extern int journal_force_commit(journal_t *);
/* /*
...@@ -976,14 +976,14 @@ extern int journal_init_revoke_caches(void); ...@@ -976,14 +976,14 @@ extern int journal_init_revoke_caches(void);
extern void journal_destroy_revoke(journal_t *); extern void journal_destroy_revoke(journal_t *);
extern int journal_revoke (handle_t *, extern int journal_revoke (handle_t *,
unsigned long, struct buffer_head *); unsigned int, struct buffer_head *);
extern int journal_cancel_revoke(handle_t *, struct journal_head *); extern int journal_cancel_revoke(handle_t *, struct journal_head *);
extern void journal_write_revoke_records(journal_t *, extern void journal_write_revoke_records(journal_t *,
transaction_t *, int); transaction_t *, int);
/* Recovery revoke support */ /* Recovery revoke support */
extern int journal_set_revoke(journal_t *, unsigned long, tid_t); extern int journal_set_revoke(journal_t *, unsigned int, tid_t);
extern int journal_test_revoke(journal_t *, unsigned long, tid_t); extern int journal_test_revoke(journal_t *, unsigned int, tid_t);
extern void journal_clear_revoke(journal_t *); extern void journal_clear_revoke(journal_t *);
extern void journal_switch_revoke_table(journal_t *journal); extern void journal_switch_revoke_table(journal_t *journal);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment