From: Eric Sandeen <sandeen@sandeen.net>
To: xfs-oss <xfs@oss.sgi.com>
Subject: Limits on agi->agi_level (and other btree depths?)
Date: Wed, 12 Feb 2014 17:54:19 -0600 [thread overview]
Message-ID: <52FC09AB.3030209@sandeen.net> (raw)
If agi->agi_level exceeds XFS_BTREE_MAXLEVELS (8), bad things happen. For example in xfs_inobt_init_cursor() we read it directly off disk into a btree cursor:
xfs_inobt_init_cursor()
cur->bc_nlevels = be32_to_cpu(agi->agi_level);
and then when it's time to tear it down we'll index into bc_bufs[] buy whatever it said:
xfs_btree_del_cursor()
for (i = 0; i < cur->bc_nlevels; i++) {
if (cur->bc_bufs[i])
xfs_trans_brelse(cur->bc_tp, cur->bc_bufs[i]);
but bc_bufs[] in the xfs_btree_cur is of fixed size:
struct xfs_buf *bc_bufs[XFS_BTREE_MAXLEVELS]; /* buf ptr per level */
where
#define XFS_BTREE_MAXLEVELS 8 /* max of all btrees */
(which means this limits any btree depth, not just agi, right...)
...
So I ran across this on an intentionally corrupted image, but I don't know what stops us from going past XFS_BTREE_MAXLEVELS in normal operations (unless we just hit filesystem limits before then?)
i.e. xfs_btree_new_root() does:
/* Set the root in the holding structure increasing the level by 1. */
cur->bc_ops->set_root(cur, &lptr, 1);
and ->set_root / xfs_inobt_set_root() will happily increase agi_level; I don't see anything limiting it to XFS_BTREE_MAXLEVELS.
I guess XFS_BTREE_MAXLEVELS is just an arbitrary in-memory limit, not a limit of the underlying disk structures, but as it stands, we should be sure that we don't exceed it, right?
I was going to put that limit into xfs_agi_verify, but realized that I wasn't sure if we could actually exceed that depth in normal operations.
(cue dchinner working out that 9 levels is 59 bazillion jillion items, and will never be hit?)
Thanks,
-Eric
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2014-02-12 23:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 23:54 Eric Sandeen [this message]
2014-02-13 1:01 ` Limits on agi->agi_level (and other btree depths?) Shaun Gosse
2014-02-13 1:03 ` Dave Chinner
2014-02-13 1:16 ` Shaun Gosse
2014-02-13 1:53 ` Eric Sandeen
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=52FC09AB.3030209@sandeen.net \
--to=sandeen@sandeen.net \
--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