diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-16 05:11:54 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-25 09:41:24 -0500 |
commit | b9a06623d9d0c6dff758d525ceb0d9e2bba8f7d6 (patch) | |
tree | 9107daa5cf1aa527603c7d33d55ca45dbe760d5a | |
parent | 4fac9f698404a5cd50b978fbdb7e54235353c215 (diff) |
UBI: get rid of ubi_ltree_slab
This slab cache is not really needed since the number of objects
is low and the constructor does not make much sense because we
allocate oblects when doint I/O, which is way slower then allocation.
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/ubi/build.c | 28 | ||||
-rw-r--r-- | drivers/mtd/ubi/eba.c | 12 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 1 |
3 files changed, 8 insertions, 33 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 8f1f9feb2d60..8b4573559dfe 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -66,9 +66,6 @@ static struct mtd_dev_param mtd_dev_param[UBI_MAX_DEVICES]; | |||
66 | /* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */ | 66 | /* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */ |
67 | struct class *ubi_class; | 67 | struct class *ubi_class; |
68 | 68 | ||
69 | /* Slab cache for lock-tree entries */ | ||
70 | struct kmem_cache *ubi_ltree_slab; | ||
71 | |||
72 | /* Slab cache for wear-leveling entries */ | 69 | /* Slab cache for wear-leveling entries */ |
73 | struct kmem_cache *ubi_wl_entry_slab; | 70 | struct kmem_cache *ubi_wl_entry_slab; |
74 | 71 | ||
@@ -858,20 +855,6 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) | |||
858 | } | 855 | } |
859 | 856 | ||
860 | /** | 857 | /** |
861 | * ltree_entry_ctor - lock tree entries slab cache constructor. | ||
862 | * @obj: the lock-tree entry to construct | ||
863 | * @cache: the lock tree entry slab cache | ||
864 | * @flags: constructor flags | ||
865 | */ | ||
866 | static void ltree_entry_ctor(struct kmem_cache *cache, void *obj) | ||
867 | { | ||
868 | struct ubi_ltree_entry *le = obj; | ||
869 | |||
870 | le->users = 0; | ||
871 | init_rwsem(&le->mutex); | ||
872 | } | ||
873 | |||
874 | /** | ||
875 | * find_mtd_device - open an MTD device by its name or number. | 858 | * find_mtd_device - open an MTD device by its name or number. |
876 | * @mtd_dev: name or number of the device | 859 | * @mtd_dev: name or number of the device |
877 | * | 860 | * |
@@ -933,17 +916,11 @@ static int __init ubi_init(void) | |||
933 | goto out_version; | 916 | goto out_version; |
934 | } | 917 | } |
935 | 918 | ||
936 | ubi_ltree_slab = kmem_cache_create("ubi_ltree_slab", | ||
937 | sizeof(struct ubi_ltree_entry), 0, | ||
938 | 0, <ree_entry_ctor); | ||
939 | if (!ubi_ltree_slab) | ||
940 | goto out_dev_unreg; | ||
941 | |||
942 | ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab", | 919 | ubi_wl_entry_slab = kmem_cache_create("ubi_wl_entry_slab", |
943 | sizeof(struct ubi_wl_entry), | 920 | sizeof(struct ubi_wl_entry), |
944 | 0, 0, NULL); | 921 | 0, 0, NULL); |
945 | if (!ubi_wl_entry_slab) | 922 | if (!ubi_wl_entry_slab) |
946 | goto out_ltree; | 923 | goto out_dev_unreg; |
947 | 924 | ||
948 | /* Attach MTD devices */ | 925 | /* Attach MTD devices */ |
949 | for (i = 0; i < mtd_devs; i++) { | 926 | for (i = 0; i < mtd_devs; i++) { |
@@ -980,8 +957,6 @@ out_detach: | |||
980 | mutex_unlock(&ubi_devices_mutex); | 957 | mutex_unlock(&ubi_devices_mutex); |
981 | } | 958 | } |
982 | kmem_cache_destroy(ubi_wl_entry_slab); | 959 | kmem_cache_destroy(ubi_wl_entry_slab); |
983 | out_ltree: | ||
984 | kmem_cache_destroy(ubi_ltree_slab); | ||
985 | out_dev_unreg: | 960 | out_dev_unreg: |
986 | misc_deregister(&ubi_ctrl_cdev); | 961 | misc_deregister(&ubi_ctrl_cdev); |
987 | out_version: | 962 | out_version: |
@@ -1005,7 +980,6 @@ static void __exit ubi_exit(void) | |||
1005 | mutex_unlock(&ubi_devices_mutex); | 980 | mutex_unlock(&ubi_devices_mutex); |
1006 | } | 981 | } |
1007 | kmem_cache_destroy(ubi_wl_entry_slab); | 982 | kmem_cache_destroy(ubi_wl_entry_slab); |
1008 | kmem_cache_destroy(ubi_ltree_slab); | ||
1009 | misc_deregister(&ubi_ctrl_cdev); | 983 | misc_deregister(&ubi_ctrl_cdev); |
1010 | class_remove_file(ubi_class, &ubi_version); | 984 | class_remove_file(ubi_class, &ubi_version); |
1011 | class_destroy(ubi_class); | 985 | class_destroy(ubi_class); |
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 85297cde4ac5..7c05c6e1abc7 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
@@ -137,10 +137,12 @@ static struct ubi_ltree_entry *ltree_add_entry(struct ubi_device *ubi, | |||
137 | { | 137 | { |
138 | struct ubi_ltree_entry *le, *le1, *le_free; | 138 | struct ubi_ltree_entry *le, *le1, *le_free; |
139 | 139 | ||
140 | le = kmem_cache_alloc(ubi_ltree_slab, GFP_NOFS); | 140 | le = kmalloc(sizeof(struct ubi_ltree_entry), GFP_NOFS); |
141 | if (!le) | 141 | if (!le) |
142 | return ERR_PTR(-ENOMEM); | 142 | return ERR_PTR(-ENOMEM); |
143 | 143 | ||
144 | le->users = 0; | ||
145 | init_rwsem(&le->mutex); | ||
144 | le->vol_id = vol_id; | 146 | le->vol_id = vol_id; |
145 | le->lnum = lnum; | 147 | le->lnum = lnum; |
146 | 148 | ||
@@ -188,7 +190,7 @@ static struct ubi_ltree_entry *ltree_add_entry(struct ubi_device *ubi, | |||
188 | spin_unlock(&ubi->ltree_lock); | 190 | spin_unlock(&ubi->ltree_lock); |
189 | 191 | ||
190 | if (le_free) | 192 | if (le_free) |
191 | kmem_cache_free(ubi_ltree_slab, le_free); | 193 | kfree(le_free); |
192 | 194 | ||
193 | return le; | 195 | return le; |
194 | } | 196 | } |
@@ -236,7 +238,7 @@ static void leb_read_unlock(struct ubi_device *ubi, int vol_id, int lnum) | |||
236 | 238 | ||
237 | up_read(&le->mutex); | 239 | up_read(&le->mutex); |
238 | if (free) | 240 | if (free) |
239 | kmem_cache_free(ubi_ltree_slab, le); | 241 | kfree(le); |
240 | } | 242 | } |
241 | 243 | ||
242 | /** | 244 | /** |
@@ -292,7 +294,7 @@ static int leb_write_trylock(struct ubi_device *ubi, int vol_id, int lnum) | |||
292 | free = 0; | 294 | free = 0; |
293 | spin_unlock(&ubi->ltree_lock); | 295 | spin_unlock(&ubi->ltree_lock); |
294 | if (free) | 296 | if (free) |
295 | kmem_cache_free(ubi_ltree_slab, le); | 297 | kfree(le); |
296 | 298 | ||
297 | return 1; | 299 | return 1; |
298 | } | 300 | } |
@@ -321,7 +323,7 @@ static void leb_write_unlock(struct ubi_device *ubi, int vol_id, int lnum) | |||
321 | 323 | ||
322 | up_write(&le->mutex); | 324 | up_write(&le->mutex); |
323 | if (free) | 325 | if (free) |
324 | kmem_cache_free(ubi_ltree_slab, le); | 326 | kfree(le); |
325 | } | 327 | } |
326 | 328 | ||
327 | /** | 329 | /** |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index ef22f922f580..3cf1aa1a0240 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -399,7 +399,6 @@ struct ubi_device { | |||
399 | #endif | 399 | #endif |
400 | }; | 400 | }; |
401 | 401 | ||
402 | extern struct kmem_cache *ubi_ltree_slab; | ||
403 | extern struct kmem_cache *ubi_wl_entry_slab; | 402 | extern struct kmem_cache *ubi_wl_entry_slab; |
404 | extern struct file_operations ubi_ctrl_cdev_operations; | 403 | extern struct file_operations ubi_ctrl_cdev_operations; |
405 | extern struct file_operations ubi_cdev_operations; | 404 | extern struct file_operations ubi_cdev_operations; |