localalloc.c (e63aecb651ba73dffc62f9608ee1b7ae2a0ffd4b) | localalloc.c (2fbe8d1ebe004425b4f7b8bba345623d2280be82) |
---|---|
1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * localalloc.c 5 * 6 * Node local data allocation 7 * 8 * Copyright (C) 2002, 2004 Oracle. All rights reserved. --- 61 unchanged lines hidden (view full) --- 70 71static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, 72 handle_t *handle, 73 struct ocfs2_alloc_context *ac); 74 75static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, 76 struct inode *local_alloc_inode); 77 | 1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * localalloc.c 5 * 6 * Node local data allocation 7 * 8 * Copyright (C) 2002, 2004 Oracle. All rights reserved. --- 61 unchanged lines hidden (view full) --- 70 71static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, 72 handle_t *handle, 73 struct ocfs2_alloc_context *ac); 74 75static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, 76 struct inode *local_alloc_inode); 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 */ | |
85static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) 86{ | 78static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) 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} 91 92/* 93 * Tell us whether a given allocation should use the local alloc 94 * file. Otherwise, it has to go to the main bitmap. 95 */ 96int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) 97{ 98 int la_bits = ocfs2_local_alloc_window_bits(osb); | 84} 85 86/* 87 * Tell us whether a given allocation should use the local alloc 88 * file. Otherwise, it has to go to the main bitmap. 89 */ 90int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) 91{ 92 int la_bits = ocfs2_local_alloc_window_bits(osb); |
93 int ret = 0; |
|
99 100 if (osb->local_alloc_state != OCFS2_LA_ENABLED) | 94 95 if (osb->local_alloc_state != OCFS2_LA_ENABLED) |
101 return 0; | 96 goto bail; |
102 103 /* la_bits should be at least twice the size (in clusters) of 104 * a new block group. We want to be sure block group 105 * allocations go through the local alloc, so allow an 106 * allocation to take up to half the bitmap. */ 107 if (bits > (la_bits / 2)) | 97 98 /* la_bits should be at least twice the size (in clusters) of 99 * a new block group. We want to be sure block group 100 * allocations go through the local alloc, so allow an 101 * allocation to take up to half the bitmap. */ 102 if (bits > (la_bits / 2)) |
108 return 0; | 103 goto bail; |
109 | 104 |
110 return 1; | 105 ret = 1; 106bail: 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} 112 113int ocfs2_load_local_alloc(struct ocfs2_super *osb) 114{ 115 int status = 0; 116 struct ocfs2_dinode *alloc = NULL; 117 struct buffer_head *alloc_bh = NULL; 118 u32 num_used; 119 struct inode *inode = NULL; 120 struct ocfs2_local_alloc *la; 121 122 mlog_entry_void(); 123 | 110} 111 112int ocfs2_load_local_alloc(struct ocfs2_super *osb) 113{ 114 int status = 0; 115 struct ocfs2_dinode *alloc = NULL; 116 struct buffer_head *alloc_bh = NULL; 117 u32 num_used; 118 struct inode *inode = NULL; 119 struct ocfs2_local_alloc *la; 120 121 mlog_entry_void(); 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 */ 125 inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, 126 osb->slot_num); 127 if (!inode) { 128 status = -EINVAL; 129 mlog_errno(status); 130 goto bail; 131 } --- 44 unchanged lines hidden (view full) --- 176 177bail: 178 if (status < 0) 179 if (alloc_bh) 180 brelse(alloc_bh); 181 if (inode) 182 iput(inode); 183 | 136 /* read the alloc off disk */ 137 inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, 138 osb->slot_num); 139 if (!inode) { 140 status = -EINVAL; 141 mlog_errno(status); 142 goto bail; 143 } --- 44 unchanged lines hidden (view full) --- 188 189bail: 190 if (status < 0) 191 if (alloc_bh) 192 brelse(alloc_bh); 193 if (inode) 194 iput(inode); 195 |
196 mlog(0, "Local alloc window bits = %d\n", 197 ocfs2_local_alloc_window_bits(osb)); 198 |
|
184 mlog_exit(status); 185 return status; 186} 187 188/* 189 * return any unused bits to the bitmap and write out a clean 190 * local_alloc. 191 * --- 324 unchanged lines hidden (view full) --- 516 ac->ac_bh = osb->local_alloc_bh; 517 status = 0; 518bail: 519 if (status < 0 && local_alloc_inode) { 520 mutex_unlock(&local_alloc_inode->i_mutex); 521 iput(local_alloc_inode); 522 } 523 | 199 mlog_exit(status); 200 return status; 201} 202 203/* 204 * return any unused bits to the bitmap and write out a clean 205 * local_alloc. 206 * --- 324 unchanged lines hidden (view full) --- 531 ac->ac_bh = osb->local_alloc_bh; 532 status = 0; 533bail: 534 if (status < 0 && local_alloc_inode) { 535 mutex_unlock(&local_alloc_inode->i_mutex); 536 iput(local_alloc_inode); 537 } 538 |
539 mlog(0, "bits=%d, slot=%d, ret=%d\n", bits_wanted, osb->slot_num, 540 status); 541 |
|
524 mlog_exit(status); 525 return status; 526} 527 528int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, 529 handle_t *handle, 530 struct ocfs2_alloc_context *ac, 531 u32 bits_wanted, --- 445 unchanged lines hidden --- | 542 mlog_exit(status); 543 return status; 544} 545 546int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, 547 handle_t *handle, 548 struct ocfs2_alloc_context *ac, 549 u32 bits_wanted, --- 445 unchanged lines hidden --- |