2006-09-08 21:39:19

by Dave Kleikamp

[permalink] [raw]
Subject: [RFC:PATCH 000/002] EXT3: cleanups in preparation for ext4 clone

I'm working on rebasing Mingming's ext4 patches on the -mm tree, and have
noticed a couple cleanups that would be nice to have in ext3 before the
code diverges.

Thanks,
Shaggy

--
David Kleikamp
IBM Linux Technology Center


2006-09-08 21:39:25

by Dave Kleikamp

[permalink] [raw]
Subject: [RFC:PATCH 001/002] EXT3: More whitespace cleanups

EXT3: More whitespace cleanups

More white space cleanups in preparation of cloning ext4 from ext3.
Removing spaces that precede a tab.

Signed-off-by: Dave Kleikamp <[email protected]>

---
diff -Nurp linux000/fs/ext3/acl.c linux001/fs/ext3/acl.c
--- linux000/fs/ext3/acl.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/acl.c 2006-09-08 16:25:07.000000000 -0500
@@ -258,7 +258,7 @@ ext3_set_acl(handle_t *handle, struct in
default:
return -EINVAL;
}
- if (acl) {
+ if (acl) {
value = ext3_acl_to_disk(acl, &size);
if (IS_ERR(value))
return (int)PTR_ERR(value);
diff -Nurp linux000/fs/ext3/balloc.c linux001/fs/ext3/balloc.c
--- linux000/fs/ext3/balloc.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/balloc.c 2006-09-08 16:25:07.000000000 -0500
@@ -40,7 +40,7 @@

/**
* ext3_get_group_desc() -- load group descriptor from disk
- * @sb: super block
+ * @sb: super block
* @block_group: given block group
* @bh: pointer to the buffer head to store the block
* group descriptor
@@ -355,7 +355,7 @@ void ext3_init_block_alloc_info(struct i
rsv->rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
rsv->rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;

- /*
+ /*
* if filesystem is mounted with NORESERVATION, the goal
* reservation window size is set to zero to indicate
* block reservation is off
@@ -681,7 +681,7 @@ bitmap_search_next_usable_block(ext3_grp
jbd_lock_bh_state(bh);
if (jh->b_committed_data)
start = ext3_find_next_zero_bit(jh->b_committed_data,
- maxblocks, next);
+ maxblocks, next);
jbd_unlock_bh_state(bh);
}
return -1;
@@ -790,10 +790,10 @@ claim_block(spinlock_t *lock, ext3_grpbl
* and at last, allocate the blocks by claiming the found free bit as allocated.
*
* To set the range of this allocation:
- * if there is a reservation window, only try to allocate block(s) from the
+ * if there is a reservation window, only try to allocate block(s) from the
* file's own reservation window;
* Otherwise, the allocation range starts from the give goal block, ends at
- * the block group's last block.
+ * the block group's last block.
*
* If we failed to allocate the desired block then we may end up crossing to a
* new bitmap. In that case we must release write access to the old one via
@@ -880,12 +880,12 @@ fail_access:
}

/**
- * find_next_reservable_window():
+ * find_next_reservable_window():
* find a reservable space within the given range.
* It does not allocate the reservation window for now:
* alloc_new_reservation() will do the work later.
*
- * @search_head: the head of the searching list;
+ * @search_head: the head of the searching list;
* This is not necessarily the list head of the whole filesystem
*
* We have both head and start_block to assist the search
@@ -893,12 +893,12 @@ fail_access:
* but we will shift to the place where start_block is,
* then start from there, when looking for a reservable space.
*
- * @size: the target new reservation window size
+ * @size: the target new reservation window size
*
- * @group_first_block: the first block we consider to start
+ * @group_first_block: the first block we consider to start
* the real search from
*
- * @last_block:
+ * @last_block:
* the maximum block number that our goal reservable space
* could start from. This is normally the last block in this
* group. The search will end when we found the start of next
@@ -906,10 +906,10 @@ fail_access:
* This could handle the cross boundary reservation window
* request.
*
- * basically we search from the given range, rather than the whole
- * reservation double linked list, (start_block, last_block)
- * to find a free region that is of my size and has not
- * been reserved.
+ * basically we search from the given range, rather than the whole
+ * reservation double linked list, (start_block, last_block)
+ * to find a free region that is of my size and has not
+ * been reserved.
*
*/
static int find_next_reservable_window(
@@ -962,7 +962,7 @@ static int find_next_reservable_window(
/*
* Found a reserveable space big enough. We could
* have a reservation across the group boundary here
- */
+ */
break;
}
}
@@ -998,7 +998,7 @@ static int find_next_reservable_window(
}

/**
- * alloc_new_reservation()--allocate a new reservation window
+ * alloc_new_reservation()--allocate a new reservation window
*
* To make a new reservation, we search part of the filesystem
* reservation list (the list that inside the group). We try to
diff -Nurp linux000/fs/ext3/dir.c linux001/fs/ext3/dir.c
--- linux000/fs/ext3/dir.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/dir.c 2006-09-08 16:25:07.000000000 -0500
@@ -70,7 +70,7 @@ int ext3_check_dir_entry (const char * f
unsigned long offset)
{
const char * error_msg = NULL;
- const int rlen = le16_to_cpu(de->rec_len);
+ const int rlen = le16_to_cpu(de->rec_len);

if (rlen < EXT3_DIR_REC_LEN(1))
error_msg = "rec_len is smaller than minimal";
diff -Nurp linux000/fs/ext3/hash.c linux001/fs/ext3/hash.c
--- linux000/fs/ext3/hash.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/hash.c 2006-09-08 16:25:07.000000000 -0500
@@ -95,7 +95,7 @@ int ext3fs_dirhash(const char *name, int
__u32 minor_hash = 0;
const char *p;
int i;
- __u32 in[8], buf[4];
+ __u32 in[8], buf[4];

/* Initialize the default seed for the hash checksum functions */
buf[0] = 0x67452301;
diff -Nurp linux000/fs/ext3/inode.c linux001/fs/ext3/inode.c
--- linux000/fs/ext3/inode.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/inode.c 2006-09-08 16:25:07.000000000 -0500
@@ -13,11 +13,11 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*
* Goal-directed block allocation by Stephen Tweedie
- * ([email protected]), 1993, 1998
+ * ([email protected]), 1993, 1998
* Big-endian to little-endian byte-swapping/bitmaps by
* David S. Miller ([email protected]), 1995
* 64-bit file support on 64-bit platforms by Jakub Jelinek
- * ([email protected])
+ * ([email protected])
*
* Assorted race fixes, rewrite of ext3_get_block() by Al Viro, 2000
*/
@@ -471,7 +471,7 @@ static ext3_fsblk_t ext3_find_goal(struc
* ext3_blks_to_allocate: Look up the block map and count the number
* of direct blocks need to be allocated for the given branch.
*
- * @branch: chain of indirect blocks
+ * @branch: chain of indirect blocks
* @k: number of blocks need for indirect blocks
* @blks: number of data blocks to be mapped.
* @blocks_to_boundary: the offset in the indirect block
@@ -1099,7 +1099,7 @@ static int walk_page_buffers( handle_t *

for ( bh = head, block_start = 0;
ret == 0 && (bh != head || !block_start);
- block_start = block_end, bh = next)
+ block_start = block_end, bh = next)
{
next = bh->b_this_page;
block_end = block_start + blocksize;
diff -Nurp linux000/fs/ext3/namei.c linux001/fs/ext3/namei.c
--- linux000/fs/ext3/namei.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/namei.c 2006-09-08 16:25:07.000000000 -0500
@@ -15,13 +15,13 @@
* Big-endian to little-endian byte-swapping/bitmaps by
* David S. Miller ([email protected]), 1995
* Directory entry file type support and forward compatibility hooks
- * for B-tree directories by Theodore Ts'o ([email protected]), 1998
+ * for B-tree directories by Theodore Ts'o ([email protected]), 1998
* Hash Tree Directory indexing (c)
- * Daniel Phillips, 2001
+ * Daniel Phillips, 2001
* Hash Tree Directory indexing porting
- * Christopher Li, 2002
+ * Christopher Li, 2002
* Hash Tree Directory indexing cleanup
- * Theodore Ts'o, 2002
+ * Theodore Ts'o, 2002
*/

#include <linux/fs.h>
@@ -279,7 +279,7 @@ static struct stats dx_show_leaf(struct
((char *) de - base));
}
space += EXT3_DIR_REC_LEN(de->name_len);
- names++;
+ names++;
}
de = (struct ext3_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
}
@@ -1689,7 +1689,7 @@ static int ext3_mknod (struct inode * di

retry:
handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
- EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
if (IS_ERR(handle))
return PTR_ERR(handle);
@@ -1817,7 +1817,7 @@ static int empty_dir (struct inode * ino
!le32_to_cpu(de1->inode) ||
strcmp (".", de->name) ||
strcmp ("..", de1->name)) {
- ext3_warning (inode->i_sb, "empty_dir",
+ ext3_warning (inode->i_sb, "empty_dir",
"bad directory (dir #%lu) - no `.' or `..'",
inode->i_ino);
brelse (bh);
@@ -2130,7 +2130,7 @@ static int ext3_symlink (struct inode *

retry:
handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
- EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
if (IS_ERR(handle))
return PTR_ERR(handle);
@@ -2228,7 +2228,7 @@ static int ext3_rename (struct inode * o
DQUOT_INIT(new_dentry->d_inode);
handle = ext3_journal_start(old_dir, 2 *
EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) +
- EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);
+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);
if (IS_ERR(handle))
return PTR_ERR(handle);

diff -Nurp linux000/fs/ext3/super.c linux001/fs/ext3/super.c
--- linux000/fs/ext3/super.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/ext3/super.c 2006-09-08 16:25:07.000000000 -0500
@@ -733,8 +733,8 @@ static match_table_t tokens = {

static ext3_fsblk_t get_sb_block(void **data)
{
- ext3_fsblk_t sb_block;
- char *options = (char *) *data;
+ ext3_fsblk_t sb_block;
+ char *options = (char *) *data;

if (!options || strncmp(options, "sb=", 3) != 0)
return 1; /* Default location */
@@ -2740,7 +2740,7 @@ static int __init init_ext3_fs(void)
out:
destroy_inodecache();
out1:
- exit_ext3_xattr();
+ exit_ext3_xattr();
return err;
}

diff -Nurp linux000/fs/jbd/checkpoint.c linux001/fs/jbd/checkpoint.c
--- linux000/fs/jbd/checkpoint.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/jbd/checkpoint.c 2006-09-08 16:25:07.000000000 -0500
@@ -480,7 +480,7 @@ static int journal_clean_one_cp_list(str
if (!jh)
return 0;

- last_jh = jh->b_cpprev;
+ last_jh = jh->b_cpprev;
do {
jh = next_jh;
next_jh = jh->b_cpnext;
diff -Nurp linux000/fs/jbd/journal.c linux001/fs/jbd/journal.c
--- linux000/fs/jbd/journal.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/jbd/journal.c 2006-09-08 16:25:07.000000000 -0500
@@ -181,7 +181,7 @@ loop:
transaction->t_expires))
should_sleep = 0;
if (journal->j_flags & JFS_UNMOUNT)
- should_sleep = 0;
+ should_sleep = 0;
if (should_sleep) {
spin_unlock(&journal->j_state_lock);
schedule();
diff -Nurp linux000/fs/jbd/recovery.c linux001/fs/jbd/recovery.c
--- linux000/fs/jbd/recovery.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/jbd/recovery.c 2006-09-08 16:25:07.000000000 -0500
@@ -314,7 +314,7 @@ static int do_one_pass(journal_t *journa
unsigned long next_log_block;
int err, success = 0;
journal_superblock_t * sb;
- journal_header_t * tmp;
+ journal_header_t * tmp;
struct buffer_head * bh;
unsigned int sequence;
int blocktype;
diff -Nurp linux000/fs/jbd/transaction.c linux001/fs/jbd/transaction.c
--- linux000/fs/jbd/transaction.c 2006-09-08 07:24:23.000000000 -0500
+++ linux001/fs/jbd/transaction.c 2006-09-08 16:25:07.000000000 -0500
@@ -580,7 +580,7 @@ repeat:
*/
JBUFFER_TRACE(jh, "Unexpected dirty buffer");
jbd_unexpected_dirty_buffer(jh);
- }
+ }

unlock_buffer(bh);

@@ -1373,7 +1373,7 @@ int journal_stop(handle_t *handle)
if (handle->h_sync ||
transaction->t_outstanding_credits >
journal->j_max_transaction_buffers ||
- time_after_eq(jiffies, transaction->t_expires)) {
+ time_after_eq(jiffies, transaction->t_expires)) {
/* Do this even for aborted journals: an abort still
* completes the commit thread, it just doesn't write
* anything to disk. */
@@ -1908,7 +1908,7 @@ void journal_invalidatepage(journal_t *j
next = bh->b_this_page;

if (offset <= curr_off) {
- /* This block is wholly outside the truncation point */
+ /* This block is wholly outside the truncation point */
lock_buffer(bh);
may_free &= journal_unmap_buffer(journal, bh);
unlock_buffer(bh);
diff -Nurp linux000/include/linux/ext3_fs.h linux001/include/linux/ext3_fs.h
--- linux000/include/linux/ext3_fs.h 2006-09-08 07:24:30.000000000 -0500
+++ linux001/include/linux/ext3_fs.h 2006-09-08 16:25:07.000000000 -0500
@@ -494,7 +494,7 @@ struct ext3_super_block {
__u8 s_reserved_char_pad;
__u16 s_reserved_word_pad;
__le32 s_default_mount_opts;
- __le32 s_first_meta_bg; /* First metablock block group */
+ __le32 s_first_meta_bg; /* First metablock block group */
__u32 s_reserved[190]; /* Padding to the end of the block */
};

diff -Nurp linux000/include/linux/ext3_fs_i.h linux001/include/linux/ext3_fs_i.h
--- linux000/include/linux/ext3_fs_i.h 2006-09-08 07:23:29.000000000 -0500
+++ linux001/include/linux/ext3_fs_i.h 2006-09-08 16:25:07.000000000 -0500
@@ -35,7 +35,7 @@ struct ext3_reserve_window {
};

struct ext3_reserve_window_node {
- struct rb_node rsv_node;
+ struct rb_node rsv_node;
__u32 rsv_goal_size;
__u32 rsv_alloc_hit;
struct ext3_reserve_window rsv_window;
diff -Nurp linux000/include/linux/jbd.h linux001/include/linux/jbd.h
--- linux000/include/linux/jbd.h 2006-09-08 07:24:30.000000000 -0500
+++ linux001/include/linux/jbd.h 2006-09-08 16:25:07.000000000 -0500
@@ -64,7 +64,7 @@ extern int journal_enable_debug;
if ((n) <= journal_enable_debug) { \
printk (KERN_DEBUG "(%s, %d): %s: ", \
__FILE__, __LINE__, __FUNCTION__); \
- printk (f, ## a); \
+ printk (f, ## a); \
} \
} while (0)
#else
@@ -201,9 +201,9 @@ typedef struct journal_superblock_s

/* 0x0024 */
/* Remaining fields are only valid in a version-2 superblock */
- __be32 s_feature_compat; /* compatible feature set */
- __be32 s_feature_incompat; /* incompatible feature set */
- __be32 s_feature_ro_compat; /* readonly-compatible feature set */
+ __be32 s_feature_compat; /* compatible feature set */
+ __be32 s_feature_incompat; /* incompatible feature set */
+ __be32 s_feature_ro_compat; /* readonly-compatible feature set */
/* 0x0030 */
__u8 s_uuid[16]; /* 128-bit uuid for journal */

@@ -699,7 +699,7 @@ struct journal_s
wait_queue_head_t j_wait_updates;

/* Semaphore for locking against concurrent checkpoints */
- struct mutex j_checkpoint_mutex;
+ struct mutex j_checkpoint_mutex;

/*
* Journal head: identifies the first unused block in the journal.

--
David Kleikamp
IBM Linux Technology Center

2006-09-08 21:39:36

by Dave Kleikamp

[permalink] [raw]
Subject: [RFC:PATCH 002/002] EXT3: Fix sparse warnings

EXT3: Fix sparse warnings

Fixing up some endian-ness warnings in preparation to clone ext4 from ext3.

Signed-off-by: Dave Kleikamp <[email protected]>

---
diff -Nurp linux001/fs/ext3/resize.c linux002/fs/ext3/resize.c
--- linux001/fs/ext3/resize.c 2006-09-08 07:24:23.000000000 -0500
+++ linux002/fs/ext3/resize.c 2006-09-08 16:25:07.000000000 -0500
@@ -336,7 +336,7 @@ static int verify_reserved_gdb(struct su
unsigned five = 5;
unsigned seven = 7;
unsigned grp;
- __u32 *p = (__u32 *)primary->b_data;
+ __le32 *p = (__le32 *)primary->b_data;
int gdbackups = 0;

while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
@@ -380,7 +380,7 @@ static int add_new_gdb(handle_t *handle,
struct buffer_head *dind;
int gdbackups;
struct ext3_iloc iloc;
- __u32 *data;
+ __le32 *data;
int err;

if (test_opt(sb, DEBUG))
@@ -410,14 +410,14 @@ static int add_new_gdb(handle_t *handle,
goto exit_bh;
}

- data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
+ data = (__le32 *)(EXT3_I(inode)->i_data + EXT3_DIND_BLOCK);
dind = sb_bread(sb, le32_to_cpu(*data));
if (!dind) {
err = -EIO;
goto exit_bh;
}

- data = (__u32 *)dind->b_data;
+ data = (__le32 *)dind->b_data;
if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
ext3_warning(sb, __FUNCTION__,
"new group %u GDT block "E3FSBLK" not reserved",
@@ -519,7 +519,7 @@ static int reserve_backup_gdb(handle_t *
struct buffer_head *dind;
struct ext3_iloc iloc;
ext3_fsblk_t blk;
- __u32 *data, *end;
+ __le32 *data, *end;
int gdbackups = 0;
int res, i;
int err;
@@ -528,7 +528,7 @@ static int reserve_backup_gdb(handle_t *
if (!primary)
return -ENOMEM;

- data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
+ data = (__le32 *)(EXT3_I(inode)->i_data + EXT3_DIND_BLOCK);
dind = sb_bread(sb, le32_to_cpu(*data));
if (!dind) {
err = -EIO;
@@ -536,8 +536,8 @@ static int reserve_backup_gdb(handle_t *
}

blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
- data = (__u32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
- end = (__u32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
+ data = (__le32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
+ end = (__le32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);

/* Get each reserved primary GDT block and verify it holds backups */
for (res = 0; res < reserved_gdb; res++, blk++) {
@@ -545,7 +545,8 @@ static int reserve_backup_gdb(handle_t *
ext3_warning(sb, __FUNCTION__,
"reserved block "E3FSBLK
" not at offset %ld",
- blk, (long)(data - (__u32 *)dind->b_data));
+ blk,
+ (long)(data - (__le32 *)dind->b_data));
err = -EINVAL;
goto exit_bh;
}
@@ -560,7 +561,7 @@ static int reserve_backup_gdb(handle_t *
goto exit_bh;
}
if (++data >= end)
- data = (__u32 *)dind->b_data;
+ data = (__le32 *)dind->b_data;
}

for (i = 0; i < reserved_gdb; i++) {
@@ -584,7 +585,7 @@ static int reserve_backup_gdb(handle_t *
blk = input->group * EXT3_BLOCKS_PER_GROUP(sb);
for (i = 0; i < reserved_gdb; i++) {
int err2;
- data = (__u32 *)primary[i]->b_data;
+ data = (__le32 *)primary[i]->b_data;
/* printk("reserving backup %lu[%u] = %lu\n",
primary[i]->b_blocknr, gdbackups,
blk + primary[i]->b_blocknr); */
@@ -689,7 +690,7 @@ exit_err:
"can't update backup for group %d (err %d), "
"forcing fsck on next reboot", group, err);
sbi->s_mount_state &= ~EXT3_VALID_FS;
- sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS);
+ sbi->s_es->s_state &= cpu_to_le16(~EXT3_VALID_FS);
mark_buffer_dirty(sbi->s_sbh);
}
}
diff -Nurp linux001/fs/ext3/super.c linux002/fs/ext3/super.c
--- linux001/fs/ext3/super.c 2006-09-08 16:25:07.000000000 -0500
+++ linux002/fs/ext3/super.c 2006-09-08 16:25:07.000000000 -0500
@@ -2330,13 +2330,14 @@ static int ext3_remount (struct super_bl

ext3_mark_recovery_complete(sb, es);
} else {
- __le32 ret;
- if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
+ int ret;
+ __le32 ret_le;
+ if ((ret_le = EXT3_HAS_RO_COMPAT_FEATURE(sb,
~EXT3_FEATURE_RO_COMPAT_SUPP))) {
printk(KERN_WARNING "EXT3-fs: %s: couldn't "
"remount RDWR because of unsupported "
"optional features (%x).\n",
- sb->s_id, le32_to_cpu(ret));
+ sb->s_id, le32_to_cpu(ret_le));
err = -EROFS;
goto restore_opts;
}
diff -Nurp linux001/fs/jbd/journal.c linux002/fs/jbd/journal.c
--- linux001/fs/jbd/journal.c 2006-09-08 16:25:07.000000000 -0500
+++ linux002/fs/jbd/journal.c 2006-09-08 16:25:07.000000000 -0500
@@ -1094,7 +1094,7 @@ int journal_load(journal_t *journal)
/*
* Create a slab for this blocksize
*/
- err = journal_create_jbd_slab(cpu_to_be32(sb->s_blocksize));
+ err = journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize));
if (err)
return err;

diff -Nurp linux001/include/linux/ext3_fs.h linux002/include/linux/ext3_fs.h
--- linux001/include/linux/ext3_fs.h 2006-09-08 16:25:07.000000000 -0500
+++ linux002/include/linux/ext3_fs.h 2006-09-08 16:25:07.000000000 -0500
@@ -481,7 +481,7 @@ struct ext3_super_block {
*/
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
__u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- __u16 s_reserved_gdt_blocks; /* Per group desc for online growth */
+ __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
/*
* Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
*/

--
David Kleikamp
IBM Linux Technology Center

2006-09-08 21:56:21

by Andrew Morton

[permalink] [raw]
Subject: Re: [RFC:PATCH 000/002] EXT3: cleanups in preparation for ext4 clone

On Fri, 8 Sep 2006 17:39:17 -0400
Dave Kleikamp <[email protected]> wrote:

> I'm working on rebasing Mingming's ext4 patches on the -mm tree, and have
> noticed a couple cleanups that would be nice to have in ext3 before the
> code diverges.

Good idea, thanks.

I'll try to get all pending ext3/jbd stuff flushed out for 2.6.19-rc1 and
then we can put a plug in it for a while, get the ext4 copy-n-paste sorted
out. I'd suggest we aim to do this on the day after 2.6.19-rc1 is tagged.

Or maybe -rc2. The road to 2.6.19-rc1 is going to be rough - there's an
unusually large amount of work pending, and there is an unusual (although
still small) amount of overlap between the subsystem trees which people
will need to sort out. Because of this I expect it will take us more than
the nominal two weeks to reach -rc1.


2006-09-08 22:18:03

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: [RFC:PATCH 002/002] EXT3: Fix sparse warnings

On Fri, Sep 08, 2006 at 03:39:30PM -0600, Dave Kleikamp wrote:
> EXT3: Fix sparse warnings

> --- linux001/fs/ext3/resize.c
> +++ linux002/fs/ext3/resize.c

> @@ -380,7 +380,7 @@ static int add_new_gdb(handle_t *handle,
> struct buffer_head *dind;
> int gdbackups;
> struct ext3_iloc iloc;
> - __u32 *data;
> + __le32 *data;
> int err;
>
> if (test_opt(sb, DEBUG))
> @@ -410,14 +410,14 @@ static int add_new_gdb(handle_t *handle,
> goto exit_bh;
> }
>
> - data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
> + data = (__le32 *)(EXT3_I(inode)->i_data + EXT3_DIND_BLOCK);

Why cast is needed? i_data is __le32 * already.

> - data = (__u32 *)dind->b_data;
> + data = (__le32 *)dind->b_data;
> if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
> ext3_warning(sb, __FUNCTION__,
> "new group %u GDT block "E3FSBLK" not reserved",
> @@ -519,7 +519,7 @@ static int reserve_backup_gdb(handle_t *
> struct buffer_head *dind;
> struct ext3_iloc iloc;
> ext3_fsblk_t blk;
> - __u32 *data, *end;
> + __le32 *data, *end;
> int gdbackups = 0;
> int res, i;
> int err;
> @@ -528,7 +528,7 @@ static int reserve_backup_gdb(handle_t *
> if (!primary)
> return -ENOMEM;
>
> - data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
> + data = (__le32 *)(EXT3_I(inode)->i_data + EXT3_DIND_BLOCK);

Ditto.

> --- linux001/fs/ext3/super.c
> +++ linux002/fs/ext3/super.c
> @@ -2330,13 +2330,14 @@ static int ext3_remount (struct super_bl
>
> ext3_mark_recovery_complete(sb, es);
> } else {
> - __le32 ret;
> - if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
> + int ret;
> + __le32 ret_le;
> + if ((ret_le = EXT3_HAS_RO_COMPAT_FEATURE(sb,
> ~EXT3_FEATURE_RO_COMPAT_SUPP))) {
> printk(KERN_WARNING "EXT3-fs: %s: couldn't "
> "remount RDWR because of unsupported "
> "optional features (%x).\n",
> - sb->s_id, le32_to_cpu(ret));
> + sb->s_id, le32_to_cpu(ret_le));
> err = -EROFS;
> goto restore_opts;
> }

Get rid of "err = ret;" assignment below. It would be cleaner than
introducing new var.


2006-09-10 14:31:45

by Dave Kleikamp

[permalink] [raw]
Subject: Re: [RFC:PATCH 002/002] EXT3: Fix sparse warnings

Andrew,
The new patch below can replace ext3-fix-sparse-warnings.patch.

On Sat, 2006-09-09 at 02:17 +0400, Alexey Dobriyan wrote:
> On Fri, Sep 08, 2006 at 03:39:30PM -0600, Dave Kleikamp wrote:
> > EXT3: Fix sparse warnings
>
> > --- linux001/fs/ext3/resize.c
> > +++ linux002/fs/ext3/resize.c
>
> > @@ -380,7 +380,7 @@ static int add_new_gdb(handle_t *handle,
> > struct buffer_head *dind;
> > int gdbackups;
> > struct ext3_iloc iloc;
> > - __u32 *data;
> > + __le32 *data;
> > int err;
> >
> > if (test_opt(sb, DEBUG))
> > @@ -410,14 +410,14 @@ static int add_new_gdb(handle_t *handle,
> > goto exit_bh;
> > }
> >
> > - data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
> > + data = (__le32 *)(EXT3_I(inode)->i_data + EXT3_DIND_BLOCK);
>
> Why cast is needed? i_data is __le32 * already.

You're right. I didn't realize fixing the declaration was enough.

> > - data = (__u32 *)dind->b_data;
> > + data = (__le32 *)dind->b_data;
> > if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
> > ext3_warning(sb, __FUNCTION__,
> > "new group %u GDT block "E3FSBLK" not reserved",
> > @@ -519,7 +519,7 @@ static int reserve_backup_gdb(handle_t *
> > struct buffer_head *dind;
> > struct ext3_iloc iloc;
> > ext3_fsblk_t blk;
> > - __u32 *data, *end;
> > + __le32 *data, *end;
> > int gdbackups = 0;
> > int res, i;
> > int err;
> > @@ -528,7 +528,7 @@ static int reserve_backup_gdb(handle_t *
> > if (!primary)
> > return -ENOMEM;
> >
> > - data = EXT3_I(inode)->i_data + EXT3_DIND_BLOCK;
> > + data = (__le32 *)(EXT3_I(inode)->i_data + EXT3_DIND_BLOCK);
>
> Ditto.

Agreed.

> > --- linux001/fs/ext3/super.c
> > +++ linux002/fs/ext3/super.c
> > @@ -2330,13 +2330,14 @@ static int ext3_remount (struct super_bl
> >
> > ext3_mark_recovery_complete(sb, es);
> > } else {
> > - __le32 ret;
> > - if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
> > + int ret;
> > + __le32 ret_le;
> > + if ((ret_le = EXT3_HAS_RO_COMPAT_FEATURE(sb,
> > ~EXT3_FEATURE_RO_COMPAT_SUPP))) {
> > printk(KERN_WARNING "EXT3-fs: %s: couldn't "
> > "remount RDWR because of unsupported "
> > "optional features (%x).\n",
> > - sb->s_id, le32_to_cpu(ret));
> > + sb->s_id, le32_to_cpu(ret_le));
> > err = -EROFS;
> > goto restore_opts;
> > }
>
> Get rid of "err = ret;" assignment below. It would be cleaner than
> introducing new var.

Agreed.

Here's a leaner patch.
===========================================================================
EXT3: Fix sparse warnings

Fixing up some endian-ness warnings in preparation to clone ext4 from ext3.

Signed-off-by: Dave Kleikamp <[email protected]>

---
diff -Nurp linux001/fs/ext3/resize.c linux002/fs/ext3/resize.c
--- linux001/fs/ext3/resize.c 2006-09-08 07:24:23.000000000 -0500
+++ linux002/fs/ext3/resize.c 2006-09-10 09:22:10.000000000 -0500
@@ -336,7 +336,7 @@ static int verify_reserved_gdb(struct su
unsigned five = 5;
unsigned seven = 7;
unsigned grp;
- __u32 *p = (__u32 *)primary->b_data;
+ __le32 *p = (__le32 *)primary->b_data;
int gdbackups = 0;

while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
@@ -380,7 +380,7 @@ static int add_new_gdb(handle_t *handle,
struct buffer_head *dind;
int gdbackups;
struct ext3_iloc iloc;
- __u32 *data;
+ __le32 *data;
int err;

if (test_opt(sb, DEBUG))
@@ -417,7 +417,7 @@ static int add_new_gdb(handle_t *handle,
goto exit_bh;
}

- data = (__u32 *)dind->b_data;
+ data = (__le32 *)dind->b_data;
if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
ext3_warning(sb, __FUNCTION__,
"new group %u GDT block "E3FSBLK" not reserved",
@@ -519,7 +519,7 @@ static int reserve_backup_gdb(handle_t *
struct buffer_head *dind;
struct ext3_iloc iloc;
ext3_fsblk_t blk;
- __u32 *data, *end;
+ __le32 *data, *end;
int gdbackups = 0;
int res, i;
int err;
@@ -536,8 +536,8 @@ static int reserve_backup_gdb(handle_t *
}

blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
- data = (__u32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
- end = (__u32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
+ data = (__le32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
+ end = (__le32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);

/* Get each reserved primary GDT block and verify it holds backups */
for (res = 0; res < reserved_gdb; res++, blk++) {
@@ -545,7 +545,8 @@ static int reserve_backup_gdb(handle_t *
ext3_warning(sb, __FUNCTION__,
"reserved block "E3FSBLK
" not at offset %ld",
- blk, (long)(data - (__u32 *)dind->b_data));
+ blk,
+ (long)(data - (__le32 *)dind->b_data));
err = -EINVAL;
goto exit_bh;
}
@@ -560,7 +561,7 @@ static int reserve_backup_gdb(handle_t *
goto exit_bh;
}
if (++data >= end)
- data = (__u32 *)dind->b_data;
+ data = (__le32 *)dind->b_data;
}

for (i = 0; i < reserved_gdb; i++) {
@@ -584,7 +585,7 @@ static int reserve_backup_gdb(handle_t *
blk = input->group * EXT3_BLOCKS_PER_GROUP(sb);
for (i = 0; i < reserved_gdb; i++) {
int err2;
- data = (__u32 *)primary[i]->b_data;
+ data = (__le32 *)primary[i]->b_data;
/* printk("reserving backup %lu[%u] = %lu\n",
primary[i]->b_blocknr, gdbackups,
blk + primary[i]->b_blocknr); */
@@ -689,7 +690,7 @@ exit_err:
"can't update backup for group %d (err %d), "
"forcing fsck on next reboot", group, err);
sbi->s_mount_state &= ~EXT3_VALID_FS;
- sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS);
+ sbi->s_es->s_state &= cpu_to_le16(~EXT3_VALID_FS);
mark_buffer_dirty(sbi->s_sbh);
}
}
diff -Nurp linux001/fs/ext3/super.c linux002/fs/ext3/super.c
--- linux001/fs/ext3/super.c 2006-09-08 16:25:07.000000000 -0500
+++ linux002/fs/ext3/super.c 2006-09-10 09:19:37.000000000 -0500
@@ -2348,10 +2348,8 @@ static int ext3_remount (struct super_bl
*/
ext3_clear_journal_err(sb, es);
sbi->s_mount_state = le16_to_cpu(es->s_state);
- if ((ret = ext3_group_extend(sb, es, n_blocks_count))) {
- err = ret;
+ if ((err = ext3_group_extend(sb, es, n_blocks_count)))
goto restore_opts;
- }
if (!ext3_setup_super (sb, es, 0))
sb->s_flags &= ~MS_RDONLY;
}
diff -Nurp linux001/fs/jbd/journal.c linux002/fs/jbd/journal.c
--- linux001/fs/jbd/journal.c 2006-09-08 16:25:07.000000000 -0500
+++ linux002/fs/jbd/journal.c 2006-09-08 16:25:07.000000000 -0500
@@ -1094,7 +1094,7 @@ int journal_load(journal_t *journal)
/*
* Create a slab for this blocksize
*/
- err = journal_create_jbd_slab(cpu_to_be32(sb->s_blocksize));
+ err = journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize));
if (err)
return err;

diff -Nurp linux001/include/linux/ext3_fs.h linux002/include/linux/ext3_fs.h
--- linux001/include/linux/ext3_fs.h 2006-09-08 16:25:07.000000000 -0500
+++ linux002/include/linux/ext3_fs.h 2006-09-08 16:25:07.000000000 -0500
@@ -481,7 +481,7 @@ struct ext3_super_block {
*/
__u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
__u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- __u16 s_reserved_gdt_blocks; /* Per group desc for online growth */
+ __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
/*
* Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
*/