mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 21:51:05 +00:00
xfs: handle zero entries case in xfs_iext_rebalance_leaf
And also rename fill to nr_entries to match the rest of the code. Reported-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
3e27c418a7
commit
ae82968ee9
1 changed files with 17 additions and 7 deletions
|
@ -787,13 +787,21 @@ xfs_iext_rebalance_leaf(
|
||||||
struct xfs_iext_cursor *cur,
|
struct xfs_iext_cursor *cur,
|
||||||
struct xfs_iext_leaf *leaf,
|
struct xfs_iext_leaf *leaf,
|
||||||
xfs_fileoff_t offset,
|
xfs_fileoff_t offset,
|
||||||
int fill)
|
int nr_entries)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* If the neighbouring nodes are completely full we might never be able
|
||||||
|
* to merge our node, and will only delete it once the number of
|
||||||
|
* entries hits zero.
|
||||||
|
*/
|
||||||
|
if (nr_entries == 0)
|
||||||
|
goto remove_node;
|
||||||
|
|
||||||
if (leaf->prev) {
|
if (leaf->prev) {
|
||||||
int nr_prev = xfs_iext_leaf_nr_entries(ifp, leaf->prev, 0), i;
|
int nr_prev = xfs_iext_leaf_nr_entries(ifp, leaf->prev, 0), i;
|
||||||
|
|
||||||
if (nr_prev + fill <= RECS_PER_LEAF) {
|
if (nr_prev + nr_entries <= RECS_PER_LEAF) {
|
||||||
for (i = 0; i < fill; i++)
|
for (i = 0; i < nr_entries; i++)
|
||||||
leaf->prev->recs[nr_prev + i] = leaf->recs[i];
|
leaf->prev->recs[nr_prev + i] = leaf->recs[i];
|
||||||
|
|
||||||
if (cur->leaf == leaf) {
|
if (cur->leaf == leaf) {
|
||||||
|
@ -807,18 +815,20 @@ xfs_iext_rebalance_leaf(
|
||||||
if (leaf->next) {
|
if (leaf->next) {
|
||||||
int nr_next = xfs_iext_leaf_nr_entries(ifp, leaf->next, 0), i;
|
int nr_next = xfs_iext_leaf_nr_entries(ifp, leaf->next, 0), i;
|
||||||
|
|
||||||
if (fill + nr_next <= RECS_PER_LEAF) {
|
if (nr_entries + nr_next <= RECS_PER_LEAF) {
|
||||||
/*
|
/*
|
||||||
* Merge the next node into this node so that we don't
|
* Merge the next node into this node so that we don't
|
||||||
* have to do an additional update of the keys in the
|
* have to do an additional update of the keys in the
|
||||||
* higher levels.
|
* higher levels.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nr_next; i++)
|
for (i = 0; i < nr_next; i++) {
|
||||||
leaf->recs[fill + i] = leaf->next->recs[i];
|
leaf->recs[nr_entries + i] =
|
||||||
|
leaf->next->recs[i];
|
||||||
|
}
|
||||||
|
|
||||||
if (cur->leaf == leaf->next) {
|
if (cur->leaf == leaf->next) {
|
||||||
cur->leaf = leaf;
|
cur->leaf = leaf;
|
||||||
cur->pos += fill;
|
cur->pos += nr_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = xfs_iext_leaf_key(leaf->next, 0);
|
offset = xfs_iext_leaf_key(leaf->next, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue