Skip to content

Commit

Permalink
[PATCH] ext3: inode numbers are unsigned long
Browse files Browse the repository at this point in the history
This is primarily format string fixes, with changes to ialloc.c where large
inode counts could overflow, and also pass around journal_inum as an
unsigned long, just to be pedantic about it....

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Cc: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Eric Sandeen authored and Linus Torvalds committed Sep 27, 2006
1 parent 41f04d8 commit eee194e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions fs/ext3/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
static int find_group_dir(struct super_block *sb, struct inode *parent)
{
int ngroups = EXT3_SB(sb)->s_groups_count;
int freei, avefreei;
unsigned int freei, avefreei;
struct ext3_group_desc *desc, *best_desc = NULL;
struct buffer_head *bh;
int group, best_group = -1;
Expand Down Expand Up @@ -261,10 +261,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
struct ext3_super_block *es = sbi->s_es;
int ngroups = sbi->s_groups_count;
int inodes_per_group = EXT3_INODES_PER_GROUP(sb);
int freei, avefreei;
unsigned int freei, avefreei;
ext3_fsblk_t freeb, avefreeb;
ext3_fsblk_t blocks_per_dir;
int ndirs;
unsigned int ndirs;
int max_debt, max_dirs, min_inodes;
ext3_grpblk_t min_blocks;
int group = -1, i;
Expand Down
2 changes: 1 addition & 1 deletion fs/ext3/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
*/
if (!bh) {
ext3_error(inode->i_sb, "ext3_free_branches",
"Read failure, inode=%ld, block="E3FSBLK,
"Read failure, inode=%lu, block="E3FSBLK,
inode->i_ino, nr);
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions fs/ext3/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1919,8 +1919,8 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
if (!err)
list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan);

jbd_debug(4, "superblock will point to %ld\n", inode->i_ino);
jbd_debug(4, "orphan inode %ld will point to %d\n",
jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
jbd_debug(4, "orphan inode %lu will point to %d\n",
inode->i_ino, NEXT_ORPHAN(inode));
out_unlock:
unlock_super(sb);
Expand Down
25 changes: 13 additions & 12 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
unsigned long journal_devnum);
static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
int);
unsigned int);
static void ext3_commit_super (struct super_block * sb,
struct ext3_super_block * es,
int sync);
Expand Down Expand Up @@ -376,7 +376,7 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi)
list_for_each(l, &sbi->s_orphan) {
struct inode *inode = orphan_list_entry(l);
printk(KERN_ERR " "
"inode %s:%ld at %p: mode %o, nlink %d, next %d\n",
"inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
inode->i_sb->s_id, inode->i_ino, inode,
inode->i_mode, inode->i_nlink,
NEXT_ORPHAN(inode));
Expand Down Expand Up @@ -753,7 +753,7 @@ static ext3_fsblk_t get_sb_block(void **data)
}

