[PATCH] Btrfs: remove redundant codes for split_state()
These two lines are needless, remove them. Signed-off-by: Qinghuang Feng qhfeng.ker...@gmail.com --- diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 37d43b5..ebe6b29 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -415,8 +415,6 @@ static int split_state(struct extent_io_tree *tree, struct extent_state *orig, node = tree_insert(tree-state, prealloc-end, prealloc-rb_node); if (node) { - struct extent_state *found; - found = rb_entry(node, struct extent_state, rb_node); free_extent_state(prealloc); return -EEXIST; } -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Btrfs: fix bug in open_ctree()
a bug in open_ctree: struct btrfs_root *open_ctree(..) { if (!extent_root || !tree_root || !fs_info || !chunk_root || !dev_root || !csum_root) { err = -ENOMEM; goto fail; //When code flow goes to fail, fs_info may be NULL or uninitialized. } fail: btrfs_close_devices(fs_info-fs_devices);// ! btrfs_mapping_tree_free(fs_info-mapping_tree);// ! kfree(extent_root); kfree(tree_root); bdi_destroy(fs_info-bdi);// ! ... ) Signed-off-by: Qinghuang Feng qhfeng.ker...@gmail.com --- diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 81a3138..f860087 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1828,13 +1828,14 @@ fail_sb_buffer: fail_iput: invalidate_inode_pages2(fs_info-btree_inode-i_mapping); iput(fs_info-btree_inode); -fail: + btrfs_close_devices(fs_info-fs_devices); btrfs_mapping_tree_free(fs_info-mapping_tree); + bdi_destroy(fs_info-bdi); +fail: kfree(extent_root); kfree(tree_root); - bdi_destroy(fs_info-bdi); kfree(fs_info); kfree(chunk_root); kfree(dev_root); -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Btrfs: simplify iteration codes
On Fri, Jan 16, 2009 at 3:25 PM, Qinghuang Feng qhfeng.ker...@gmail.com wrote: merge list_for_each and list_entry to list_for_each_entry. Please ignore this patch, I will resend a patch to cleanup all the similar codes in btrfs. -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH resend] Btrfs: simplify iteration codes
Merge list_for_each* and list_entry to list_for_each_entry* Signed-off-by: Qinghuang Feng qhfeng.ker...@gmail.com --- diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 81a3138..aedfcec 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1136,7 +1136,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) { struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data; int ret = 0; - struct list_head *cur; struct btrfs_device *device; struct backing_dev_info *bdi; #if 0 @@ -1144,8 +1143,7 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) btrfs_congested_async(info, 0)) return 1; #endif - list_for_each(cur, info-fs_devices-devices) { - device = list_entry(cur, struct btrfs_device, dev_list); + list_for_each_entry(device, info-fs_devices-devices, dev_list) { if (!device-bdev) continue; bdi = blk_get_backing_dev_info(device-bdev); @@ -1163,13 +1161,11 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) */ static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page) { - struct list_head *cur; struct btrfs_device *device; struct btrfs_fs_info *info; info = (struct btrfs_fs_info *)bdi-unplug_io_data; - list_for_each(cur, info-fs_devices-devices) { - device = list_entry(cur, struct btrfs_device, dev_list); + list_for_each_entry(device, info-fs_devices-devices, dev_list) { if (!device-bdev) continue; @@ -1995,7 +1991,6 @@ static int write_dev_supers(struct btrfs_device *device, int write_all_supers(struct btrfs_root *root, int max_mirrors) { - struct list_head *cur; struct list_head *head = root-fs_info-fs_devices-devices; struct btrfs_device *dev; struct btrfs_super_block *sb; @@ -2011,8 +2006,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors) sb = root-fs_info-super_for_commit; dev_item = sb-dev_item; - list_for_each(cur, head) { - dev = list_entry(cur, struct btrfs_device, dev_list); + list_for_each_entry(dev, head, dev_list) { if (!dev-bdev) { total_errors++; continue; @@ -2045,8 +2039,7 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors) } total_errors = 0; - list_for_each(cur, head) { - dev = list_entry(cur, struct btrfs_device, dev_list); + list_for_each_entry(dev, head, dev_list) { if (!dev-bdev) continue; if (!dev-in_fs_metadata || !dev-writeable) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 293da65..c8815c1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -326,10 +326,8 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info, u64 flags) { struct list_head *head = info-space_info; - struct list_head *cur; struct btrfs_space_info *found; - list_for_each(cur, head) { - found = list_entry(cur, struct btrfs_space_info, list); + list_for_each_entry(found, head, list) { if (found-flags == flags) return found; } @@ -3014,7 +3012,6 @@ loop_check: static void dump_space_info(struct btrfs_space_info *info, u64 bytes) { struct btrfs_block_group_cache *cache; - struct list_head *l; printk(KERN_INFO space_info has %llu free, is %sfull\n, (unsigned long long)(info-total_bytes - info-bytes_used - @@ -3022,8 +3019,7 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes) (info-full) ? : not ); down_read(info-groups_sem); - list_for_each(l, info-block_groups) { - cache = list_entry(l, struct btrfs_block_group_cache, list); + list_for_each_entry(cache, info-block_groups, list) { spin_lock(cache-lock); printk(KERN_INFO block group %llu has %llu bytes, %llu used %llu pinned %llu reserved\n, diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8adfe05..72c9277 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1324,12 +1324,11 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans, struct inode *inode, u64 file_offset, struct list_head *list) { - struct list_head *cur; struct btrfs_ordered_sum *sum; btrfs_set_trans_block_group(trans, inode); - list_for_each(cur, list) { - sum = list_entry(cur, struct btrfs_ordered_sum, list); + + list_for_each_entry(sum, list, list) { btrfs_csum_file_blocks
[PATCH] Btrfs: simplify iteration codes
merge list_for_each and list_entry to list_for_each_entry. Signed-off-by: Qinghuang Feng qhfeng.ker...@gmail.com --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b187b53..70f0248 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -104,10 +104,8 @@ static noinline struct btrfs_device *__find_device(struct list_head *head, u64 devid, u8 *uuid) { struct btrfs_device *dev; - struct list_head *cur; - list_for_each(cur, head) { - dev = list_entry(cur, struct btrfs_device, dev_list); + list_for_each_entry(dev, head, dev_list) { if (dev-devid == devid (!uuid || !memcmp(dev-uuid, uuid, BTRFS_UUID_SIZE))) { return dev; @@ -118,11 +116,9 @@ static noinline struct btrfs_device *__find_device(struct list_head *head, static noinline struct btrfs_fs_devices *find_fsid(u8 *fsid) { - struct list_head *cur; struct btrfs_fs_devices *fs_devices; - list_for_each(cur, fs_uuids) { - fs_devices = list_entry(cur, struct btrfs_fs_devices, list); + list_for_each_entry(fs_devices, fs_uuids, list) { if (memcmp(fsid, fs_devices-fsid, BTRFS_FSID_SIZE) == 0) return fs_devices; } -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] BTRFS: Mark '__init' for btrfs_init_cachep, btrfs_init_sysfs,btrfs_interface_init
There functions are only called by 'static int __init init_btrfs_fs(void)', so also mark them as '__init'. Signed-off-by: Qinghuang Feng qhfeng.ker...@gmail.com --- diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index eee060f..7e03ec8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2045,7 +2045,7 @@ int btrfs_write_inode(struct inode *inode, int wait); void btrfs_dirty_inode(struct inode *inode); struct inode *btrfs_alloc_inode(struct super_block *sb); void btrfs_destroy_inode(struct inode *inode); -int btrfs_init_cachep(void); +int __init btrfs_init_cachep(void); void btrfs_destroy_cachep(void); long btrfs_ioctl_trans_end(struct file *file); struct inode *btrfs_ilookup(struct super_block *s, u64 objectid, @@ -2089,7 +2089,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, struct btrfs_root *root, int cache_only); /* sysfs.c */ -int btrfs_init_sysfs(void); +int __init btrfs_init_sysfs(void); void btrfs_exit_sysfs(void); int btrfs_sysfs_add_super(struct btrfs_fs_info *fs); int btrfs_sysfs_add_root(struct btrfs_root *root); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8adfe05..7170c4a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4521,7 +4521,7 @@ struct kmem_cache *btrfs_cache_create(const char *name, size_t size, SLAB_MEM_SPREAD | extra_flags), ctor); } -int btrfs_init_cachep(void) +int __init btrfs_init_cachep(void) { btrfs_inode_cachep = btrfs_cache_create(btrfs_inode_cache, sizeof(struct btrfs_inode), diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0a14b49..0a3fc0d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -649,7 +649,7 @@ static struct miscdevice btrfs_misc = { .fops = btrfs_ctl_fops }; -static int btrfs_interface_init(void) +static int __init btrfs_interface_init(void) { return misc_register(btrfs_misc); } diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index a240b6f..bd73c97 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -254,7 +254,7 @@ void btrfs_sysfs_del_super(struct btrfs_fs_info *fs) wait_for_completion(fs-kobj_unregister); } -int btrfs_init_sysfs(void) +int __init btrfs_init_sysfs(void) { btrfs_kset = kset_create_and_add(btrfs, NULL, fs_kobj); if (!btrfs_kset) -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] btrfs squashfs: Move btrfs and squashfsto's magic number to linux/magic.h
Use the standard magic.h for btrfs and squashfs. Signed-off-by: Qinghuang Feng qhfeng.ker...@gmail.com --- diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0a14b49..7256cf2 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -38,6 +38,7 @@ #include linux/namei.h #include linux/miscdevice.h #include linux/version.h +#include linux/magic.h #include compat.h #include ctree.h #include disk-io.h @@ -51,7 +52,6 @@ #include export.h #include compression.h -#define BTRFS_SUPER_MAGIC 0x9123683E static struct super_operations btrfs_super_ops; diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h index 6840da1..283daaf 100644 --- a/fs/squashfs/squashfs_fs.h +++ b/fs/squashfs/squashfs_fs.h @@ -26,7 +26,6 @@ #define SQUASHFS_CACHED_FRAGMENTS CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE #define SQUASHFS_MAJOR 4 #define SQUASHFS_MINOR 0 -#define SQUASHFS_MAGIC 0x73717368 #define SQUASHFS_START 0 /* size of metadata (inode and directory) blocks */ diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index a0466d7..071df5b 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c @@ -35,6 +35,7 @@ #include linux/init.h #include linux/module.h #include linux/zlib.h +#include linux/magic.h #include squashfs_fs.h #include squashfs_fs_sb.h diff --git a/include/linux/magic.h b/include/linux/magic.h index 439f6f3..0b4df7e 100644 --- a/include/linux/magic.h +++ b/include/linux/magic.h @@ -10,11 +10,13 @@ #define SYSFS_MAGIC0x62656572 #define SECURITYFS_MAGIC 0x73636673 #define TMPFS_MAGIC0x01021994 +#define SQUASHFS_MAGIC 0x73717368 #define EFS_SUPER_MAGIC0x414A53 #define EXT2_SUPER_MAGIC 0xEF53 #define EXT3_SUPER_MAGIC 0xEF53 #define XENFS_SUPER_MAGIC 0xabba1974 #define EXT4_SUPER_MAGIC 0xEF53 +#define BTRFS_SUPER_MAGIC 0x9123683E #define HPFS_SUPER_MAGIC 0xf995e849 #define ISOFS_SUPER_MAGIC 0x9660 #define JFFS2_SUPER_MAGIC 0x72b6 -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html