aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGu Zheng <guz.fnst@cn.fujitsu.com>2014-01-10 05:09:14 -0500
committerJaegeuk Kim <jaegeuk.kim@samsung.com>2014-01-14 04:12:05 -0500
commit17b692f60e93f5d417fcdbfd681b0f20f9f31ec8 (patch)
treecbc5410c54767f86ac07eae945851cc5ee782765
parentc1ef37257229dc8903615eaf1d1abaa5da3f0686 (diff)
f2fs: use spinlock rather than mutex for better speed
With the 2 previous changes, all the long time operations are moved out of the protection region, so here we can use spinlock rather than mutex (orphan_inode_mutex) for lower overhead. Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com> Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r--fs/f2fs/checkpoint.c24
-rw-r--r--fs/f2fs/f2fs.h2
2 files changed, 13 insertions, 13 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 681782c715fb..4de0345f73f3 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -196,22 +196,22 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
196{ 196{
197 int err = 0; 197 int err = 0;
198 198
199 mutex_lock(&sbi->orphan_inode_mutex); 199 spin_lock(&sbi->orphan_inode_lock);
200 if (unlikely(sbi->n_orphans >= sbi->max_orphans)) 200 if (unlikely(sbi->n_orphans >= sbi->max_orphans))
201 err = -ENOSPC; 201 err = -ENOSPC;
202 else 202 else
203 sbi->n_orphans++; 203 sbi->n_orphans++;
204 mutex_unlock(&sbi->orphan_inode_mutex); 204 spin_unlock(&sbi->orphan_inode_lock);
205 205
206 return err; 206 return err;
207} 207}
208 208
209void release_orphan_inode(struct f2fs_sb_info *sbi) 209void release_orphan_inode(struct f2fs_sb_info *sbi)
210{ 210{
211 mutex_lock(&sbi->orphan_inode_mutex); 211 spin_lock(&sbi->orphan_inode_lock);
212 f2fs_bug_on(sbi->n_orphans == 0); 212 f2fs_bug_on(sbi->n_orphans == 0);
213 sbi->n_orphans--; 213 sbi->n_orphans--;
214 mutex_unlock(&sbi->orphan_inode_mutex); 214 spin_unlock(&sbi->orphan_inode_lock);
215} 215}
216 216
217void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) 217void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
@@ -222,12 +222,12 @@ void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
222 new = f2fs_kmem_cache_alloc(orphan_entry_slab, GFP_ATOMIC); 222 new = f2fs_kmem_cache_alloc(orphan_entry_slab, GFP_ATOMIC);
223 new->ino = ino; 223 new->ino = ino;
224 224
225 mutex_lock(&sbi->orphan_inode_mutex); 225 spin_lock(&sbi->orphan_inode_lock);
226 head = &sbi->orphan_inode_list; 226 head = &sbi->orphan_inode_list;
227 list_for_each(this, head) { 227 list_for_each(this, head) {
228 orphan = list_entry(this, struct orphan_inode_entry, list); 228 orphan = list_entry(this, struct orphan_inode_entry, list);
229 if (orphan->ino == ino) { 229 if (orphan->ino == ino) {
230 mutex_unlock(&sbi->orphan_inode_mutex); 230 spin_unlock(&sbi->orphan_inode_lock);
231 kmem_cache_free(orphan_entry_slab, new); 231 kmem_cache_free(orphan_entry_slab, new);
232 return; 232 return;
233 } 233 }
@@ -242,7 +242,7 @@ void add_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
242 list_add(&new->list, this->prev); 242 list_add(&new->list, this->prev);
243 else 243 else
244 list_add_tail(&new->list, head); 244 list_add_tail(&new->list, head);
245 mutex_unlock(&sbi->orphan_inode_mutex); 245 spin_unlock(&sbi->orphan_inode_lock);
246} 246}
247 247
248void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) 248void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
@@ -250,7 +250,7 @@ void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
250 struct list_head *head; 250 struct list_head *head;
251 struct orphan_inode_entry *orphan; 251 struct orphan_inode_entry *orphan;
252 252
253 mutex_lock(&sbi->orphan_inode_mutex); 253 spin_lock(&sbi->orphan_inode_lock);
254 head = &sbi->orphan_inode_list; 254 head = &sbi->orphan_inode_list;
255 list_for_each_entry(orphan, head, list) { 255 list_for_each_entry(orphan, head, list) {
256 if (orphan->ino == ino) { 256 if (orphan->ino == ino) {
@@ -261,7 +261,7 @@ void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
261 break; 261 break;
262 } 262 }
263 } 263 }
264 mutex_unlock(&sbi->orphan_inode_mutex); 264 spin_unlock(&sbi->orphan_inode_lock);
265} 265}
266 266
267static void recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) 267static void recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
@@ -318,7 +318,7 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
318 pages[index] = grab_meta_page(sbi, start_blk + index); 318 pages[index] = grab_meta_page(sbi, start_blk + index);
319 319
320 index = 1; 320 index = 1;
321 mutex_lock(&sbi->orphan_inode_mutex); 321 spin_lock(&sbi->orphan_inode_lock);
322 head = &sbi->orphan_inode_list; 322 head = &sbi->orphan_inode_list;
323 323
324 /* loop for each orphan inode entry and write them in Jornal block */ 324 /* loop for each orphan inode entry and write them in Jornal block */
@@ -357,7 +357,7 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
357 f2fs_put_page(page, 1); 357 f2fs_put_page(page, 1);
358 } 358 }
359 359
360 mutex_unlock(&sbi->orphan_inode_mutex); 360 spin_unlock(&sbi->orphan_inode_lock);
361} 361}
362 362
363static struct page *validate_checkpoint(struct f2fs_sb_info *sbi, 363static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
@@ -828,7 +828,7 @@ void write_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
828 828
829void init_orphan_info(struct f2fs_sb_info *sbi) 829void init_orphan_info(struct f2fs_sb_info *sbi)
830{ 830{
831 mutex_init(&sbi->orphan_inode_mutex); 831 spin_lock_init(&sbi->orphan_inode_lock);
832 INIT_LIST_HEAD(&sbi->orphan_inode_list); 832 INIT_LIST_HEAD(&sbi->orphan_inode_list);
833 sbi->n_orphans = 0; 833 sbi->n_orphans = 0;
834 /* 834 /*
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 8466b5ea76f7..ee304fb71e1f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -412,7 +412,7 @@ struct f2fs_sb_info {
412 412
413 /* for orphan inode management */ 413 /* for orphan inode management */
414 struct list_head orphan_inode_list; /* orphan inode list */ 414 struct list_head orphan_inode_list; /* orphan inode list */
415 struct mutex orphan_inode_mutex; /* for orphan inode list */ 415 spinlock_t orphan_inode_lock; /* for orphan inode list */
416 unsigned int n_orphans; /* # of orphan inodes */ 416 unsigned int n_orphans; /* # of orphan inodes */
417 unsigned int max_orphans; /* max orphan inodes */ 417 unsigned int max_orphans; /* max orphan inodes */
418 418