aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2009-12-07 16:16:07 -0500
committerJoel Becker <joel.becker@oracle.com>2010-05-05 21:17:30 -0400
commite3b4a97dbe9741a3227c3ed857a0632532fcd386 (patch)
tree31da8dd09ad6ef8959b287e36e98ead30472a284 /fs/ocfs2
parent4fe370afaae49c57619bb0bedb75de7e7c168308 (diff)
ocfs2: use allocation reservations for directory data
Use the reservations system for unindexed dir tree allocations. We don't bother with the indexed tree as reads from it are mostly random anyway. Directory reservations are marked seperately, to allow the reservations code a chance to optimize their window sizes. This patch allocates only 8 bits for directory windows as they generally are not expected to grow as quickly as file data. Future improvements to dir window sizing can trivially be made. Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/dir.c3
-rw-r--r--fs/ocfs2/inode.c4
-rw-r--r--fs/ocfs2/reservations.c8
-rw-r--r--fs/ocfs2/reservations.h4
-rw-r--r--fs/ocfs2/suballoc.c1
5 files changed, 17 insertions, 3 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 6d832487c187..8563f97c58af 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2977,6 +2977,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
2977 * if we only get one now, that's enough to continue. The rest 2977 * if we only get one now, that's enough to continue. The rest
2978 * will be claimed after the conversion to extents. 2978 * will be claimed after the conversion to extents.
2979 */ 2979 */
2980 data_ac->ac_resv = &oi->ip_la_data_resv;
2980 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len); 2981 ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len);
2981 if (ret) { 2982 if (ret) {
2982 mlog_errno(ret); 2983 mlog_errno(ret);
@@ -3347,6 +3348,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
3347 goto bail; 3348 goto bail;
3348 } 3349 }
3349 3350
3351 data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv;
3352
3350 credits = ocfs2_calc_extend_credits(sb, el, 1); 3353 credits = ocfs2_calc_extend_credits(sb, el, 1);
3351 } else { 3354 } else {
3352 spin_unlock(&OCFS2_I(dir)->ip_lock); 3355 spin_unlock(&OCFS2_I(dir)->ip_lock);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 62b4743fb6f1..9ee13f70da57 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -377,6 +377,10 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
377 377
378 OCFS2_I(inode)->ip_last_used_slot = 0; 378 OCFS2_I(inode)->ip_last_used_slot = 0;
379 OCFS2_I(inode)->ip_last_used_group = 0; 379 OCFS2_I(inode)->ip_last_used_group = 0;
380
381 if (S_ISDIR(inode->i_mode))
382 ocfs2_resv_set_type(&OCFS2_I(inode)->ip_la_data_resv,
383 OCFS2_RESV_FLAG_DIR);
380 mlog_exit_void(); 384 mlog_exit_void();
381} 385}
382 386
diff --git a/fs/ocfs2/reservations.c b/fs/ocfs2/reservations.c
index 79642d608210..7fc6cfee95f1 100644
--- a/fs/ocfs2/reservations.c
+++ b/fs/ocfs2/reservations.c
@@ -44,6 +44,7 @@ DEFINE_SPINLOCK(resv_lock);
44 44
45#define OCFS2_MIN_RESV_WINDOW_BITS 8 45#define OCFS2_MIN_RESV_WINDOW_BITS 8
46#define OCFS2_MAX_RESV_WINDOW_BITS 1024 46#define OCFS2_MAX_RESV_WINDOW_BITS 1024
47#define OCFS2_RESV_DIR_WINDOW_BITS OCFS2_MIN_RESV_WINDOW_BITS
47 48
48static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap, 49static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,
49 struct ocfs2_alloc_reservation *resv) 50 struct ocfs2_alloc_reservation *resv)
@@ -51,8 +52,11 @@ static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,
51 struct ocfs2_super *osb = resmap->m_osb; 52 struct ocfs2_super *osb = resmap->m_osb;
52 unsigned int bits; 53 unsigned int bits;
53 54
54 /* 8, 16, 32, 64, 128, 256, 512, 1024 */ 55 if (!(resv->r_flags & OCFS2_RESV_FLAG_DIR)) {
55 bits = 4 << osb->osb_resv_level; 56 /* 8, 16, 32, 64, 128, 256, 512, 1024 */
57 bits = 4 << osb->osb_resv_level;
58 } else
59 bits = OCFS2_RESV_DIR_WINDOW_BITS;
56 60
57 return bits; 61 return bits;
58} 62}
diff --git a/fs/ocfs2/reservations.h b/fs/ocfs2/reservations.h
index 8341cd0ef855..34bb308375c5 100644
--- a/fs/ocfs2/reservations.h
+++ b/fs/ocfs2/reservations.h
@@ -42,6 +42,8 @@ struct ocfs2_alloc_reservation {
42#define OCFS2_RESV_FLAG_INUSE 0x01 /* Set when r_node is part of a btree */ 42#define OCFS2_RESV_FLAG_INUSE 0x01 /* Set when r_node is part of a btree */
43#define OCFS2_RESV_FLAG_TMP 0x02 /* Temporary reservation, will be 43#define OCFS2_RESV_FLAG_TMP 0x02 /* Temporary reservation, will be
44 * destroyed immedately after use */ 44 * destroyed immedately after use */
45#define OCFS2_RESV_FLAG_DIR 0x04 /* Reservation is for an unindexed
46 * directory btree */
45 47
46struct ocfs2_reservation_map { 48struct ocfs2_reservation_map {
47 struct rb_root m_reservations; 49 struct rb_root m_reservations;
@@ -61,7 +63,7 @@ struct ocfs2_reservation_map {
61 63
62void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv); 64void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv);
63 65
64#define OCFS2_RESV_TYPES (OCFS2_RESV_FLAG_TMP) 66#define OCFS2_RESV_TYPES (OCFS2_RESV_FLAG_TMP|OCFS2_RESV_FLAG_DIR)
65void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv, 67void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv,
66 unsigned int flags); 68 unsigned int flags);
67 69
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index d4babfba4f04..f20bcbf64ce0 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -130,6 +130,7 @@ void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac)
130 } 130 }
131 brelse(ac->ac_bh); 131 brelse(ac->ac_bh);
132 ac->ac_bh = NULL; 132 ac->ac_bh = NULL;
133 ac->ac_resv = NULL;
133} 134}
134 135
135void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) 136void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)