Btrfs: cast cleanups
cover Btrfs: cast cleanups
Hi Chris,
This is a collection of cast cleanups I created after burning my eyes by the btrfs code.
- [01/12] Btrfs: Remove superfluous casts from u64 to unsigned long long
- [02/12] Btrfs: Make BTRFS_DEV_REPLACE_DEVID an unsigned long long constant
- [03/12] Btrfs: Format PAGE_SIZE as unsigned long
- [04/12] Btrfs: Format mirror_num as int
- [05/12] Btrfs: Make btrfs_device_uuid() return unsigned long
- [06/12] Btrfs: Make btrfs_device_fsid() return unsigned long
- [07/12] Btrfs: Make btrfs_dev_extent_chunk_tree_uuid() return unsigned long
- [08/12] Btrfs: Make btrfs_header_fsid() return unsigned long
- [09/12] Btrfs: Make btrfs_header_chunk_tree_uuid() return unsigned long
- [10/12] Btrfs: PAGE_CACHE_SIZE is already unsigned long
- [11/12] Btrfs: Do not truncate sector_t on 32-bit with CONFIG_LBDAF=y
- [12/12] Btrfs: Use %z to format size_t
None of them are real bugs, except for "[11/12] Btrfs: Do not truncate sector_t on 32-bit with CONFIG_LBDAF=y", which may print truncated values.
This was only compile-tested.
fs/btrfs/backref.c | 24 ++-- fs/btrfs/check-integrity.c | 313 +++++++++++++++---------------------------- fs/btrfs/compression.c | 5 +- fs/btrfs/ctree.c | 28 ++-- fs/btrfs/ctree.h | 24 ++-- fs/btrfs/delayed-inode.c | 10 +- fs/btrfs/dev-replace.c | 4 +- fs/btrfs/disk-io.c | 39 ++---- fs/btrfs/extent-tree.c | 47 +++---- fs/btrfs/extent_io.c | 48 +++---- fs/btrfs/file-item.c | 4 +- fs/btrfs/free-space-cache.c | 6 +- fs/btrfs/inode.c | 24 ++-- fs/btrfs/ioctl.c | 15 +-- fs/btrfs/ordered-data.c | 11 +- fs/btrfs/print-tree.c | 80 ++++------- fs/btrfs/qgroup.c | 10 +- fs/btrfs/relocation.c | 7 +- fs/btrfs/root-tree.c | 3 +- fs/btrfs/scrub.c | 25 ++-- fs/btrfs/super.c | 10 +- fs/btrfs/transaction.c | 3 +- fs/btrfs/volumes.c | 40 +++--- 23 files changed, 279 insertions(+), 501 deletions(-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 4/12 Btrfs: Format mirror_num as int
mirror_num is always "int", hence don't cast it to "unsigned long long" and format it as a 64-bit number.
--- fs/btrfs/scrub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/scrub.c +3 -3
@@ -3170,9 +3170,9 @@ static void copy_nocow_pages_worker(struct btrfs_work *work) copy_nocow_pages_for_inode, nocow_ctx);if (ret !=0 && ret != -ENOENT ) { -pr_warn ("iterate_inodes_from_logical() failed: log %llu, phys %llu, len %llu, mir %llu, ret %d\n" , - logical, physical_for_dev_replace, len, - (unsigned long long )mirror_num, ret); +pr_warn ("iterate_inodes_from_logical() failed: log %llu, phys %llu, len %llu, mir %u, ret %d\n" , + logical, physical_for_dev_replace, len, mirror_num, + ret); not_written =1 ; goto out; }
Signature · 1 line
1.7.9.5
PATCH 2/12 Btrfs: Make BTRFS_DEV_REPLACE_DEVID an unsigned long long constant
In reply to Geert UytterhoevenThe internal btrfs device id is a u64, hence make the constant BTRFS_DEV_REPLACE_DEVID "unsigned long long" as well, so we no longer need a cast to print it.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/dev-replace.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -142,7 +142,7 @@ struct btrfs_ordered_sum;#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2 -#define BTRFS_DEV_REPLACE_DEVID 0 +#define BTRFS_DEV_REPLACE_DEVID 0ULL/* * the max metadata block size. This limit is somewhat artificial,
fs/btrfs/dev-replace.c +1 -1
@@ -154,7 +154,7 @@ no_valid_dev_replace_entry_found: !btrfs_test_opt(dev_root, DEGRADED)) { ret = -EIO ;pr_warn ("btrfs: cannot mount because device replace operation is ongoing and\n" "tgtdev (devid %llu) is missing, need to run btrfs dev scan?\n" , - (unsigned long long )BTRFS_DEV_REPLACE_DEVID ); +BTRFS_DEV_REPLACE_DEVID ); }if (dev_replace->tgtdev) {if (dev_replace->srcdev) {
Signature · 1 line
1.7.9.5
PATCH 3/12 Btrfs: Format PAGE_SIZE as unsigned long
In reply to Geert UytterhoevenPAGE_SIZE is "unsigned long" everywhere, so there's no need to cast it to "unsigned long long" and format it as a 64-bit number.
--- fs/btrfs/scrub.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/scrub.c +2 -3
@@ -2859,9 +2859,8 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,if (fs_info->chunk_root->sectorsize !=PAGE_SIZE ) {/* not supported for data w/o checksums */ printk (KERN_ERR -"btrfs_scrub: size assumption sectorsize != PAGE_SIZE (%d != %lld) fails\n" , - fs_info->chunk_root->sectorsize, - (unsigned long long )PAGE_SIZE ); +"btrfs_scrub: size assumption sectorsize != PAGE_SIZE (%d != %lu) fails\n" , + fs_info->chunk_root->sectorsize,PAGE_SIZE );return -EINVAL ; }
Signature · 1 line
1.7.9.5
PATCH 6/12 Btrfs: Make btrfs_device_fsid() return unsigned long
In reply to Geert UytterhoevenAll callers of btrfs_device_fsid() cast its return type to unsigned long.
--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/volumes.c | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-)
fs/btrfs/ctree.h +2 -2
@@ -2135,9 +2135,9 @@ static inline unsigned long btrfs_device_uuid(struct btrfs_dev_item *d)return (unsigned long )d + offsetof(struct btrfs_dev_item , uuid); } -static inline char *btrfs_device_fsid (struct btrfs_dev_item *d) +static inline unsigned long btrfs_device_fsid (struct btrfs_dev_item *d) { -return (char *)d + offsetof(struct btrfs_dev_item , fsid); +return (unsigned long )d + offsetof(struct btrfs_dev_item , fsid); } BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64);
fs/btrfs/volumes.c +3 -5
@@ -1392,7 +1392,7 @@ static int btrfs_add_device(struct btrfs_trans_handle *trans, ptr =btrfs_device_uuid (dev_item);write_extent_buffer (leaf, device->uuid, ptr,BTRFS_UUID_SIZE ); - ptr = (unsigned long )btrfs_device_fsid (dev_item); + ptr =btrfs_device_fsid (dev_item);write_extent_buffer (leaf, root->fs_info->fsid, ptr,BTRFS_UUID_SIZE );btrfs_mark_buffer_dirty (leaf);
@@ -1890,8 +1890,7 @@ next_slot: devid =btrfs_device_id (leaf, dev_item);read_extent_buffer (leaf, dev_uuid,btrfs_device_uuid (dev_item),BTRFS_UUID_SIZE ); -read_extent_buffer (leaf, fs_uuid, - (unsigned long )btrfs_device_fsid (dev_item), +read_extent_buffer (leaf, fs_uuid,btrfs_device_fsid (dev_item),BTRFS_UUID_SIZE ); device =btrfs_find_device (root->fs_info, devid, dev_uuid, fs_uuid);
@@ -5497,8 +5496,7 @@ static int read_one_dev(struct btrfs_root *root, devid =btrfs_device_id (leaf, dev_item);read_extent_buffer (leaf, dev_uuid,btrfs_device_uuid (dev_item),BTRFS_UUID_SIZE ); -read_extent_buffer (leaf, fs_uuid, - (unsigned long )btrfs_device_fsid (dev_item), +read_extent_buffer (leaf, fs_uuid,btrfs_device_fsid (dev_item),BTRFS_UUID_SIZE );if (memcmp (fs_uuid, root->fs_info->fsid,BTRFS_UUID_SIZE )) {
Signature · 1 line
1.7.9.5
PATCH 7/12 Btrfs: Make btrfs_dev_extent_chunk_tree_uuid() return unsigned long
In reply to Geert UytterhoevenInternally, btrfs_dev_extent_chunk_tree_uuid() calculates an unsigned long, but casts it to a pointer, while all callers cast it to unsigned long again.
--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/volumes.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
fs/btrfs/ctree.h +2 -2
@@ -2277,10 +2277,10 @@ BTRFS_SETGET_FUNCS(dev_extent_chunk_offset, struct btrfs_dev_extent, chunk_offset, 64); BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64); -static inline u8 *btrfs_dev_extent_chunk_tree_uuid (struct btrfs_dev_extent *dev) +static inline unsigned long btrfs_dev_extent_chunk_tree_uuid (struct btrfs_dev_extent *dev) {unsigned long ptr = offsetof(struct btrfs_dev_extent , chunk_tree_uuid); -return (u8 *)((unsigned long )dev + ptr); +return (unsigned long )dev + ptr; } BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 64);
fs/btrfs/volumes.c +1 -2
@@ -1277,8 +1277,7 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,btrfs_set_dev_extent_chunk_offset (leaf, extent, chunk_offset);write_extent_buffer (leaf, root->fs_info->chunk_tree_uuid, - (unsigned long )btrfs_dev_extent_chunk_tree_uuid (extent), -BTRFS_UUID_SIZE ); +btrfs_dev_extent_chunk_tree_uuid (extent),BTRFS_UUID_SIZE );btrfs_set_dev_extent_length (leaf, extent, num_bytes);btrfs_mark_buffer_dirty (leaf);
Signature · 1 line
1.7.9.5
PATCH 8/12 Btrfs: Make btrfs_header_fsid() return unsigned long
In reply to Geert UytterhoevenInternally, btrfs_header_fsid() calculates an unsigned long, but casts it to a pointer, while all callers cast it to unsigned long again.
--- fs/btrfs/ctree.c | 15 +++++---------- fs/btrfs/ctree.h | 5 ++--- fs/btrfs/disk-io.c | 9 +++------ fs/btrfs/ioctl.c | 3 +-- 4 files changed, 11 insertions(+), 21 deletions(-)
fs/btrfs/ctree.c +5 -10
@@ -274,8 +274,7 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,else btrfs_set_header_owner (cow, new_root_objectid); -write_extent_buffer (cow, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (cow), +write_extent_buffer (cow, root->fs_info->fsid,btrfs_header_fsid (cow),BTRFS_FSID_SIZE );WARN_ON (btrfs_header_generation (buf) > trans->transid);
@@ -1046,8 +1045,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,else btrfs_set_header_owner (cow, root->root_key.objectid); -write_extent_buffer (cow, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (cow), +write_extent_buffer (cow, root->fs_info->fsid,btrfs_header_fsid (cow),BTRFS_FSID_SIZE ); ret =update_ref_for_cow (trans, root, buf, cow, &last_ref);
@@ -3141,8 +3139,7 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,btrfs_set_header_backref_rev (c,BTRFS_MIXED_BACKREF_REV );btrfs_set_header_owner (c, root->root_key.objectid); -write_extent_buffer (c, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (c), +write_extent_buffer (c, root->fs_info->fsid,btrfs_header_fsid (c),BTRFS_FSID_SIZE ); write_extent_buffer(c, root->fs_info->chunk_tree_uuid,
@@ -3282,8 +3279,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,btrfs_set_header_backref_rev (split,BTRFS_MIXED_BACKREF_REV );btrfs_set_header_owner (split, root->root_key.objectid);write_extent_buffer (split, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (split), -BTRFS_FSID_SIZE ); +btrfs_header_fsid (split),BTRFS_FSID_SIZE );write_extent_buffer (split, root->fs_info->chunk_tree_uuid, (unsigned long )btrfs_header_chunk_tree_uuid (split),BTRFS_UUID_SIZE );
@@ -4038,8 +4034,7 @@ again:btrfs_set_header_owner (right, root->root_key.objectid);btrfs_set_header_level (right,0 );write_extent_buffer (right, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (right), -BTRFS_FSID_SIZE ); +btrfs_header_fsid (right),BTRFS_FSID_SIZE ); write_extent_buffer(right, root->fs_info->chunk_tree_uuid, (unsigned long)btrfs_header_chunk_tree_uuid(right),
fs/btrfs/ctree.h +2 -3
@@ -2603,10 +2603,9 @@ static inline void btrfs_set_header_backref_rev(struct extent_buffer *eb,btrfs_set_header_flags (eb, flags); } -static inline u8 *btrfs_header_fsid (struct extent_buffer *eb) +static inline unsigned long btrfs_header_fsid (struct extent_buffer *eb) { -unsigned long ptr = offsetof(struct btrfs_header , fsid); -return (u8 *)ptr; +return offsetof(struct btrfs_header , fsid); }static inline u8 *btrfs_header_chunk_tree_uuid (struct extent_buffer *eb)
fs/btrfs/disk-io.c +3 -6
@@ -494,8 +494,7 @@ static int check_tree_block_fsid(struct btrfs_root *root,u8 fsid[BTRFS_UUID_SIZE ];int ret =1 ; -read_extent_buffer (eb, fsid, (unsigned long )btrfs_header_fsid (eb), -BTRFS_FSID_SIZE ); +read_extent_buffer (eb, fsid,btrfs_header_fsid (eb),BTRFS_FSID_SIZE );while (fs_devices) {if (!memcmp (fsid, fs_devices->fsid,BTRFS_FSID_SIZE )) { ret =0 ;
@@ -1286,8 +1285,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,btrfs_set_header_owner (leaf, objectid); root->node = leaf; -write_extent_buffer (leaf, fs_info->fsid, - (unsigned long )btrfs_header_fsid (leaf), +write_extent_buffer (leaf, fs_info->fsid,btrfs_header_fsid (leaf),BTRFS_FSID_SIZE ); write_extent_buffer(leaf, fs_info->chunk_tree_uuid, (unsigned long)btrfs_header_chunk_tree_uuid(leaf),
@@ -1374,8 +1372,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, root->node = leaf;write_extent_buffer (root->node, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (root->node), -BTRFS_FSID_SIZE ); +btrfs_header_fsid (root->node),BTRFS_FSID_SIZE );btrfs_mark_buffer_dirty (root->node);btrfs_tree_unlock (root->node);return root;
fs/btrfs/ioctl.c +1 -2
@@ -425,8 +425,7 @@ static noinline int create_subvol(struct inode *dir,btrfs_set_header_backref_rev (leaf,BTRFS_MIXED_BACKREF_REV );btrfs_set_header_owner (leaf, objectid); -write_extent_buffer (leaf, root->fs_info->fsid, - (unsigned long )btrfs_header_fsid (leaf), +write_extent_buffer (leaf, root->fs_info->fsid,btrfs_header_fsid (leaf),BTRFS_FSID_SIZE ); write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid, (unsigned long)btrfs_header_chunk_tree_uuid(leaf),
Signature · 1 line
1.7.9.5
PATCH 10/12 Btrfs: PAGE_CACHE_SIZE is already unsigned long
In reply to Geert UytterhoevenPAGE_CACHE_SIZE == PAGE_SIZE is "unsigned long" everywhere, so there's no need to cast it to "unsigned long".
--- fs/btrfs/check-integrity.c | 9 ++++----- fs/btrfs/extent_io.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-)
fs/btrfs/check-integrity.c +4 -5
@@ -1232,8 +1232,7 @@ static void btrfsic_read_from_block_data(unsigned long i = (start_offset + offset) >>PAGE_CACHE_SHIFT ;WARN_ON (offset + len > block_ctx->len); - offset_in_page = (start_offset + offset) & - ((unsigned long )PAGE_CACHE_SIZE -1 ); + offset_in_page = (start_offset + offset) & (PAGE_CACHE_SIZE -1 );while (len >0 ) { cur =min (len, ((size_t )PAGE_CACHE_SIZE - offset_in_page));
@@ -3113,19 +3112,19 @@ int btrfsic_mount(struct btrfs_root *root,if (root->nodesize & ((u64 )PAGE_CACHE_SIZE -1 )) {printk (KERN_INFO "btrfsic: cannot handle nodesize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n" , - root->nodesize, (unsigned long )PAGE_CACHE_SIZE ); + root->nodesize,PAGE_CACHE_SIZE );return -1 ; }if (root->leafsize & ((u64 )PAGE_CACHE_SIZE -1 )) {printk (KERN_INFO "btrfsic: cannot handle leafsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n" , - root->leafsize, (unsigned long )PAGE_CACHE_SIZE ); + root->leafsize,PAGE_CACHE_SIZE );return -1 ; }if (root->sectorsize & ((u64 )PAGE_CACHE_SIZE -1 )) {printk (KERN_INFO "btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n" , - root->sectorsize, (unsigned long )PAGE_CACHE_SIZE ); + root->sectorsize,PAGE_CACHE_SIZE );return -1 ; } state =kzalloc (sizeof (*state),GFP_NOFS );
fs/btrfs/extent_io.c +9 -9
@@ -4763,7 +4763,7 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,WARN_ON (start > eb->len);WARN_ON (start + len > eb->start + eb->len); - offset = (start_offset + start) & ((unsigned long )PAGE_CACHE_SIZE -1 ); + offset = (start_offset + start) & (PAGE_CACHE_SIZE -1 );while (len >0 ) { page =extent_buffer_page (eb, i);
@@ -4833,7 +4833,7 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,WARN_ON (start > eb->len);WARN_ON (start + len > eb->start + eb->len); - offset = (start_offset + start) & ((unsigned long )PAGE_CACHE_SIZE -1 ); + offset = (start_offset + start) & (PAGE_CACHE_SIZE -1 );while (len >0 ) { page =extent_buffer_page (eb, i);
@@ -4867,7 +4867,7 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv,WARN_ON (start > eb->len);WARN_ON (start + len > eb->start + eb->len); - offset = (start_offset + start) & ((unsigned long )PAGE_CACHE_SIZE -1 ); + offset = (start_offset + start) & (PAGE_CACHE_SIZE -1 );while (len >0 ) { page =extent_buffer_page (eb, i);
@@ -4897,7 +4897,7 @@ void memset_extent_buffer(struct extent_buffer *eb, char c,WARN_ON (start > eb->len);WARN_ON (start + len > eb->start + eb->len); - offset = (start_offset + start) & ((unsigned long )PAGE_CACHE_SIZE -1 ); + offset = (start_offset + start) & (PAGE_CACHE_SIZE -1 );while (len >0 ) { page =extent_buffer_page (eb, i);
@@ -4928,7 +4928,7 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,WARN_ON (src->len != dst_len); offset = (start_offset + dst_offset) & - ((unsigned long )PAGE_CACHE_SIZE -1 ); + (PAGE_CACHE_SIZE -1 );while (len >0 ) { page =extent_buffer_page (dst, i);
@@ -5014,9 +5014,9 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,while (len >0 ) { dst_off_in_page = (start_offset + dst_offset) & - ((unsigned long )PAGE_CACHE_SIZE -1 ); + (PAGE_CACHE_SIZE -1 ); src_off_in_page = (start_offset + src_offset) & - ((unsigned long )PAGE_CACHE_SIZE -1 ); + (PAGE_CACHE_SIZE -1 ); dst_i = (start_offset + dst_offset) >>PAGE_CACHE_SHIFT ; src_i = (start_offset + src_offset) >>PAGE_CACHE_SHIFT ;
@@ -5067,9 +5067,9 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, src_i = (start_offset + src_end) >>PAGE_CACHE_SHIFT ; dst_off_in_page = (start_offset + dst_end) & - ((unsigned long )PAGE_CACHE_SIZE -1 ); + (PAGE_CACHE_SIZE -1 ); src_off_in_page = (start_offset + src_end) & - ((unsigned long )PAGE_CACHE_SIZE -1 ); + (PAGE_CACHE_SIZE -1 ); cur = min_t(unsigned long, len, src_off_in_page + 1); cur =min (cur, dst_off_in_page +1 );
Signature · 1 line
1.7.9.5
PATCH 11/12 Btrfs: Do not truncate sector_t on 32-bit with CONFIG_LBDAF=y
In reply to Geert Uytterhoevensector_t may be either "u64" (always 64 bit) or "unsigned long" (32 or 64 bit). Casting it to "unsigned long" will truncate it on 32-bit platforms where CONFIG_LBDAF=y.
Cast to "unsigned long long" and format using "ll" instead.
--- fs/btrfs/check-integrity.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/btrfs/check-integrity.c +7 -5
@@ -2949,9 +2949,10 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh)if (dev_state->state->print_mask &BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH )printk (KERN_INFO -"submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu)," +"submit_bh(rw=0x%x, blocknr=%llu (bytenr %llu)," " size=%lu, data=%p, bdev=%p)\n" , - rw, (unsigned long )bh->b_blocknr, dev_bytenr, + rw, (unsigned long long )bh->b_blocknr, + dev_bytenr, (unsigned long )bh->b_size, bh->b_data, bh->b_bdev); btrfsic_process_written_block(dev_state, dev_bytenr,
@@ -3018,9 +3019,10 @@ void btrfsic_submit_bio(int rw, struct bio *bio) BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) printk(KERN_INFO"submit_bio(rw=0x%x, bi_vcnt=%u," -" bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n" , - rw, bio->bi_vcnt, (unsigned long )bio->bi_sector, - dev_bytenr, bio->bi_bdev); +" bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n" , + rw, bio->bi_vcnt, + (unsigned long long )bio->bi_sector, dev_bytenr, + bio->bi_bdev); mapped_datav =kmalloc (sizeof (*mapped_datav) * bio->bi_vcnt,GFP_NOFS );
Signature · 1 line
1.7.9.5
PATCH 12/12 Btrfs: Use %z to format size_t
In reply to Geert Uytterhoeven--- fs/btrfs/check-integrity.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/check-integrity.c +2 -4
@@ -2950,11 +2950,9 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh) BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) printk(KERN_INFO"submit_bh(rw=0x%x, blocknr=%llu (bytenr %llu)," -" size=%lu, data=%p, bdev=%p)\n" , +" size=%zu, data=%p, bdev=%p)\n" , rw, (unsigned long long )bh->b_blocknr, - dev_bytenr, - (unsigned long )bh->b_size, bh->b_data, - bh->b_bdev); + dev_bytenr, bh->b_size, bh->b_data, bh->b_bdev);btrfsic_process_written_block (dev_state, dev_bytenr, &bh->b_data,1 ,NULL ,NULL , bh, rw);
Signature · 1 line
1.7.9.5
PATCH 5/12 Btrfs: Make btrfs_device_uuid() return unsigned long
In reply to Geert UytterhoevenAll callers of btrfs_device_uuid() cast its return type to unsigned long.
--- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/volumes.c | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-)
fs/btrfs/ctree.h +2 -2
@@ -2130,9 +2130,9 @@ BTRFS_SETGET_STACK_FUNCS(stack_device_bandwidth, struct btrfs_dev_item, BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item, generation,64 ); -static inline char *btrfs_device_uuid (struct btrfs_dev_item *d) +static inline unsigned long btrfs_device_uuid (struct btrfs_dev_item *d) { -return (char *)d + offsetof(struct btrfs_dev_item , uuid); +return (unsigned long )d + offsetof(struct btrfs_dev_item , uuid); }static inline char *btrfs_device_fsid (struct btrfs_dev_item *d)
fs/btrfs/volumes.c +4 -6
@@ -1390,7 +1390,7 @@ static int btrfs_add_device(struct btrfs_trans_handle *trans,btrfs_set_device_bandwidth (leaf, dev_item,0 );btrfs_set_device_start_offset (leaf, dev_item,0 ); - ptr = (unsigned long )btrfs_device_uuid (dev_item); + ptr =btrfs_device_uuid (dev_item);write_extent_buffer (leaf, device->uuid, ptr,BTRFS_UUID_SIZE ); ptr = (unsigned long )btrfs_device_fsid (dev_item);write_extent_buffer (leaf, root->fs_info->fsid, ptr,BTRFS_UUID_SIZE );
@@ -1888,8 +1888,7 @@ next_slot: dev_item =btrfs_item_ptr (leaf, path->slots[0 ], struct btrfs_dev_item); devid =btrfs_device_id (leaf, dev_item); -read_extent_buffer (leaf, dev_uuid, - (unsigned long )btrfs_device_uuid (dev_item), +read_extent_buffer (leaf, dev_uuid,btrfs_device_uuid (dev_item),BTRFS_UUID_SIZE ); read_extent_buffer(leaf, fs_uuid, (unsigned long)btrfs_device_fsid(dev_item),
@@ -5433,7 +5432,7 @@ static void fill_device_from_item(struct extent_buffer *leaf,WARN_ON (device->devid ==BTRFS_DEV_REPLACE_DEVID ); device->is_tgtdev_for_dev_replace =0 ; - ptr = (unsigned long )btrfs_device_uuid (dev_item); + ptr =btrfs_device_uuid (dev_item);read_extent_buffer (leaf, device->uuid, ptr,BTRFS_UUID_SIZE ); }
@@ -5496,8 +5495,7 @@ static int read_one_dev(struct btrfs_root *root,u8 dev_uuid[BTRFS_UUID_SIZE ]; devid =btrfs_device_id (leaf, dev_item); -read_extent_buffer (leaf, dev_uuid, - (unsigned long )btrfs_device_uuid (dev_item), +read_extent_buffer (leaf, dev_uuid,btrfs_device_uuid (dev_item),BTRFS_UUID_SIZE ); read_extent_buffer(leaf, fs_uuid, (unsigned long)btrfs_device_fsid(dev_item),
Signature · 1 line
1.7.9.5
PATCH 1/12 Btrfs: Remove superfluous casts from u64 to unsigned long long
In reply to Geert Uytterhoevenu64 is "unsigned long long" on all architectures now, so there's no need to cast it when formatting it using the "ll" length modifier.
--- fs/btrfs/backref.c | 24 ++-- fs/btrfs/check-integrity.c | 294 ++++++++++++++----------------------------- fs/btrfs/compression.c | 5 +- fs/btrfs/ctree.c | 6 +- fs/btrfs/delayed-inode.c | 10 +- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/disk-io.c | 25 ++-- fs/btrfs/extent-tree.c | 47 +++---- fs/btrfs/extent_io.c | 30 ++--- fs/btrfs/file-item.c | 4 +- fs/btrfs/free-space-cache.c | 6 +- fs/btrfs/inode.c | 24 ++-- fs/btrfs/ioctl.c | 10 +- fs/btrfs/ordered-data.c | 11 +- fs/btrfs/print-tree.c | 80 +++++------- fs/btrfs/qgroup.c | 10 +- fs/btrfs/relocation.c | 7 +- fs/btrfs/root-tree.c | 3 +- fs/btrfs/scrub.c | 16 +-- fs/btrfs/super.c | 10 +- fs/btrfs/transaction.c | 3 +- fs/btrfs/volumes.c | 19 ++- 22 files changed, 222 insertions(+), 424 deletions(-)
fs/btrfs/backref.c +9 -15
@@ -295,10 +295,9 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ret =btrfs_search_old_slot (root, &ref->key_for_search, path, time_seq);pr_debug ("search slot in root %llu (level %d, ref count %d) returned " "%d for key (%llu %u %llu)\n" , - (unsigned long long )ref->root_id, level, ref->count, ret, - (unsigned long long )ref->key_for_search.objectid, - ref->key_for_search.type, - (unsigned long long )ref->key_for_search.offset); + ref->root_id, level, ref->count, ret, + ref->key_for_search.objectid, ref->key_for_search.type, + ref->key_for_search.offset);if (ret <0 ) goto out;
@@ -1326,8 +1325,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, found_key->type != BTRFS_METADATA_ITEM_KEY) || found_key->objectid > logical || found_key->objectid + size <= logical) { -pr_debug ("logical %llu is not within any extent\n" , - (unsigned long long )logical); +pr_debug ("logical %llu is not within any extent\n" , logical);return -ENOENT ; }
@@ -1340,11 +1338,8 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,pr_debug ("logical %llu is at position %llu within the extent (%llu " "EXTENT_ITEM %llu) flags %#llx size %u\n" , - (unsigned long long )logical, - (unsigned long long )(logical - found_key->objectid), - (unsigned long long )found_key->objectid, - (unsigned long long )found_key->offset, - (unsigned long long )flags, item_size); + logical, logical - found_key->objectid, found_key->objectid, + found_key->offset, flags, item_size);WARN_ON (!flags_ret);if (flags_ret) {
@@ -1516,7 +1511,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,while (!ret && (root_node =ulist_next (roots, &root_uiter))) {pr_debug ("root %llu references leaf %llu, data list " "%#llx\n" , root_node->val, ref_node->val, - (long long )ref_node->aux); + ref_node->aux); ret = iterate_leaf_refs((struct extent_inode_elem *) (uintptr_t)ref_node->aux, root_node->val,
@@ -1608,9 +1603,8 @@ static int iterate_inode_refs(u64 inum, struct btrfs_root *fs_root, name_len =btrfs_inode_ref_name_len (eb, iref);/* path must be released before calling iterate()! */ pr_debug ("following ref at offset %u for inode %llu in " -"tree %llu\n" , cur, - (unsigned long long )found_key.objectid, - (unsigned long long )fs_root->objectid); +"tree %llu\n" , cur, found_key.objectid, + fs_root->objectid); ret =iterate (parent, name_len, (unsigned long )(iref +1 ), eb, ctx);if (ret)
fs/btrfs/check-integrity.c +96 -198
738 lines not on this page · raw message
fs/btrfs/compression.c +2 -3
@@ -132,9 +132,8 @@ static int check_compressed_csum(struct inode *inode,printk (KERN_INFO "btrfs csum failed ino %llu " "extent %llu csum %u " "wanted %u mirror %d\n" , - (unsigned long long )btrfs_ino (inode), - (unsigned long long )disk_start, - csum, *cb_sum, cb->mirror_num); +btrfs_ino (inode), disk_start, csum, *cb_sum, + cb->mirror_num); ret = -EIO ; goto fail; }
fs/btrfs/ctree.c +2 -4
@@ -1419,14 +1419,12 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,if (trans->transaction != root->fs_info->running_transaction)WARN (1 ,KERN_CRIT "trans %llu running %llu\n" , - (unsigned long long )trans->transid, - (unsigned long long ) + trans->transid, root->fs_info->running_transaction->transid);if (trans->transid != root->fs_info->generation)WARN (1 ,KERN_CRIT "trans %llu running %llu\n" , - (unsigned long long )trans->transid, - (unsigned long long )root->fs_info->generation); + trans->transid, root->fs_info->generation);if (!should_cow_block (trans, root, buf)) { *cow_ret = buf;
fs/btrfs/delayed-inode.c +3 -7
@@ -1473,10 +1473,8 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,printk (KERN_ERR "err add delayed dir index item(name: %s) into " "the insertion tree of the delayed node" "(root id: %llu, inode id: %llu, errno: %d)\n" , - name, - (unsigned long long )delayed_node->root->objectid, - (unsigned long long )delayed_node->inode_id, - ret); + name, delayed_node->root->objectid, + delayed_node->inode_id, ret);BUG (); }mutex_unlock (&delayed_node->mutex);
@@ -1547,9 +1545,7 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,printk (KERN_ERR "err add delayed dir index item(index: %llu) " "into the deletion tree of the delayed node" "(root id: %llu, inode id: %llu, errno: %d)\n" , - (unsigned long long )index, - (unsigned long long )node->root->objectid, - (unsigned long long )node->inode_id, + index, node->root->objectid, node->inode_id, ret);BUG (); }
fs/btrfs/dev-replace.c +1 -1
@@ -148,7 +148,7 @@ no_valid_dev_replace_entry_found: !btrfs_test_opt(dev_root, DEGRADED)) { ret = -EIO ;pr_warn ("btrfs: cannot mount because device replace operation is ongoing and\n" "srcdev (devid %llu) is missing, need to run 'btrfs dev scan'?\n" , - (unsigned long long )src_devid); + src_devid); }if (!dev_replace->tgtdev && !btrfs_test_opt (dev_root,DEGRADED )) {
fs/btrfs/disk-io.c +9 -16
@@ -302,9 +302,8 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,printk_ratelimited (KERN_INFO "btrfs: %s checksum verify " "failed on %llu wanted %X found %X " "level %d\n" , - root->fs_info->sb->s_id, - (unsigned long long )buf->start, val, found, -btrfs_header_level (buf)); + root->fs_info->sb->s_id, buf->start, + val, found,btrfs_header_level (buf));if (result != (char *)&inline_result)kfree (result);return 1 ;
@@ -345,9 +344,7 @@ static int verify_parent_transid(struct extent_io_tree *io_tree, }printk_ratelimited ("parent transid verify failed on %llu wanted %llu " "found %llu\n" , - (unsigned long long )eb->start, - (unsigned long long )parent_transid, - (unsigned long long )btrfs_header_generation (eb)); + eb->start, parent_transid,btrfs_header_generation (eb)); ret =1 ;clear_extent_buffer_uptodate (eb); out:
@@ -512,8 +509,7 @@ static int check_tree_block_fsid(struct btrfs_root *root,#define CORRUPT (reason, eb, root, slot) \ printk(KERN_CRIT "btrfs: corrupt leaf, %s: block=%llu," \ "root=%llu, slot=%d\n", reason, \ - (unsigned long long)btrfs_header_bytenr(eb), \ - (unsigned long long)root->objectid, slot) + btrfs_header_bytenr(eb), root->objectid, slot) static noinline int check_leaf(struct btrfs_root *root,struct extent_buffer *leaf)
@@ -612,14 +608,13 @@ static int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,if (found_start != eb->start) {printk_ratelimited (KERN_INFO "btrfs bad tree block start " "%llu %llu\n" , - (unsigned long long )found_start, - (unsigned long long )eb->start); + found_start, eb->start); ret = -EIO ; goto err; }if (check_tree_block_fsid (root, eb)) {printk_ratelimited (KERN_INFO "btrfs bad fsid on block %llu\n" , - (unsigned long long )eb->start); + eb->start); ret = -EIO ; goto err; }
@@ -2383,7 +2378,7 @@ int open_ctree(struct super_block *sb,if (features) {printk (KERN_ERR "BTRFS: couldn't mount because of " "unsupported optional features (%Lx).\n" , - (unsigned long long )features); + features); err = -EINVAL ; goto fail_alloc; }
@@ -2453,7 +2448,7 @@ int open_ctree(struct super_block *sb,if (!(sb->s_flags &MS_RDONLY ) && features) {printk (KERN_ERR "BTRFS: couldn't mount RDWR because of " "unsupported option features (%Lx).\n" , - (unsigned long long )features); + features); err = -EINVAL ; goto fail_alloc; }
@@ -3608,9 +3603,7 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)if (transid != root->fs_info->generation)WARN (1 ,KERN_CRIT "btrfs transid mismatch buffer %llu, " "found %llu running %llu\n" , - (unsigned long long )buf->start, - (unsigned long long )transid, - (unsigned long long )root->fs_info->generation); + buf->start, transid, root->fs_info->generation); was_dirty =set_extent_buffer_dirty (buf);if (!was_dirty) __percpu_counter_add(&root->fs_info->dirty_metadata_bytes,
fs/btrfs/extent-tree.c +17 -30
104 lines not on this page · raw message
fs/btrfs/extent_io.c +11 -19
@@ -61,9 +61,8 @@ void btrfs_leak_debug_check(void) state = list_entry(states.next, struct extent_state, leak_list);printk (KERN_ERR "btrfs state leak: start %llu end %llu " "state %lu in tree %p refs %d\n" , - (unsigned long long )state->start, - (unsigned long long )state->end, - state->state, state->tree,atomic_read (&state->refs)); + state->start, state->end, state->state, state->tree, +atomic_read (&state->refs));list_del (&state->leak_list);kmem_cache_free (extent_state_cache, state); }
@@ -71,8 +70,8 @@ void btrfs_leak_debug_check(void)while (!list_empty (&buffers)) { eb = list_entry(buffers.next, struct extent_buffer, leak_list);printk (KERN_ERR "btrfs buffer leak start %llu len %lu " -"refs %d\n" , (unsigned long long )eb->start, - eb->len,atomic_read (&eb->refs)); +"refs %d\n" , + eb->start, eb->len,atomic_read (&eb->refs));list_del (&eb->leak_list);kmem_cache_free (extent_buffer_cache, eb); }
@@ -88,11 +87,7 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller,if (end >=PAGE_SIZE && (end %2 ) ==0 && end != isize -1 ) {printk_ratelimited (KERN_DEBUG "btrfs: %s: ino %llu isize %llu odd range [%llu,%llu]\n" , - caller, - (unsigned long long )btrfs_ino (inode), - (unsigned long long )isize, - (unsigned long long )start, - (unsigned long long )end); + caller,btrfs_ino (inode), isize, start, end); } }#else
@@ -388,8 +383,7 @@ static int insert_state(struct extent_io_tree *tree,if (end < start)WARN (1 ,KERN_ERR "btrfs end < start %llu %llu\n" , - (unsigned long long )end, - (unsigned long long )start); + end, start); state->start = start; state->end = end;
@@ -400,9 +394,8 @@ static int insert_state(struct extent_io_tree *tree,struct extent_state *found; found = rb_entry(node, struct extent_state, rb_node);printk (KERN_ERR "btrfs found node %llu %llu on insert of " -"%llu %llu\n" , (unsigned long long )found->start, - (unsigned long long )found->end, - (unsigned long long )start, (unsigned long long )end); +"%llu %llu\n" , + found->start, found->end, start, end);return -EEXIST ; } state->tree = tree;
@@ -3189,8 +3182,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,if (!PageWriteback (page)) {printk (KERN_ERR "btrfs warning page %lu not " "writeback, cur %llu end %llu\n" , - page->index, (unsigned long long )cur, - (unsigned long long )end); + page->index, cur, end); } ret = submit_extent_page(write_flags, tree, page,
@@ -4813,8 +4805,8 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,if (start + min_len > eb->len) {WARN (1 ,KERN_ERR "btrfs bad mapping eb start %llu len %lu, " -"wanted %lu %lu\n" , (unsigned long long )eb->start, - eb->len, start, min_len); +"wanted %lu %lu\n" , + eb->start, eb->len, start, min_len);return -EINVAL ; }
fs/btrfs/file-item.c +1 -3
@@ -222,9 +222,7 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, }else {printk (KERN_INFO "btrfs no csum found " "for inode %llu start %llu\n" , - (unsigned long long ) -btrfs_ino (inode), - (unsigned long long )offset); +btrfs_ino (inode), offset); } item =NULL ;btrfs_release_path (path);
fs/btrfs/free-space-cache.c +2 -4
@@ -673,8 +673,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,btrfs_err (root->fs_info,"free space inode generation (%llu) " "did not match free space cache generation (%llu)" , - (unsigned long long )BTRFS_I (inode)->generation, - (unsigned long long )generation); +BTRFS_I (inode)->generation, generation);return 0 ; }
@@ -1991,8 +1990,7 @@ void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,if (info->bytes >= bytes && !block_group->ro) count++;printk (KERN_CRIT "entry offset %llu, bytes %llu, bitmap %s\n" , - (unsigned long long )info->offset, - (unsigned long long )info->bytes, + info->offset, info->bytes, (info->bitmap) ?"yes" :"no" ); } printk(KERN_INFO "block group has cluster?: %s\n",
fs/btrfs/inode.c +8 -16
@@ -2878,9 +2878,7 @@ good: zeroit:if (__ratelimit (&_rs))btrfs_info (root->fs_info,"csum failed ino %llu off %llu csum %u private %llu" , - (unsigned long long )btrfs_ino (page->mapping->host), - (unsigned long long )start, csum, - (unsigned long long )private); +btrfs_ino (page->mapping->host), start, csum, private);memset (kaddr + offset,1 , end - start +1 );flush_dcache_page (page);kunmap_atomic (kaddr);
@@ -3657,8 +3655,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,if (ret) {btrfs_info (root->fs_info,"failed to delete reference to %.*s, inode %llu parent %llu" , - name_len, name, - (unsigned long long )ino, (unsigned long long )dir_ino); + name_len, name, ino, dir_ino);btrfs_abort_transaction (trans, root, ret); goto err; }
@@ -6161,10 +6158,7 @@ insert:btrfs_release_path (path);if (em->start > start ||extent_map_end (em) <= start) {btrfs_err (root->fs_info,"bad extent! em: [%llu %llu] passed [%llu %llu]" , - (unsigned long long )em->start, - (unsigned long long )em->len, - (unsigned long long )start, - (unsigned long long )len); + em->start, em->len, start, len); err = -EIO ; goto out; }
@@ -6867,9 +6861,8 @@ static void btrfs_endio_direct_read(struct bio *bio, int err)if (csum != private) { failed:btrfs_err (root->fs_info,"csum failed ino %llu off %llu csum %u private %u" , - (unsigned long long )btrfs_ino (inode), - (unsigned long long )start, - csum, (unsigned )private); +btrfs_ino (inode), start, csum, + (unsigned )private); err = -EIO ; } }
@@ -6956,7 +6949,7 @@ static void btrfs_end_dio_bio(struct bio *bio, int err)if (err) {printk (KERN_ERR "btrfs direct IO failed ino %llu rw %lu " "sector %#Lx len %u err no %d\n" , - (unsigned long long )btrfs_ino (dip->inode), bio->bi_rw, +btrfs_ino (dip->inode), bio->bi_rw, (unsigned long long )bio->bi_sector, bio->bi_size, err); dip->errors =1 ;
@@ -7876,7 +7869,7 @@ void btrfs_destroy_inode(struct inode *inode)if (test_bit (BTRFS_INODE_HAS_ORPHAN_ITEM , &BTRFS_I (inode)->runtime_flags)) {btrfs_info (root->fs_info,"inode %llu still on the orphan list" , - (unsigned long long )btrfs_ino (inode)); +btrfs_ino (inode));atomic_dec (&root->orphan_inodes); }
@@ -7886,8 +7879,7 @@ void btrfs_destroy_inode(struct inode *inode)break ; else {btrfs_err (root->fs_info,"found ordered extent %llu %llu on inode cleanup" , - (unsigned long long )ordered->file_offset, - (unsigned long long )ordered->len); + ordered->file_offset, ordered->len);btrfs_remove_ordered_extent (inode, ordered);btrfs_put_ordered_extent (ordered);btrfs_put_ordered_extent (ordered);
fs/btrfs/ioctl.c +4 -6
@@ -1403,14 +1403,13 @@ static noinline int btrfs_ioctl_resize(struct file *file, ret = -EINVAL ; goto out_free; } -printk (KERN_INFO "btrfs: resizing devid %llu\n" , - (unsigned long long )devid); +printk (KERN_INFO "btrfs: resizing devid %llu\n" , devid); } device =btrfs_find_device (root->fs_info, devid,NULL ,NULL );if (!device) {printk (KERN_INFO "btrfs: resizer unable to find device %llu\n" , - (unsigned long long )devid); + devid); ret = -ENODEV ; goto out_free; }
@@ -1418,7 +1417,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,if (!device->writeable) {printk (KERN_INFO "btrfs: resizer unable to apply on " "readonly device %llu\n" , - (unsigned long long )devid); + devid); ret = -EPERM ; goto out_free; }
@@ -1470,8 +1469,7 @@ static noinline int btrfs_ioctl_resize(struct file *file, new_size *= root->sectorsize;printk_in_rcu (KERN_INFO "btrfs: new size for %s is %llu\n" , -rcu_str_deref (device->name), - (unsigned long long )new_size); +rcu_str_deref (device->name), new_size);if (new_size > old_size) { trans =btrfs_start_transaction (root,0 );
fs/btrfs/ordered-data.c +4 -7
@@ -67,7 +67,7 @@ static void ordered_data_tree_panic(struct inode *inode, int errno, {struct btrfs_fs_info *fs_info =btrfs_sb (inode->i_sb);btrfs_panic (fs_info, errno,"Inconsistency in ordered tree at offset " -"%llu\n" , (unsigned long long )offset); +"%llu\n" , offset); }/*
@@ -336,14 +336,12 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode, *file_offset = dec_end;if (dec_start > dec_end) {printk (KERN_CRIT "bad ordering dec_start %llu end %llu\n" , - (unsigned long long )dec_start, - (unsigned long long )dec_end); + dec_start, dec_end); } to_dec = dec_end - dec_start;if (to_dec > entry->bytes_left) {printk (KERN_CRIT "bad ordered accounting left %llu size %llu\n" , - (unsigned long long )entry->bytes_left, - (unsigned long long )to_dec); + entry->bytes_left, to_dec); } entry->bytes_left -= to_dec;if (!uptodate)
@@ -403,8 +401,7 @@ have_entry:if (io_size > entry->bytes_left) {printk (KERN_CRIT "bad ordered accounting left %llu size %llu\n" , - (unsigned long long )entry->bytes_left, - (unsigned long long )io_size); + entry->bytes_left, io_size); } entry->bytes_left -= io_size;if (!uptodate)
fs/btrfs/print-tree.c +28 -52
198 lines not on this page · raw message
fs/btrfs/qgroup.c +4 -6
@@ -394,8 +394,7 @@ next1:if (ret == -ENOENT ) {printk (KERN_WARNING "btrfs: orphan qgroup relation 0x%llx->0x%llx\n" , - (unsigned long long )found_key.objectid, - (unsigned long long )found_key.offset); + found_key.objectid, found_key.offset); ret =0 ;/* ignore the error */ }if (ret)
@@ -1174,7 +1173,7 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,if (ret) { fs_info->qgroup_flags |=BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT ;printk (KERN_INFO "unable to update quota limit for %llu\n" , - (unsigned long long )qgroupid); + qgroupid); }spin_lock (&fs_info->qgroup_lock);
@@ -1884,10 +1883,9 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path, path, 1, 0);pr_debug ("current progress key (%llu %u %llu), search_slot ret %d\n" , - (unsigned long long )fs_info->qgroup_rescan_progress.objectid, + fs_info->qgroup_rescan_progress.objectid, fs_info->qgroup_rescan_progress.type, - (unsigned long long )fs_info->qgroup_rescan_progress.offset, - ret); + fs_info->qgroup_rescan_progress.offset, ret);if (ret) {/*
fs/btrfs/relocation.c +3 -4
@@ -335,7 +335,7 @@ static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr)if (bnode->root) fs_info = bnode->root->fs_info;btrfs_panic (fs_info, errno,"Inconsistency in backref cache " -"found at offset %llu\n" , (unsigned long long )bytenr); +"found at offset %llu\n" , bytenr); }/*
@@ -4219,8 +4219,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) }printk (KERN_INFO "btrfs: relocating block group %llu flags %llu\n" , - (unsigned long long )rc->block_group->key.objectid, - (unsigned long long )rc->block_group->flags); + rc->block_group->key.objectid, rc->block_group->flags); ret =btrfs_start_all_delalloc_inodes (fs_info,0 );if (ret <0 ) {
@@ -4242,7 +4241,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)break ;printk (KERN_INFO "btrfs: found %llu extents\n" , - (unsigned long long )rc->extents_found); + rc->extents_found);if (rc->stage ==MOVE_DATA_EXTENTS && rc->found_file_extent) {btrfs_wait_ordered_range (rc->data_inode,0 , (u64)-1 );
fs/btrfs/root-tree.c +1 -2
@@ -155,8 +155,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_rootif (ret !=0 ) {btrfs_print_leaf (root, path->nodes[0 ]);printk (KERN_CRIT "unable to update root key %llu %u %llu\n" , - (unsigned long long )key->objectid, key->type, - (unsigned long long )key->offset); + key->objectid, key->type, key->offset);BUG_ON (1 ); }
fs/btrfs/scrub.c +5 -11
@@ -754,8 +754,7 @@ out: num_uncorrectable_read_errors);printk_ratelimited_in_rcu (KERN_ERR "btrfs: unable to fixup (nodatasum) error at logical %llu on dev %s\n" , - (unsigned long long )fixup->logical, -rcu_str_deref (fixup->dev->name)); + fixup->logical,rcu_str_deref (fixup->dev->name)); }btrfs_free_path (path);
@@ -1154,8 +1153,7 @@ corrected_error:spin_unlock (&sctx->stat_lock);printk_ratelimited_in_rcu (KERN_ERR "btrfs: fixed up error at logical %llu on dev %s\n" , - (unsigned long long )logical, -rcu_str_deref (dev->name)); + logical,rcu_str_deref (dev->name)); } }else { did_not_correct_error:
@@ -1164,8 +1162,7 @@ did_not_correct_error:spin_unlock (&sctx->stat_lock);printk_ratelimited_in_rcu (KERN_ERR "btrfs: unable to fixup (regular) error at logical %llu on dev %s\n" , - (unsigned long long )logical, -rcu_str_deref (dev->name)); + logical,rcu_str_deref (dev->name)); } out:
@@ -2455,8 +2452,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,printk (KERN_ERR "btrfs scrub: tree block %llu spanning " "stripes, ignored. logical=%llu\n" , - (unsigned long long )key.objectid, - (unsigned long long )logical); + key.objectid, logical); goto next; }
@@ -3176,9 +3172,7 @@ static void copy_nocow_pages_worker(struct btrfs_work *work) nocow_ctx);if (ret !=0 && ret != -ENOENT ) {pr_warn ("iterate_inodes_from_logical() failed: log %llu, phys %llu, len %llu, mir %llu, ret %d\n" , - (unsigned long long )logical, - (unsigned long long )physical_for_dev_replace, - (unsigned long long )len, + logical, physical_for_dev_replace, len, (unsigned long long )mirror_num, ret); not_written =1 ; goto out;
fs/btrfs/super.c +4 -6
@@ -513,7 +513,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) root->sectorsize); }printk (KERN_INFO "btrfs: max_inline at %llu\n" , - (unsigned long long )info->max_inline); + info->max_inline); }break ;case Opt_alloc_start:
@@ -525,7 +525,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)kfree (num);printk (KERN_INFO "btrfs: allocations start at %llu\n" , - (unsigned long long )info->alloc_start); + info->alloc_start); }break ;case Opt_noacl:
@@ -892,11 +892,9 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)if (btrfs_test_opt (root,NOBARRIER ))seq_puts (seq,",nobarrier" );if (info->max_inline !=8192 *1024 ) -seq_printf (seq,",max_inline=%llu" , - (unsigned long long )info->max_inline); +seq_printf (seq,",max_inline=%llu" , info->max_inline);if (info->alloc_start !=0 ) -seq_printf (seq,",alloc_start=%llu" , - (unsigned long long )info->alloc_start); +seq_printf (seq,",alloc_start=%llu" , info->alloc_start); if (info->thread_pool_size != min_t(unsigned long,num_online_cpus () +2 ,8 ))seq_printf (seq,",thread_pool=%d" , info->thread_pool_size);
fs/btrfs/transaction.c +1 -2
@@ -1928,8 +1928,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)list_del_init (&root->root_list);spin_unlock (&fs_info->trans_lock); -pr_debug ("btrfs: cleaner removing %llu\n" , - (unsigned long long )root->objectid); +pr_debug ("btrfs: cleaner removing %llu\n" , root->objectid);btrfs_kill_all_delayed_nodes (root);
fs/btrfs/volumes.c +7 -12
@@ -880,8 +880,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,printk (KERN_INFO "device fsid %pU " , disk_super->fsid); } -printk (KERN_CONT "devid %llu transid %llu %s\n" , - (unsigned long long )devid, (unsigned long long )transid, path); +printk (KERN_CONT "devid %llu transid %llu %s\n" , devid, transid, path); ret =device_list_add (path, disk_super, devid, fs_devices_ret);if (!ret && fs_devices_ret)
@@ -3139,7 +3138,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, (bctl->data.target & ~allowed))) {printk (KERN_ERR "btrfs: unable to start balance with target " "data profile %llu\n" , - (unsigned long long )bctl->data.target); + bctl->data.target); ret = -EINVAL ; goto out; }
@@ -3148,7 +3147,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, (bctl->meta.target & ~allowed))) {printk (KERN_ERR "btrfs: unable to start balance with target " "metadata profile %llu\n" , - (unsigned long long )bctl->meta.target); + bctl->meta.target); ret = -EINVAL ; goto out; }
@@ -3157,7 +3156,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, (bctl->sys.target & ~allowed))) {printk (KERN_ERR "btrfs: unable to start balance with target " "system profile %llu\n" , - (unsigned long long )bctl->sys.target); + bctl->sys.target); ret = -EINVAL ; goto out; }
@@ -4375,8 +4374,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,if (!em) {btrfs_crit (fs_info,"unable to find logical %llu len %llu" , - (unsigned long long )logical, - (unsigned long long )*length); + logical, *length);return -EINVAL ; }
@@ -5246,9 +5244,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,if (map_length < length) {btrfs_crit (root->fs_info,"mapping failed logical %llu bio len %llu len %llu" , - (unsigned long long )logical, - (unsigned long long )length, - (unsigned long long )map_length); + logical, length, map_length);BUG (); }
@@ -5519,8 +5515,7 @@ static int read_one_dev(struct btrfs_root *root,return -EIO ;if (!device) { -btrfs_warn (root->fs_info,"devid %llu missing" , - (unsigned long long )devid); +btrfs_warn (root->fs_info,"devid %llu missing" , devid); device =add_missing_dev (root, devid, dev_uuid);if (!device)return -ENOMEM ;
Signature · 1 line
1.7.9.5
PATCH 9/12 Btrfs: Make btrfs_header_chunk_tree_uuid() return unsigned long
In reply to Geert UytterhoevenInternally, btrfs_header_chunk_tree_uuid() calculates an unsigned long, but casts it to a pointer, while all callers cast it to unsigned long again.
--- fs/btrfs/ctree.c | 7 +++---- fs/btrfs/ctree.h | 5 ++--- fs/btrfs/disk-io.c | 5 ++--- fs/btrfs/ioctl.c | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-)
fs/btrfs/ctree.c +3 -4
@@ -3143,8 +3143,7 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, BTRFS_FSID_SIZE);write_extent_buffer (c, root->fs_info->chunk_tree_uuid, - (unsigned long )btrfs_header_chunk_tree_uuid (c), -BTRFS_UUID_SIZE ); +btrfs_header_chunk_tree_uuid (c),BTRFS_UUID_SIZE );btrfs_set_node_key (c, &lower_key,0 );btrfs_set_node_blockptr (c,0 , lower->start);
@@ -3281,7 +3280,7 @@ static noinline int split_node(struct btrfs_trans_handle *trans,write_extent_buffer (split, root->fs_info->fsid,btrfs_header_fsid (split),BTRFS_FSID_SIZE );write_extent_buffer (split, root->fs_info->chunk_tree_uuid, - (unsigned long )btrfs_header_chunk_tree_uuid (split), +btrfs_header_chunk_tree_uuid (split),BTRFS_UUID_SIZE );tree_mod_log_eb_copy (root->fs_info, split, c,0 , mid, c_nritems - mid);
@@ -4037,7 +4036,7 @@ again: btrfs_header_fsid(right), BTRFS_FSID_SIZE);write_extent_buffer (right, root->fs_info->chunk_tree_uuid, - (unsigned long )btrfs_header_chunk_tree_uuid (right), +btrfs_header_chunk_tree_uuid (right),BTRFS_UUID_SIZE );if (split ==0 ) {
fs/btrfs/ctree.h +2 -3
@@ -2608,10 +2608,9 @@ static inline unsigned long btrfs_header_fsid(struct extent_buffer *eb)return offsetof(struct btrfs_header , fsid); } -static inline u8 *btrfs_header_chunk_tree_uuid (struct extent_buffer *eb) +static inline unsigned long btrfs_header_chunk_tree_uuid (struct extent_buffer *eb) { -unsigned long ptr = offsetof(struct btrfs_header , chunk_tree_uuid); -return (u8 *)ptr; +return offsetof(struct btrfs_header , chunk_tree_uuid); }static inline int btrfs_is_leaf (struct extent_buffer *eb)
fs/btrfs/disk-io.c +2 -3
@@ -1288,7 +1288,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,write_extent_buffer (leaf, fs_info->fsid,btrfs_header_fsid (leaf),BTRFS_FSID_SIZE );write_extent_buffer (leaf, fs_info->chunk_tree_uuid, - (unsigned long )btrfs_header_chunk_tree_uuid (leaf), +btrfs_header_chunk_tree_uuid (leaf),BTRFS_UUID_SIZE );btrfs_mark_buffer_dirty (leaf);
@@ -2607,8 +2607,7 @@ int open_ctree(struct super_block *sb, chunk_root->commit_root =btrfs_root_node (chunk_root);read_extent_buffer (chunk_root->node, fs_info->chunk_tree_uuid, - (unsigned long )btrfs_header_chunk_tree_uuid (chunk_root->node), -BTRFS_UUID_SIZE ); +btrfs_header_chunk_tree_uuid (chunk_root->node),BTRFS_UUID_SIZE ); ret =btrfs_read_chunk_tree (chunk_root);if (ret) {
fs/btrfs/ioctl.c +1 -1
@@ -428,7 +428,7 @@ static noinline int create_subvol(struct inode *dir,write_extent_buffer (leaf, root->fs_info->fsid,btrfs_header_fsid (leaf),BTRFS_FSID_SIZE );write_extent_buffer (leaf, root->fs_info->chunk_tree_uuid, - (unsigned long )btrfs_header_chunk_tree_uuid (leaf), +btrfs_header_chunk_tree_uuid (leaf),BTRFS_UUID_SIZE );btrfs_mark_buffer_dirty (leaf);
Signature · 1 line
1.7.9.5
Re: [PATCH 01/12] Btrfs: Remove superfluous casts from u64 to unsigned long long
In reply to Geert UytterhoevenQuoted 48 lines · Geert Uytterhoeven
u64 is "unsigned long long" on all architectures now, so there's no need to cast it when formatting it using the "ll" length modifier.
Signed-off-by Geert Uytterhoeven <[email protected]>--- fs/btrfs/backref.c | 24 ++-- fs/btrfs/check-integrity.c | 294 ++++++++++++++----------------------------- fs/btrfs/compression.c | 5 +- fs/btrfs/ctree.c | 6 +- fs/btrfs/delayed-inode.c | 10 +- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/disk-io.c | 25 ++-- fs/btrfs/extent-tree.c | 47 +++---- fs/btrfs/extent_io.c | 30 ++--- fs/btrfs/file-item.c | 4 +- fs/btrfs/free-space-cache.c | 6 +- fs/btrfs/inode.c | 24 ++-- fs/btrfs/ioctl.c | 10 +- fs/btrfs/ordered-data.c | 11 +- fs/btrfs/print-tree.c | 80 +++++------- fs/btrfs/qgroup.c | 10 +- fs/btrfs/relocation.c | 7 +- fs/btrfs/root-tree.c | 3 +- fs/btrfs/scrub.c | 16 +-- fs/btrfs/super.c | 10 +- fs/btrfs/transaction.c | 3 +- fs/btrfs/volumes.c | 19 ++- 22 files changed, 222 insertions(+), 424 deletions(-)fs/btrfs/backref.c +3
-4@@ -295,10 +295,9 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ret =btrfs_search_old_slot (root, &ref->key_for_search, path, time_seq);pr_debug ("search slot in root %llu (level %d, ref count %d) returned " "%d for key (%llu %u %llu)\n" , - (unsigned long long )ref->root_id, level, ref->count, ret, - (unsigned long long )ref->key_for_search.objectid, - ref->key_for_search.type, - (unsigned long long )ref->key_for_search.offset); + ref->root_id, level, ref->count, ret, + ref->key_for_search.objectid, ref->key_for_search.type, + ref->key_for_search.offset);if (ret <0 ) goto out;
fs/btrfs/backref.c int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, · line 1328
Quoted 6 lines
fs/btrfs/backref.c +1
-2@@ -1326,8 +1325,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, found_key->type != BTRFS_METADATA_ITEM_KEY) || found_key->objectid > logical || found_key->objectid + size <= logical) { -pr_debug ("logical %llu is not within any extent\n" , - (unsigned long long )logical); +pr_debug ("logical %llu is not within any extent\n" , logical);
...
Many platforms use "long" for u64, so without these casts, they'll generate compile-time printf-format warnings. See int-l64.h, and the various arch/*/include/uapi/asm/types.h files that include it - ia64, ppc, etc.
-Eric
Re: [PATCH 01/12] Btrfs: Remove superfluous casts from u64 to unsigned long long
Quoted 58 lines · Eric Sandeen
Quoted 54 lines · Geert Uytterhoeven
u64 is "unsigned long long" on all architectures now, so there's no need to cast it when formatting it using the "ll" length modifier.
Signed-off-by Geert Uytterhoeven <[email protected]>--- fs/btrfs/backref.c | 24 ++-- fs/btrfs/check-integrity.c | 294 ++++++++++++++----------------------------- fs/btrfs/compression.c | 5 +- fs/btrfs/ctree.c | 6 +- fs/btrfs/delayed-inode.c | 10 +- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/disk-io.c | 25 ++-- fs/btrfs/extent-tree.c | 47 +++---- fs/btrfs/extent_io.c | 30 ++--- fs/btrfs/file-item.c | 4 +- fs/btrfs/free-space-cache.c | 6 +- fs/btrfs/inode.c | 24 ++-- fs/btrfs/ioctl.c | 10 +- fs/btrfs/ordered-data.c | 11 +- fs/btrfs/print-tree.c | 80 +++++------- fs/btrfs/qgroup.c | 10 +- fs/btrfs/relocation.c | 7 +- fs/btrfs/root-tree.c | 3 +- fs/btrfs/scrub.c | 16 +-- fs/btrfs/super.c | 10 +- fs/btrfs/transaction.c | 3 +- fs/btrfs/volumes.c | 19 ++- 22 files changed, 222 insertions(+), 424 deletions(-)fs/btrfs/backref.c +4
-6@@ -295,10 +295,9 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, ret =btrfs_search_old_slot (root, &ref->key_for_search, path, time_seq);pr_debug ("search slot in root %llu (level %d, ref count %d) returned " "%d for key (%llu %u %llu)\n" , - (unsigned long long )ref->root_id, level, ref->count, ret, - (unsigned long long )ref->key_for_search.objectid, - ref->key_for_search.type, - (unsigned long long )ref->key_for_search.offset); + ref->root_id, level, ref->count, ret, + ref->key_for_search.objectid, ref->key_for_search.type, + ref->key_for_search.offset);if (ret <0 ) goto out;@@ -1326,8 +1325,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, found_key->type != BTRFS_METADATA_ITEM_KEY) || found_key->objectid > logical || found_key->objectid + size <= logical) { -pr_debug ("logical %llu is not within any extent\n" , - (unsigned long long )logical); +pr_debug ("logical %llu is not within any extent\n" , logical);...
Quoted 3 lines
Many platforms use "long" for u64, so without these casts, they'll generate compile-time printf-format warnings. See
int-l64.h, and the variousarch/*/include/uapi/asm/types.hfiles that include it - ia64, ppc, etc.
Sorry, should have read your commit message first ;) I didn't know that this had changed...
-Eric
Quoted 2 lines
-Eric