From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 07/20] xfs: rmap btree add more reserved blocks
Date: Wed, 3 Jun 2015 16:04:44 +1000 [thread overview]
Message-ID: <1433311497-10245-8-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1433311497-10245-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
XFS reserves a small amount of space in each AG for the minimum
number of free blocks needed for operation. Adding the rmap btree
increases the number of reserved blocks, but it also increases the
complexity of the calculation as the free inode btree is optional
(like the rmbt).
Rather than calculate the prealloc blocks every time we need to
check it, add a function to calculate it at mount time and store it
in the struct xfs_mount, and convert the XFS_PREALLOC_BLOCKS macro
just to use the xfs-mount variable directly.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/libxfs/xfs_alloc.c | 11 +++++++++++
fs/xfs/libxfs/xfs_alloc.h | 2 ++
fs/xfs/libxfs/xfs_format.h | 9 +--------
fs/xfs/xfs_fsops.c | 6 +++---
fs/xfs/xfs_mount.c | 2 ++
fs/xfs/xfs_mount.h | 1 +
6 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index c7206b5..a683d7a 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -49,6 +49,17 @@ STATIC int xfs_alloc_ag_vextent_size(xfs_alloc_arg_t *);
STATIC int xfs_alloc_ag_vextent_small(xfs_alloc_arg_t *,
xfs_btree_cur_t *, xfs_agblock_t *, xfs_extlen_t *, int *);
+xfs_extlen_t
+xfs_prealloc_blocks(
+ struct xfs_mount *mp)
+{
+ if (xfs_sb_version_hasrmapbt(&mp->m_sb))
+ return XFS_RMAP_BLOCK(mp) + 1;
+ if (xfs_sb_version_hasfinobt(&mp->m_sb))
+ return XFS_FIBT_BLOCK(mp) + 1;
+ return XFS_IBT_BLOCK(mp) + 1;
+}
+
/*
* Lookup the record equal to [bno, len] in the btree given by cur.
*/
diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h
index ca1c816..71379f6 100644
--- a/fs/xfs/libxfs/xfs_alloc.h
+++ b/fs/xfs/libxfs/xfs_alloc.h
@@ -234,4 +234,6 @@ xfs_alloc_get_rec(
int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
+xfs_extlen_t xfs_prealloc_blocks(struct xfs_mount *mp);
+
#endif /* __XFS_ALLOC_H__ */
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index d120af4..e81ffec 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -1288,18 +1288,11 @@ typedef __be32 xfs_inobt_ptr_t;
*/
#define XFS_RMAP_CRC_MAGIC 0x524d4233 /* 'RMB3' */
-/*
- * The first data block of an AG depends on whether the filesystem was formatted
- * with the finobt feature. If so, account for the finobt reserved root btree
- * block.
- */
-#define XFS_PREALLOC_BLOCKS(mp) \
+#define XFS_RMAP_BLOCK(mp) \
(xfs_sb_version_hasfinobt(&((mp)->m_sb)) ? \
XFS_FIBT_BLOCK(mp) + 1 : \
XFS_IBT_BLOCK(mp) + 1)
-
-
/*
* BMAP Btree format definitions
*
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 4bd6463..a564c4c 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -246,7 +246,7 @@ xfs_growfs_data_private(
agf->agf_flfirst = 0;
agf->agf_fllast = cpu_to_be32(XFS_AGFL_SIZE(mp) - 1);
agf->agf_flcount = 0;
- tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
+ tmpsize = agsize - mp->m_ag_prealloc_blocks;
agf->agf_freeblks = cpu_to_be32(tmpsize);
agf->agf_longest = cpu_to_be32(tmpsize);
if (xfs_sb_version_hascrc(&mp->m_sb))
@@ -343,7 +343,7 @@ xfs_growfs_data_private(
agno, 0);
arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1);
- arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
+ arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks);
arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock));
@@ -372,7 +372,7 @@ xfs_growfs_data_private(
agno, 0);
arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1);
- arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
+ arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks);
arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock));
nfree += be32_to_cpu(arec->ar_blockcount);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 461e791..9d6be55 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -239,6 +239,8 @@ xfs_initialize_perag(
if (maxagi)
*maxagi = index;
+
+ mp->m_ag_prealloc_blocks = xfs_prealloc_blocks(mp);
return 0;
out_unwind:
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 7999e91..d9c9834 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -93,6 +93,7 @@ typedef struct xfs_mount {
uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */
uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */
uint m_in_maxlevels; /* max inobt btree levels. */
+ xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */
struct radix_tree_root m_perag_tree; /* per-ag accounting info */
spinlock_t m_perag_lock; /* lock for m_perag_tree */
struct mutex m_growlock; /* growfs mutex */
--
2.0.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-06-03 6:05 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-03 6:04 [RFC PATCH 00/20] xfs: reverse mapping btree support Dave Chinner
2015-06-03 6:04 ` [PATCH 01/20] xfs: xfs_alloc_fix_freelist() can use incore perag structures Dave Chinner
2015-06-15 14:57 ` Brian Foster
2015-06-03 6:04 ` [PATCH 02/20] xfs: factor out free space extent length check Dave Chinner
2015-06-15 14:58 ` Brian Foster
2015-06-03 6:04 ` [PATCH 03/20] xfs: sanitise error handling in xfs_alloc_fix_freelist Dave Chinner
2015-06-15 14:58 ` Brian Foster
2015-06-15 21:51 ` Dave Chinner
2015-06-16 11:27 ` Brian Foster
2015-06-22 0:10 ` Dave Chinner
2015-06-03 6:04 ` [PATCH 04/20] xfs: clean up XFS_MIN_FREELIST macros Dave Chinner
2015-06-15 14:58 ` Brian Foster
2015-06-03 6:04 ` [PATCH 05/20] xfs: introduce rmap btree definitions Dave Chinner
2015-06-03 6:30 ` Darrick J. Wong
2015-06-03 6:34 ` Darrick J. Wong
2015-06-03 6:04 ` [PATCH 06/20] xfs: add rmap btree stats infrastructure Dave Chinner
2015-06-03 6:04 ` Dave Chinner [this message]
2015-06-03 6:04 ` [PATCH 08/20] xfs: add owner field to extent allocation and freeing Dave Chinner
2015-06-24 19:09 ` Brian Foster
2015-06-24 21:13 ` Dave Chinner
2015-06-25 13:03 ` Brian Foster
2015-06-03 6:04 ` [PATCH 09/20] xfs: introduce rmap extent operation stubs Dave Chinner
2015-06-03 6:04 ` [PATCH 10/20] xfs: define the on-disk rmap btree format Dave Chinner
2015-06-03 6:04 ` [PATCH 11/20] xfs: add rmap btree growfs support Dave Chinner
2015-06-03 6:04 ` [PATCH 12/20] xfs: rmap btree transaction reservations Dave Chinner
2015-06-03 6:04 ` [PATCH 13/20] xfs: rmap btree requires more reserved free space Dave Chinner
2015-06-25 16:41 ` Brian Foster
2015-07-10 0:37 ` Dave Chinner
2015-06-03 6:04 ` [PATCH 14/20] xfs: add rmap btree operations Dave Chinner
2015-06-03 6:04 ` [PATCH 15/20] xfs: add an extent to the rmap btree Dave Chinner
2015-06-25 16:41 ` Brian Foster
2015-07-10 0:39 ` Dave Chinner
2015-06-03 6:04 ` [PATCH 16/20] xfs: remove an extent from " Dave Chinner
2015-06-03 6:04 ` [PATCH 17/20] xfs: add rmap btree geometry feature flag Dave Chinner
2015-06-03 6:04 ` [PATCH 18/20] xfs: add rmap btree block detection to log recovery Dave Chinner
2015-06-03 6:04 ` [PATCH 19/20] xfs: disable XFS_IOC_SWAPEXT when rmap btree is enabled Dave Chinner
2015-06-03 6:04 ` [PATCH 20/20] xfs: enable the rmap btree functionality Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433311497-10245-8-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox