diff options
author | David Chinner <dgc@sgi.com> | 2007-05-24 01:26:31 -0400 |
---|---|---|
committer | Tim Shimmin <tes@chook.melbourne.sgi.com> | 2007-07-14 01:28:50 -0400 |
commit | 92821e2ba4ae26887223326fb0b95cdab963b768 (patch) | |
tree | a40a2ef10e5b0791df3e522f3139193d39bf2454 /fs/xfs/xfs_mount.h | |
parent | 3260f78ad6d5b788e78ea709d377f58e569bee41 (diff) |
[XFS] Lazy Superblock Counters
When we have a couple of hundred transactions on the fly at once, they all
typically modify the on disk superblock in some way.
create/unclink/mkdir/rmdir modify inode counts, allocation/freeing modify
free block counts.
When these counts are modified in a transaction, they must eventually lock
the superblock buffer and apply the mods. The buffer then remains locked
until the transaction is committed into the incore log buffer. The result
of this is that with enough transactions on the fly the incore superblock
buffer becomes a bottleneck.
The result of contention on the incore superblock buffer is that
transaction rates fall - the more pressure that is put on the superblock
buffer, the slower things go.
The key to removing the contention is to not require the superblock fields
in question to be locked. We do that by not marking the superblock dirty
in the transaction. IOWs, we modify the incore superblock but do not
modify the cached superblock buffer. In short, we do not log superblock
modifications to critical fields in the superblock on every transaction.
In fact we only do it just before we write the superblock to disk every
sync period or just before unmount.
This creates an interesting problem - if we don't log or write out the
fields in every transaction, then how do the values get recovered after a
crash? the answer is simple - we keep enough duplicate, logged information
in other structures that we can reconstruct the correct count after log
recovery has been performed.
It is the AGF and AGI structures that contain the duplicate information;
after recovery, we walk every AGI and AGF and sum their individual
counters to get the correct value, and we do a transaction into the log to
correct them. An optimisation of this is that if we have a clean unmount
record, we know the value in the superblock is correct, so we can avoid
the summation walk under normal conditions and so mount/recovery times do
not change under normal operation.
One wrinkle that was discovered during development was that the blocks
used in the freespace btrees are never accounted for in the AGF counters.
This was once a valid optimisation to make; when the filesystem is full,
the free space btrees are empty and consume no space. Hence when it
matters, the "accounting" is correct. But that means the when we do the
AGF summations, we would not have a correct count and xfs_check would
complain. Hence a new counter was added to track the number of blocks used
by the free space btrees. This is an *on-disk format change*.
As a result of this, lazy superblock counters are a mkfs option and at the
moment on linux there is no way to convert an old filesystem. This is
possible - xfs_db can be used to twiddle the right bits and then
xfs_repair will do the format conversion for you. Similarly, you can
convert backwards as well. At some point we'll add functionality to
xfs_admin to do the bit twiddling easily....
SGI-PV: 964999
SGI-Modid: xfs-linux-melb:xfs-kern:28652a
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_mount.h')
-rw-r--r-- | fs/xfs/xfs_mount.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 871a5bfd8617..0bca2d422719 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -429,12 +429,12 @@ typedef struct xfs_mount { | |||
429 | /* | 429 | /* |
430 | * Flags for m_flags. | 430 | * Flags for m_flags. |
431 | */ | 431 | */ |
432 | #define XFS_MOUNT_WSYNC (1ULL << 0) /* for nfs - all metadata ops | 432 | #define XFS_MOUNT_WSYNC (1ULL << 0) /* for nfs - all metadata ops |
433 | must be synchronous except | 433 | must be synchronous except |
434 | for space allocations */ | 434 | for space allocations */ |
435 | #define XFS_MOUNT_INO64 (1ULL << 1) | 435 | #define XFS_MOUNT_INO64 (1ULL << 1) |
436 | /* (1ULL << 2) -- currently unused */ | 436 | /* (1ULL << 2) -- currently unused */ |
437 | /* (1ULL << 3) -- currently unused */ | 437 | #define XFS_MOUNT_WAS_CLEAN (1ULL << 3) |
438 | #define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem | 438 | #define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem |
439 | operations, typically for | 439 | operations, typically for |
440 | disk errors in metadata */ | 440 | disk errors in metadata */ |
@@ -511,6 +511,8 @@ xfs_preferred_iosize(xfs_mount_t *mp) | |||
511 | 511 | ||
512 | #define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset) | 512 | #define XFS_MAXIOFFSET(mp) ((mp)->m_maxioffset) |
513 | 513 | ||
514 | #define XFS_LAST_UNMOUNT_WAS_CLEAN(mp) \ | ||
515 | ((mp)->m_flags & XFS_MOUNT_WAS_CLEAN) | ||
514 | #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) | 516 | #define XFS_FORCED_SHUTDOWN(mp) ((mp)->m_flags & XFS_MOUNT_FS_SHUTDOWN) |
515 | #define xfs_force_shutdown(m,f) \ | 517 | #define xfs_force_shutdown(m,f) \ |
516 | bhv_vfs_force_shutdown((XFS_MTOVFS(m)), f, __FILE__, __LINE__) | 518 | bhv_vfs_force_shutdown((XFS_MTOVFS(m)), f, __FILE__, __LINE__) |
@@ -602,6 +604,7 @@ typedef struct xfs_mod_sb { | |||
602 | 604 | ||
603 | extern xfs_mount_t *xfs_mount_init(void); | 605 | extern xfs_mount_t *xfs_mount_init(void); |
604 | extern void xfs_mod_sb(xfs_trans_t *, __int64_t); | 606 | extern void xfs_mod_sb(xfs_trans_t *, __int64_t); |
607 | extern int xfs_log_sbcount(xfs_mount_t *, uint); | ||
605 | extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); | 608 | extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv); |
606 | extern int xfs_mountfs(struct bhv_vfs *, xfs_mount_t *mp, int); | 609 | extern int xfs_mountfs(struct bhv_vfs *, xfs_mount_t *mp, int); |
607 | extern void xfs_mountfs_check_barriers(xfs_mount_t *mp); | 610 | extern void xfs_mountfs_check_barriers(xfs_mount_t *mp); |
@@ -618,6 +621,7 @@ extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *, | |||
618 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); | 621 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); |
619 | extern int xfs_readsb(xfs_mount_t *, int); | 622 | extern int xfs_readsb(xfs_mount_t *, int); |
620 | extern void xfs_freesb(xfs_mount_t *); | 623 | extern void xfs_freesb(xfs_mount_t *); |
624 | extern int xfs_fs_writable(xfs_mount_t *); | ||
621 | extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); | 625 | extern void xfs_do_force_shutdown(bhv_desc_t *, int, char *, int); |
622 | extern int xfs_syncsub(xfs_mount_t *, int, int *); | 626 | extern int xfs_syncsub(xfs_mount_t *, int, int *); |
623 | extern int xfs_sync_inodes(xfs_mount_t *, int, int *); | 627 | extern int xfs_sync_inodes(xfs_mount_t *, int, int *); |