diff options
author | Sunil Mushran <sunil.mushran@oracle.com> | 2007-12-20 17:58:11 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2008-01-25 18:05:43 -0500 |
commit | 2fbe8d1ebe004425b4f7b8bba345623d2280be82 (patch) | |
tree | 7620954c7a364c41306a3becc0046dd1e235158f /fs/ocfs2/localalloc.c | |
parent | d147b3d630edef1d34de6ea819787a1ac1b8603b (diff) |
ocfs2: Local alloc window size changeable via mount option
Local alloc is a performance optimization in ocfs2 in which a node
takes a window of bits from the global bitmap and then uses that for
all small local allocations. This window size is fixed to 8MB currently.
This patch allows users to specify the window size in MB including
disabling it by passing in 0. If the number specified is too large,
the fs will use the default value of 8MB.
mount -o localalloc=X /dev/sdX /mntpoint
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/localalloc.c')
-rw-r--r-- | fs/ocfs2/localalloc.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 0de0792fce7f..add1ffdc5c6c 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -75,18 +75,12 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, | |||
75 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | 75 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, |
76 | struct inode *local_alloc_inode); | 76 | struct inode *local_alloc_inode); |
77 | 77 | ||
78 | /* | ||
79 | * Determine how large our local alloc window should be, in bits. | ||
80 | * | ||
81 | * These values (and the behavior in ocfs2_alloc_should_use_local) have | ||
82 | * been chosen so that most allocations, including new block groups go | ||
83 | * through local alloc. | ||
84 | */ | ||
85 | static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) | 78 | static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) |
86 | { | 79 | { |
87 | BUG_ON(osb->s_clustersize_bits < 12); | 80 | BUG_ON(osb->s_clustersize_bits > 20); |
88 | 81 | ||
89 | return 2048 >> (osb->s_clustersize_bits - 12); | 82 | /* Size local alloc windows by the megabyte */ |
83 | return osb->local_alloc_size << (20 - osb->s_clustersize_bits); | ||
90 | } | 84 | } |
91 | 85 | ||
92 | /* | 86 | /* |
@@ -96,18 +90,23 @@ static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) | |||
96 | int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) | 90 | int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) |
97 | { | 91 | { |
98 | int la_bits = ocfs2_local_alloc_window_bits(osb); | 92 | int la_bits = ocfs2_local_alloc_window_bits(osb); |
93 | int ret = 0; | ||
99 | 94 | ||
100 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) | 95 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) |
101 | return 0; | 96 | goto bail; |
102 | 97 | ||
103 | /* la_bits should be at least twice the size (in clusters) of | 98 | /* la_bits should be at least twice the size (in clusters) of |
104 | * a new block group. We want to be sure block group | 99 | * a new block group. We want to be sure block group |
105 | * allocations go through the local alloc, so allow an | 100 | * allocations go through the local alloc, so allow an |
106 | * allocation to take up to half the bitmap. */ | 101 | * allocation to take up to half the bitmap. */ |
107 | if (bits > (la_bits / 2)) | 102 | if (bits > (la_bits / 2)) |
108 | return 0; | 103 | goto bail; |
109 | 104 | ||
110 | return 1; | 105 | ret = 1; |
106 | bail: | ||
107 | mlog(0, "state=%d, bits=%llu, la_bits=%d, ret=%d\n", | ||
108 | osb->local_alloc_state, (unsigned long long)bits, la_bits, ret); | ||
109 | return ret; | ||
111 | } | 110 | } |
112 | 111 | ||
113 | int ocfs2_load_local_alloc(struct ocfs2_super *osb) | 112 | int ocfs2_load_local_alloc(struct ocfs2_super *osb) |
@@ -121,6 +120,19 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) | |||
121 | 120 | ||
122 | mlog_entry_void(); | 121 | mlog_entry_void(); |
123 | 122 | ||
123 | if (ocfs2_mount_local(osb)) | ||
124 | goto bail; | ||
125 | |||
126 | if (osb->local_alloc_size == 0) | ||
127 | goto bail; | ||
128 | |||
129 | if (ocfs2_local_alloc_window_bits(osb) >= osb->bitmap_cpg) { | ||
130 | mlog(ML_NOTICE, "Requested local alloc window %d is larger " | ||
131 | "than max possible %u. Using defaults.\n", | ||
132 | ocfs2_local_alloc_window_bits(osb), (osb->bitmap_cpg - 1)); | ||
133 | osb->local_alloc_size = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; | ||
134 | } | ||
135 | |||
124 | /* read the alloc off disk */ | 136 | /* read the alloc off disk */ |
125 | inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, | 137 | inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, |
126 | osb->slot_num); | 138 | osb->slot_num); |
@@ -181,6 +193,9 @@ bail: | |||
181 | if (inode) | 193 | if (inode) |
182 | iput(inode); | 194 | iput(inode); |
183 | 195 | ||
196 | mlog(0, "Local alloc window bits = %d\n", | ||
197 | ocfs2_local_alloc_window_bits(osb)); | ||
198 | |||
184 | mlog_exit(status); | 199 | mlog_exit(status); |
185 | return status; | 200 | return status; |
186 | } | 201 | } |
@@ -521,6 +536,9 @@ bail: | |||
521 | iput(local_alloc_inode); | 536 | iput(local_alloc_inode); |
522 | } | 537 | } |
523 | 538 | ||
539 | mlog(0, "bits=%d, slot=%d, ret=%d\n", bits_wanted, osb->slot_num, | ||
540 | status); | ||
541 | |||
524 | mlog_exit(status); | 542 | mlog_exit(status); |
525 | return status; | 543 | return status; |
526 | } | 544 | } |