Skip to contentSkip to conversation

f2fs: order free nid allocator

PATCH New Chao Yu 1 participant 1 message Sep 30, 2017 F2FS file system

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH v2 1/1 f2fs: order free nid allocator

Previously, there is no restrict order among free nid allocators, if there are no free nids being cached in memory, previous allocator will try to load them by scanning NAT pages, but after that, these newly loaded free nids could be grabbed by later allocators, result in long delay of previous allocator during nid allocation.

This patch tries to refactor alloc_nid flow to serialize allocators.

---
v2:
- fix deadlock due to incorrectly using of down_trylock.

 fs/f2fs/f2fs.h |  3 ++-
 fs/f2fs/node.c | 63 ++++++++++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 50 insertions(+), 16 deletions(-)
fs/f2fs/f2fs.h +2 -1
index c07690ce9a46..97ac7e6ab14b 100644
@@ -722,7 +722,8 @@ struct f2fs_nm_info {
 	struct list_head free_nid_list;		/* list for free nids excluding preallocated nids */
 	unsigned int nid_cnt[MAX_NID_STATE];	/* the number of free node id */
 	spinlock_t nid_list_lock;	/* protect nid lists ops */
-	struct mutex build_lock;	/* lock for build free nids */
+	struct semaphore build_lock;	/* lock for build free nids */
+	atomic_t allocator;		/* # of free nid allocators */
 	unsigned char (*free_nid_bitmap)[NAT_ENTRY_BITMAP_SIZE];
 	unsigned char *nat_block_bitmap;
 	unsigned short *free_nid_count;	/* free nid count of NAT block */
fs/f2fs/node.c +48 -15

114 lines not on this page · raw message

Signature · 6 lines
2.13.1.388.g69e6b9b4f4a9


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot