Changeset 1663:ccf5a393facd
- Timestamp:
- 06/16/08 12:20:14 (2 months ago)
- Author:
- klai@…
- Children:
- 1664:c3f9598e57b5, 1670:b68f577681e2
- Branch:
- default
- Message:
-
Switch off creation of sparse file systems because they are very slow with tap:aio
- Location:
- src/Tycoon/Virtualization
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r1637
|
r1663
|
|
| 222 | 222 | get_dir_size = staticmethod(deferredGenerator(get_dir_size)) |
| 223 | 223 | |
| | 224 | def grow_sparse_file_system(file_system, new_size, old_size): |
| | 225 | # Write a single byte at the last seek position. |
| | 226 | d = OSUtil.do( |
| | 227 | '/bin/dd', 'if=/dev/zero', 'of=%s' % (file_system,), |
| | 228 | 'seek=%d' % (new_size - 1,), 'bs=1', 'count=1') |
| | 229 | return d |
| | 230 | grow_sparse_file_system = staticmethod(grow_sparse_file_system) |
| | 231 | |
| | 232 | def grow_dense_file_system(file_system, new_size, old_size): |
| | 233 | m = (new_size - old_size) / 1048576 |
| | 234 | seek = old_size / 1048576 |
| | 235 | d = OSUtil.do( |
| | 236 | '/bin/dd', 'if=/dev/zero', 'of=%s' % (file_system,), |
| | 237 | 'seek=%d' % (seek,), 'bs=1M', 'count=%d' % (m,)) |
| | 238 | return d |
| | 239 | grow_dense_file_system = staticmethod(grow_dense_file_system) |
| | 240 | |
| 224 | 241 | def resize_file_system(file_system, size): |
| 225 | 242 | """Resize a file system file. |
| … |
… |
|
| 227 | 244 | old_size = os.stat(file_system).st_size |
| 228 | 245 | |
| 229 | | # Round down to nearest number of KB |
| 230 | | k = size / 1024 |
| 231 | | real_size = k * 1024 |
| | 246 | # Round down to nearest number of MB |
| | 247 | m = size / 1048576 |
| | 248 | real_size = m * 1048576 |
| 232 | 249 | if real_size > old_size: |
| 233 | | d = OSUtil.do( |
| 234 | | '/bin/dd', 'if=/dev/zero', 'of=%s' % (file_system,), |
| 235 | | 'seek=%d' % (real_size - 1,), 'bs=1', 'count=1') |
| | 250 | # Sparse file systems are faster to create, but slower to use |
| | 251 | # than dense ones. |
| | 252 | sparse = False |
| | 253 | if sparse: |
| | 254 | d = OSUtil.grow_sparse_file_system( |
| | 255 | file_system, real_size, old_size) |
| | 256 | else: |
| | 257 | d = OSUtil.grow_dense_file_system( |
| | 258 | file_system, real_size, old_size) |
| 236 | 259 | yield d |
| 237 | 260 | d = OSUtil.do('/sbin/e2fsck','-f', '-y', file_system) |
| … |
… |
|
| 242 | 265 | d = OSUtil.do('/sbin/e2fsck','-f', '-y', file_system) |
| 243 | 266 | yield d |
| 244 | | d = OSUtil.do('/sbin/resize2fs', file_system, "%dK" % (k,)) |
| | 267 | d = OSUtil.do('/sbin/resize2fs', file_system, "%dM" % (m,)) |
| 245 | 268 | yield d |
| 246 | 269 | f = file(file_system, "a+") |
-
|
r1661
|
r1663
|
|
| 61 | 61 | |
| 62 | 62 | def set_last_share(self, account_name): |
| 63 | | self.set_share(*((account_name,) + self.last_share[account_name])) |
| | 63 | last_share = self.last_share.get(account_name) |
| | 64 | if last_share != None: |
| | 65 | self.set_share(*((account_name,) + last_share)) |
| 64 | 66 | |
| 65 | 67 | def clear_shares(self): |