static int parse_options (char *options, struct super_block *sb,
unsigned long *inum, unsigned long *journal_devnum,
unsigned int *inum, unsigned long *journal_devnum,
ext3_fsblk_t *n_blocks_count, int is_remount)
{
struct ext3_sb_info *sbi = EXT3_SB(sb);
Expand Down Expand Up @@ -1306,17 +1306,17 @@ static void ext3_orphan_cleanup (struct super_block * sb,
DQUOT_INIT(inode);
if (inode->i_nlink) {
printk(KERN_DEBUG
"%s: truncating inode %ld to %Ld bytes\n",
"%s: truncating inode %lu to %Ld bytes\n",
__FUNCTION__, inode->i_ino, inode->i_size);
jbd_debug(2, "truncating inode %ld to %Ld bytes\n",
jbd_debug(2, "truncating inode %lu to %Ld bytes\n",
inode->i_ino, inode->i_size);
ext3_truncate(inode);
nr_truncates++;
} else {
printk(KERN_DEBUG
"%s: deleting unreferenced inode %ld\n",
"%s: deleting unreferenced inode %lu\n",
__FUNCTION__, inode->i_ino);
jbd_debug(2, "deleting unreferenced inode %ld\n",
jbd_debug(2, "deleting unreferenced inode %lu\n",
inode->i_ino);
nr_orphans++;
}
Expand Down Expand Up @@ -1395,7 +1395,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
ext3_fsblk_t sb_block = get_sb_block(&data);
ext3_fsblk_t logic_sb_block;
unsigned long offset = 0;
unsigned long journal_inum = 0;
unsigned int journal_inum = 0;
unsigned long journal_devnum = 0;
unsigned long def_mount_opts;
struct inode *root;
Expand Down Expand Up @@ -1844,7 +1844,8 @@ static void ext3_init_journal_params(struct super_block *sb, journal_t *journal)
spin_unlock(&journal->j_state_lock);
}

static journal_t *ext3_get_journal(struct super_block *sb, int journal_inum)
static journal_t *ext3_get_journal(struct super_block *sb,
unsigned int journal_inum)
{
struct inode *journal_inode;
journal_t *journal;
Expand Down Expand Up @@ -1979,7 +1980,7 @@ static int ext3_load_journal(struct super_block *sb,
unsigned long journal_devnum)
{
journal_t *journal;
int journal_inum = le32_to_cpu(es->s_journal_inum);
unsigned int journal_inum = le32_to_cpu(es->s_journal_inum);
dev_t journal_dev;
int err = 0;
int really_read_only;
Expand Down Expand Up @@ -2065,7 +2066,7 @@ static int ext3_load_journal(struct super_block *sb,

static int ext3_create_journal(struct super_block * sb,
struct ext3_super_block * es,
int journal_inum)
unsigned int journal_inum)
{
journal_t *journal;

Expand All @@ -2078,7 +2079,7 @@ static int ext3_create_journal(struct super_block * sb,
if (!(journal = ext3_get_journal(sb, journal_inum)))
return -EINVAL;

printk(KERN_INFO "EXT3-fs: creating new journal on inode %d\n",
printk(KERN_INFO "EXT3-fs: creating new journal on inode %u\n",
journal_inum);

if (journal_create(journal)) {
Expand Down
16 changes: 8 additions & 8 deletions fs/ext3/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

#ifdef EXT3_XATTR_DEBUG
# define ea_idebug(inode, f...) do { \
printk(KERN_DEBUG "inode %s:%ld: ", \
printk(KERN_DEBUG "inode %s:%lu: ", \
inode->i_sb->s_id, inode->i_ino); \
printk(f); \
printk("\n"); \
Expand Down Expand Up @@ -233,7 +233,7 @@ ext3_xattr_block_get(struct inode *inode, int name_index, const char *name,
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
if (ext3_xattr_check_block(bh)) {
bad_block: ext3_error(inode->i_sb, __FUNCTION__,
"inode %ld: bad block "E3FSBLK, inode->i_ino,
"inode %lu: bad block "E3FSBLK, inode->i_ino,
EXT3_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
Expand Down Expand Up @@ -375,7 +375,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
if (ext3_xattr_check_block(bh)) {
ext3_error(inode->i_sb, __FUNCTION__,
"inode %ld: bad block "E3FSBLK, inode->i_ino,
"inode %lu: bad block "E3FSBLK, inode->i_ino,
EXT3_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
Expand Down Expand Up @@ -647,7 +647,7 @@ ext3_xattr_block_find(struct inode *inode, struct ext3_xattr_info *i,
le32_to_cpu(BHDR(bs->bh)->h_refcount));
if (ext3_xattr_check_block(bs->bh)) {
ext3_error(sb, __FUNCTION__,
"inode %ld: bad block "E3FSBLK, inode->i_ino,
"inode %lu: bad block "E3FSBLK, inode->i_ino,
EXT3_I(inode)->i_file_acl);
error = -EIO;
goto cleanup;
Expand Down Expand Up @@ -848,7 +848,7 @@ ext3_xattr_block_set(handle_t *handle, struct inode *inode,

bad_block:
ext3_error(inode->i_sb, __FUNCTION__,
"inode %ld: bad block "E3FSBLK, inode->i_ino,
"inode %lu: bad block "E3FSBLK, inode->i_ino,
EXT3_I(inode)->i_file_acl);
goto cleanup;

Expand Down Expand Up @@ -1077,14 +1077,14 @@ ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl);
if (!bh) {
ext3_error(inode->i_sb, __FUNCTION__,
"inode %ld: block "E3FSBLK" read error", inode->i_ino,
"inode %lu: block "E3FSBLK" read error", inode->i_ino,
EXT3_I(inode)->i_file_acl);
goto cleanup;
}
if (BHDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
BHDR(bh)->h_blocks != cpu_to_le32(1)) {
ext3_error(inode->i_sb, __FUNCTION__,
"inode %ld: bad block "E3FSBLK, inode->i_ino,
"inode %lu: bad block "E3FSBLK, inode->i_ino,
EXT3_I(inode)->i_file_acl);
goto cleanup;
}
Expand Down Expand Up @@ -1211,7 +1211,7 @@ ext3_xattr_cache_find(struct inode *inode, struct ext3_xattr_header *header,
bh = sb_bread(inode->i_sb, ce->e_block);
if (!bh) {
ext3_error(inode->i_sb, __FUNCTION__,
"inode %ld: block %lu read error",
"inode %lu: block %lu read error",
inode->i_ino, (unsigned long) ce->e_block);
} else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
EXT3_XATTR_REFCOUNT_MAX) {
Expand Down

0 comments on commit eee194e

Please sign in to comment.