]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ocfs2: use allocation reservations for directory data
authorMark Fasheh <mfasheh@suse.com>
Mon, 7 Dec 2009 21:16:07 +0000 (13:16 -0800)
committerJoel Becker <joel.becker@oracle.com>
Thu, 6 May 2010 01:17:30 +0000 (18:17 -0700)
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>
fs/ocfs2/dir.c
fs/ocfs2/inode.c
fs/ocfs2/reservations.c
fs/ocfs2/reservations.h
fs/ocfs2/suballoc.c

index 6d832487c1871ff8c35cb6935625674b3f50807a..8563f97c58aff7a68e83d4a8c7f788185b29e28b 100644 (file)
@@ -2977,6 +2977,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
         * if we only get one now, that's enough to continue. The rest
         * will be claimed after the conversion to extents.
         */
+       data_ac->ac_resv = &oi->ip_la_data_resv;
        ret = ocfs2_claim_clusters(osb, handle, data_ac, 1, &bit_off, &len);
        if (ret) {
                mlog_errno(ret);
@@ -3347,6 +3348,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
                        goto bail;
                }
 
+               data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv;
+
                credits = ocfs2_calc_extend_credits(sb, el, 1);
        } else {
                spin_unlock(&OCFS2_I(dir)->ip_lock);
index 62b4743fb6f1b3a869f76ed2368b75592ec41465..9ee13f70da57dbeaea9f4d969a7f60c52045e4e1 100644 (file)
@@ -377,6 +377,10 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
 
        OCFS2_I(inode)->ip_last_used_slot = 0;
        OCFS2_I(inode)->ip_last_used_group = 0;
+
+       if (S_ISDIR(inode->i_mode))
+               ocfs2_resv_set_type(&OCFS2_I(inode)->ip_la_data_resv,
+                                   OCFS2_RESV_FLAG_DIR);
        mlog_exit_void();
 }
 
index 79642d60821037859050d18fa66ce7be5b7a75c7..7fc6cfee95f1567a6fa2330ed9e60f65399af0a7 100644 (file)
@@ -44,6 +44,7 @@ DEFINE_SPINLOCK(resv_lock);
 
 #define        OCFS2_MIN_RESV_WINDOW_BITS      8
 #define        OCFS2_MAX_RESV_WINDOW_BITS      1024
+#define        OCFS2_RESV_DIR_WINDOW_BITS      OCFS2_MIN_RESV_WINDOW_BITS
 
 static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,
                                           struct ocfs2_alloc_reservation *resv)
@@ -51,8 +52,11 @@ static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,
        struct ocfs2_super *osb = resmap->m_osb;
        unsigned int bits;
 
-       /* 8, 16, 32, 64, 128, 256, 512, 1024 */
-       bits = 4 << osb->osb_resv_level;
+       if (!(resv->r_flags & OCFS2_RESV_FLAG_DIR)) {
+               /* 8, 16, 32, 64, 128, 256, 512, 1024 */
+               bits = 4 << osb->osb_resv_level;
+       } else
+               bits = OCFS2_RESV_DIR_WINDOW_BITS;
 
        return bits;
 }
index 8341cd0ef85555200da200d57b50396469148b31..34bb308375c5ae987d52b93af9d71dae68228cc3 100644 (file)
@@ -42,6 +42,8 @@ struct ocfs2_alloc_reservation {
 #define        OCFS2_RESV_FLAG_INUSE   0x01    /* Set when r_node is part of a btree */
 #define        OCFS2_RESV_FLAG_TMP     0x02    /* Temporary reservation, will be
                                         * destroyed immedately after use */
+#define        OCFS2_RESV_FLAG_DIR     0x04    /* Reservation is for an unindexed
+                                        * directory btree */
 
 struct ocfs2_reservation_map {
        struct rb_root          m_reservations;
@@ -61,7 +63,7 @@ struct ocfs2_reservation_map {
 
 void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv);
 
-#define OCFS2_RESV_TYPES       (OCFS2_RESV_FLAG_TMP)
+#define OCFS2_RESV_TYPES       (OCFS2_RESV_FLAG_TMP|OCFS2_RESV_FLAG_DIR)
 void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv,
                         unsigned int flags);
 
index d4babfba4f049326da4f8384e9bcc7d78273d1c8..f20bcbf64ce007e3dce7d25022e6552bb82c3111 100644 (file)
@@ -130,6 +130,7 @@ void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac)
        }
        brelse(ac->ac_bh);
        ac->ac_bh = NULL;
+       ac->ac_resv = NULL;
 }
 
 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)