diff options
author | Gu Zheng <guz.fnst@cn.fujitsu.com> | 2013-10-22 02:52:26 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-10-22 07:16:02 -0400 |
commit | 7bd59381c82defe19875284c48b1ac9dacd16e8f (patch) | |
tree | 872cece782fc04b77b220060022f43d08886090b /fs/f2fs/f2fs.h | |
parent | 435f2a1b58ac8f50894f23549c97791085f7cba2 (diff) |
f2fs: introduce f2fs_kmem_cache_alloc to hide the unfailed, kmem cache allocation
Introduce the unfailed version of kmem_cache_alloc named f2fs_kmem_cache_alloc
to hide the retry routine and make the code a bit cleaner.
v2:
Fix the wrong use of 'retry' tag pointed out by Gao feng.
Use more neat code to remove redundant tag suggested by Haicheng Li.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs/f2fs.h')
-rw-r--r-- | fs/f2fs/f2fs.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 171c52fc95bb..29492754bd7d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/crc32.h> | 18 | #include <linux/crc32.h> |
19 | #include <linux/magic.h> | 19 | #include <linux/magic.h> |
20 | #include <linux/kobject.h> | 20 | #include <linux/kobject.h> |
21 | #include <linux/sched.h> | ||
21 | 22 | ||
22 | /* | 23 | /* |
23 | * For mount options | 24 | * For mount options |
@@ -787,6 +788,20 @@ static inline struct kmem_cache *f2fs_kmem_cache_create(const char *name, | |||
787 | return kmem_cache_create(name, size, 0, SLAB_RECLAIM_ACCOUNT, ctor); | 788 | return kmem_cache_create(name, size, 0, SLAB_RECLAIM_ACCOUNT, ctor); |
788 | } | 789 | } |
789 | 790 | ||
791 | static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep, | ||
792 | gfp_t flags) | ||
793 | { | ||
794 | void *entry; | ||
795 | retry: | ||
796 | entry = kmem_cache_alloc(cachep, flags); | ||
797 | if (!entry) { | ||
798 | cond_resched(); | ||
799 | goto retry; | ||
800 | } | ||
801 | |||
802 | return entry; | ||
803 | } | ||
804 | |||
790 | #define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino) | 805 | #define RAW_IS_INODE(p) ((p)->footer.nid == (p)->footer.ino) |
791 | 806 | ||
792 | static inline bool IS_INODE(struct page *page) | 807 | static inline bool IS_INODE(struct page *page) |