summaryrefslogtreecommitdiffstats
path: root/src/H5HFsection.c
blob: 7fe557bee4203622238d907604b30d83fdb95660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html.  If you do not have     *
 * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* Programmer:  Quincey Koziol <koziol@ncsa.uiuc.edu>
 *              Monday, May  1, 2006
 *
 * Purpose:	Free space section routines for fractal heaps.
 *
 */

/****************/
/* Module Setup */
/****************/

#define H5HF_PACKAGE		/*suppress error about including H5HFpkg  */

/***********/
/* Headers */
/***********/
#include "H5private.h"		/* Generic Functions			*/
#include "H5Eprivate.h"		/* Error handling		  	*/
#include "H5HFpkg.h"		/* Fractal heaps			*/

/****************/
/* Local Macros */
/****************/


/******************/
/* Local Typedefs */
/******************/


/********************/
/* Package Typedefs */
/********************/


/********************/
/* Local Prototypes */
/********************/

/* Shared routines */
static H5HF_free_section_t *H5HF_sect_node_new(unsigned sect_type,
    haddr_t sect_addr, hsize_t sect_size, H5FS_section_state_t state);
static herr_t H5HF_sect_node_free(H5HF_free_section_t *sect,
    H5HF_indirect_t *parent);
static herr_t H5HF_sect_revive(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect);

/* 'single' section callbacks */
static H5FS_section_info_t *H5HF_sect_single_deserialize(const uint8_t *buf,
    haddr_t sect_addr, hsize_t sect_size);
static htri_t H5HF_sect_single_can_merge(H5FS_section_info_t *sect1,
    H5FS_section_info_t *sect2, void *udata);
static herr_t H5HF_sect_single_merge(H5FS_section_info_t *sect1,
    H5FS_section_info_t *sect2, void *udata);
static htri_t H5HF_sect_single_can_shrink(H5FS_section_info_t *sect,
    void *udata);
static herr_t H5HF_sect_single_free(H5FS_section_info_t *sect);

/* 'range' section routines */
static herr_t H5HF_sect_range_from_single(H5HF_hdr_t *hdr,
    H5HF_free_section_t *sect, H5HF_direct_t *dblock);

/* 'range' section callbacks */
static herr_t H5HF_sect_range_init_cls(H5FS_section_class_t *cls, const void *udata);
static herr_t H5HF_sect_range_serialize(const H5FS_section_info_t *sect, uint8_t *buf);
static H5FS_section_info_t *H5HF_sect_range_deserialize(const uint8_t *buf,
    haddr_t sect_addr, hsize_t sect_size);
static htri_t H5HF_sect_range_can_merge(H5FS_section_info_t *sect1,
    H5FS_section_info_t *sect2, void *udata);
static herr_t H5HF_sect_range_merge(H5FS_section_info_t *sect1,
    H5FS_section_info_t *sect2, void *udata);
static htri_t H5HF_sect_range_can_shrink(H5FS_section_info_t *sect,
    void *udata);
static herr_t H5HF_sect_range_shrink(H5FS_section_info_t **sect,
    void *udata);
static herr_t H5HF_sect_range_free(H5FS_section_info_t *sect);
static herr_t H5HF_sect_range_debug(const H5FS_section_info_t *sect,
    FILE *stream, int indent, int fwidth);

/* 'indirect' section callbacks */
static herr_t H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, const void *udata);
static herr_t H5HF_sect_indirect_serialize(const H5FS_section_info_t *sect, uint8_t *buf);
static H5FS_section_info_t *H5HF_sect_indirect_deserialize(const uint8_t *buf,
    haddr_t sect_addr, hsize_t sect_size);
static herr_t H5HF_sect_indirect_free(H5FS_section_info_t *sect);
static herr_t H5HF_sect_indirect_debug(const H5FS_section_info_t *sect,
    FILE *stream, int indent, int fwidth);


/*********************/
/* Package Variables */
/*********************/

/* Class info for "single" free space sections */
/* (No callbacks necessary) */
H5FS_section_class_t H5HF_FSPACE_SECT_CLS_SINGLE[1] = {{
    H5HF_FSPACE_SECT_SINGLE,		/* Section type                 */
    0,					/* Extra serialized size        */
    NULL,				/* Initialize section class     */
    NULL,				/* Serialize section            */
    H5HF_sect_single_deserialize,	/* Deserialize section          */
    H5HF_sect_single_can_merge,		/* Can sections merge?          */
    H5HF_sect_single_merge,		/* Merge sections               */
    H5HF_sect_single_can_shrink,	/* Can section shrink container?*/
    NULL,				/* Shrink container w/section   */
    H5HF_sect_single_free,		/* Free section                 */
    NULL,				/* Dump debugging for section   */
}};

/* Class info for "range" free space sections */
H5FS_section_class_t H5HF_FSPACE_SECT_CLS_RANGE[1] = {{
    H5HF_FSPACE_SECT_RANGE,		/* Section type                 */
    0,					/* Extra serialized size        */
    H5HF_sect_range_init_cls,		/* Initialize section class     */
    H5HF_sect_range_serialize,		/* Serialize section            */
    H5HF_sect_range_deserialize,	/* Deserialize section          */
    H5HF_sect_range_can_merge,		/* Can sections merge?          */
    H5HF_sect_range_merge,		/* Merge sections               */
    H5HF_sect_range_can_shrink,		/* Can section shrink container?*/
    H5HF_sect_range_shrink,		/* Shrink container w/section   */
    H5HF_sect_range_free,		/* Free section                 */
    H5HF_sect_range_debug,		/* Dump debugging for section   */
}};

/* Class info for "indirect" free space sections */
H5FS_section_class_t H5HF_FSPACE_SECT_CLS_INDIRECT[1] = {{
    H5HF_FSPACE_SECT_INDIRECT,		/* Section type                 */
    0,					/* Extra serialized size        */
    H5HF_sect_indirect_init_cls,	/* Initialize section class     */
    H5HF_sect_indirect_serialize,	/* Serialize section            */
    H5HF_sect_indirect_deserialize,	/* Deserialize section          */
    NULL,				/* Can sections merge?          */
    NULL,				/* Merge sections               */
    NULL,				/* Can section shrink container?*/
    NULL,				/* Shrink container w/section   */
    H5HF_sect_indirect_free,		/* Free section                 */
    H5HF_sect_indirect_debug,		/* Dump debugging for section   */
}};

/* Declare a free list to manage the H5HF_free_section_t struct */
H5FL_DEFINE(H5HF_free_section_t);


/*****************************/
/* Library Private Variables */
/*****************************/


/*******************/
/* Local Variables */
/*******************/



/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_node_new
 *
 * Purpose:	Allocate a free space section node of a particular type
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Saturday, May 13, 2006
 *
 *-------------------------------------------------------------------------
 */
static H5HF_free_section_t *
H5HF_sect_node_new(unsigned sect_type, haddr_t sect_addr, hsize_t sect_size,
    H5FS_section_state_t sect_state)
{
    H5HF_free_section_t *new_sect;      /* New section */
    H5HF_free_section_t *ret_value;     /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_node_new)

    /* Check arguments. */
    HDassert(H5F_addr_defined(sect_addr));
    HDassert(sect_size);

    /* Create free list section node */
    if(NULL == (new_sect = H5FL_MALLOC(H5HF_free_section_t)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for direct block free list section")

    /* Set the information passed in */
    new_sect->sect_info.addr = sect_addr;
    new_sect->sect_info.size = sect_size;

    /* Set the section's class & state */
    new_sect->sect_info.type = sect_type;
    new_sect->sect_info.state = sect_state;

    /* Set return value */
    ret_value = new_sect;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_node_new() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_node_free
 *
 * Purpose:	Free a section node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, May 17, 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_node_free(H5HF_free_section_t *sect, H5HF_indirect_t *parent)
{
    herr_t ret_value = SUCCEED;               /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_node_free)

    HDassert(sect);

    /* Release indirect block, if there was one */
    if(parent)
        if(H5HF_iblock_decr(parent) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on parent indirect block")

    /* Release the section */
    H5FL_FREE(H5HF_free_section_t, sect);

done:
    FUNC_LEAVE_NOAPI(ret_value)
}   /* H5HF_sect_node_free() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_revive
 *
 * Purpose:	Revive a section node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, June  5, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_revive(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect)
{
    herr_t ret_value = SUCCEED;               /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_revive)

    /* Sanity check */
    HDassert(hdr);
    HDassert(sect);

    /* Call appropriate 'revive' routine */
    switch(sect->sect_info.type) {
        case H5HF_FSPACE_SECT_INDIRECT:
            if(H5HF_sect_indirect_revive(hdr, dxpl_id, sect) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive range free section")
            break;

        case H5HF_FSPACE_SECT_RANGE:
            if(H5HF_sect_range_revive(hdr, dxpl_id, sect) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive range free section")
            break;

        case H5HF_FSPACE_SECT_SINGLE:
            if(H5HF_sect_single_revive(hdr, dxpl_id, sect) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section")
            break;

        default:
            HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "unknown section type")
    } /* end switch */

done:
    FUNC_LEAVE_NOAPI(ret_value)
}   /* H5HF_sect_revive() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_new
 *
 * Purpose:	Create a new 'single' section and return it to the caller
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 30 2006
 *
 *-------------------------------------------------------------------------
 */
H5HF_free_section_t *
H5HF_sect_single_new(hsize_t sect_off, size_t sect_size,
    H5HF_indirect_t *parent, unsigned par_entry,
    haddr_t dblock_addr, size_t dblock_size)
{
    H5HF_free_section_t *sect = NULL;   /* 'Single' free space section to add */
    hbool_t par_incr = FALSE;           /* Indicate that parent iblock has been incremented */
    H5HF_free_section_t *ret_value;     /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_new)

    /*
     * Check arguments.
     */
    HDassert(sect_size);

    /* Create free space section node */
    if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_off, (hsize_t)sect_size, H5FS_SECT_LIVE)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for single section")

    /* Set the 'single' specific fields */
    sect->u.single.parent = parent;
    if(sect->u.single.parent) {
        if(H5HF_iblock_incr(sect->u.single.parent) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, NULL, "can't increment reference count on shared indirect block")
        par_incr = TRUE;
    } /* end if */
    sect->u.single.par_entry = par_entry;
    sect->u.single.dblock_addr = dblock_addr;
    sect->u.single.dblock_size = dblock_size;

    /* Set return value */
    ret_value = sect;

done:
    if(!ret_value && sect) {
        /* Check if we should decrement parent ref. count */
        if(par_incr) {
            HDassert(sect->u.single.parent);
            if(H5HF_iblock_decr(sect->u.single.parent) < 0)
                HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, NULL, "can't decrement reference count on parent indirect block")
        } /* end if */

        /* Release the section */
        H5FL_FREE(H5HF_free_section_t, sect);
    } /* end if */

    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_single_new() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_revive
 *
 * Purpose:	Update the memory information for a 'single' free section
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May  8 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_single_revive(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect)
{
    H5HF_indirect_t *sec_iblock;        /* Pointer to section indirect block */
    unsigned sec_entry;                 /* Entry within section indirect block */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_revive)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED);

    /* Check for root direct block */
    if(hdr->man_dtable.curr_root_rows == 0) {
        /* Set the information for the section */
        sect->u.single.parent = NULL;
        sect->u.single.par_entry = 0;

        /* Set direct block info */
        HDassert(H5F_addr_defined(hdr->man_dtable.table_addr));
        sect->u.single.dblock_addr =  hdr->man_dtable.table_addr;
        sect->u.single.dblock_size =  hdr->man_dtable.cparam.start_block_size;
    } /* end if */
    else {
        /* Look up indirect block containing direct blocks for range */
        if(H5HF_man_locate_block(hdr, dxpl_id, sect->sect_info.addr, FALSE, &sec_iblock, &sec_entry, H5AC_READ) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section")

        /* Increment reference count on indirect block that free section is in */
        if(H5HF_iblock_incr(sec_iblock) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")

        /* Set the information for the section */
        sect->u.single.parent = sec_iblock;
        sect->u.single.par_entry = sec_entry;

        /* Set direct block info */
        sect->u.single.dblock_addr =  sec_iblock->ents[sec_entry].addr;
        sect->u.single.dblock_size =  hdr->man_dtable.row_block_size[sec_entry / hdr->man_dtable.cparam.width];

        /* Unlock indirect block */
        if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, sec_iblock->addr, sec_iblock, H5AC__NO_FLAGS_SET) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
        sec_iblock = NULL;
    } /* end else */

    /* Section is "live" now */
    sect->sect_info.state = H5FS_SECT_LIVE;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_single_revive() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_reduce
 *
 * Purpose:	Reduce the size of a single section (possibly freeing it)
 *              and re-add it back to the free space manager for the heap
 *              (if it hasn't been freed)
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 31 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_single_reduce(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect, size_t amt)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_reduce)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_SINGLE);
    HDassert(sect->sect_info.state == H5FS_SECT_LIVE);

    /* Check for eliminating the section */
    if(sect->sect_info.size == amt) {
        /* Free single section */
        if(H5HF_sect_single_free((H5FS_section_info_t *)sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free single section node")
    } /* end if */
    else {
        /* Adjust information for section */
        sect->sect_info.addr += amt;
        sect->sect_info.size -= amt;

        /* Re-insert section node into heap's free space */
        if(H5HF_space_add(hdr, dxpl_id, sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add single section to free space manager")
    } /* end else */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_single_reduce() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_deserialize
 *
 * Purpose:	Deserialize a buffer into a "live" single section
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static H5FS_section_info_t *
H5HF_sect_single_deserialize(const uint8_t *buf, haddr_t sect_addr,
    hsize_t sect_size)
{
    H5HF_free_section_t *new_sect;      /* New section */
    H5FS_section_info_t *ret_value;     /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_deserialize)

    /* Check arguments. */
    HDassert(buf);
    HDassert(H5F_addr_defined(sect_addr));
    HDassert(sect_size);

    /* Create free list section node */
    if(NULL == (new_sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_SINGLE, sect_addr, sect_size, H5FS_SECT_SERIALIZED)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "allocation failed for direct block free list section")

    /* Set return value */
    ret_value = (H5FS_section_info_t *)new_sect;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_single_deserialize() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_can_merge
 *
 * Purpose:	Can two sections of this type merge?
 *
 * Note:        Second section must be "after" first section
 *
 * Return:	Success:	non-negative (TRUE/FALSE)
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, May 17, 2006
 *
 *-------------------------------------------------------------------------
 */
static htri_t
H5HF_sect_single_can_merge(H5FS_section_info_t *_sect1,
    H5FS_section_info_t *_sect2, void *_udata)
{
    H5HF_free_section_t *sect1 = (H5HF_free_section_t *)_sect1;   /* Fractal heap free section */
    H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2;   /* Fractal heap free section */
    H5HF_add_ud1_t *udata = (H5HF_add_ud1_t *)_udata;   /* User callback data */
    H5HF_hdr_t *hdr = udata->hdr;       /* Fractal heap header */
    size_t dblock_size;                 /* Section's direct block's size */
    size_t dblock_overhead;             /* Direct block's overhead */
    hid_t dxpl_id = udata->dxpl_id;     /* DXPL ID for operation */
    htri_t ret_value = FALSE;           /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_can_merge)

    /* Check arguments. */
    HDassert(sect1);
    HDassert(sect2);
    HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr));

#ifdef QAK
HDfprintf(stderr, "%s: sect1->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect1->sect_info.addr, sect1->sect_info.size, sect1->sect_info.type, (sect1->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: sect2->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect2->sect_info.addr, sect2->sect_info.size, sect2->sect_info.type, (sect2->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
#endif /* QAK */

    /* Check to see if we should revive either section */
    if(sect1->sect_info.state != H5FS_SECT_LIVE)
        if(H5HF_sect_single_revive(hdr, dxpl_id, sect1) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section")
    if(sect2->sect_info.state != H5FS_SECT_LIVE)
        if(H5HF_sect_revive(hdr, dxpl_id, sect2) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive free section")

    /* Check for section occupying entire direct block */
    dblock_size = sect1->u.single.dblock_size;
    dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr);
#ifdef QAK
HDfprintf(stderr, "%s: dblock_size = %u\n", FUNC, dblock_size);
#endif /* QAK */
    if((dblock_size - dblock_overhead) == sect1->sect_info.size) {
        H5HF_direct_t *dblock;          /* Pointer to direct block for section */
        haddr_t dblock_addr;            /* Section's direct block's address */

        /* Protect the direct block for the section */
        dblock_addr = sect1->u.single.dblock_addr;
#ifdef QAK
HDfprintf(stderr, "%s: dblock_addr = %a\n", FUNC, dblock_addr);
#endif /* QAK */
        if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, sect1->u.single.parent, sect1->u.single.par_entry, H5AC_READ)))
            HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block")
        HDassert(H5F_addr_eq(dblock->block_off + dblock_overhead, sect1->sect_info.addr));

        /* Convert 'single' section into 'range' section */
        if(H5HF_sect_range_from_single(hdr, sect1, dblock) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't convert single section into range section")

#ifdef QAK
HDfprintf(stderr, "%s: sect1->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect1->sect_info.addr, sect1->sect_info.size, sect1->sect_info.type, (sect1->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: sect2->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect2->sect_info.addr, sect2->sect_info.size, sect2->sect_info.type, (sect2->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
#endif /* QAK */

        /* Destroy direct block */
        if(H5HF_man_dblock_destroy(hdr, dxpl_id, dblock, dblock_addr) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block")
        dblock = NULL;

        /* Check if second section is a range section */
        if(sect2->sect_info.type == H5HF_FSPACE_SECT_RANGE) {
            htri_t status;      /* Status from range 'can merge' call */

            /* Check if two sections can merge now */
            /* (i.e. assumes responsibility for passing along 'can merge' callback) */
            if((status = H5HF_sect_range_can_merge((H5FS_section_info_t *)sect1, (H5FS_section_info_t *)sect2, udata)) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTMERGE, FAIL, "can't check for merging sections")
            HGOTO_DONE(status)
        } /* end if */
    } /* end if */

    /* Single section can only merge with other single sections */
    if(sect1->sect_info.type != sect2->sect_info.type)
        HGOTO_DONE(FALSE)

    /* Check if second section adjoins first section */
    /* (This can only occurs within a direct block, due to the direct block
     *  overhead at the beginning of a block)
     */
    if(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr))
        HGOTO_DONE(TRUE)

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_single_can_merge() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_merge
 *
 * Purpose:	Merge two sections of this type
 *
 * Note:        Second section always merges into first node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, May 17, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_single_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2,
    void UNUSED *udata)
{
    H5HF_free_section_t *sect1 = (H5HF_free_section_t *)_sect1;   /* Fractal heap free section */
    H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2;   /* Fractal heap free section */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_merge)

    /* Check arguments. */
    HDassert(sect1);
    HDassert(sect1->sect_info.state == H5FS_SECT_LIVE);
    HDassert(sect2);
    HDassert(sect2->sect_info.state == H5FS_SECT_LIVE);
    HDassert(H5F_addr_eq(sect1->sect_info.addr + sect1->sect_info.size, sect2->sect_info.addr));

#ifdef QAK
HDfprintf(stderr, "%s: sect1->sect_info.size = %Hu, sect1->sect_info.addr = %a\n", FUNC, sect1->sect_info.size, sect1->sect_info.addr);
HDfprintf(stderr, "%s: sect2->sect_info.size = %Hu, sect2->sect_info.addr = %a\n", FUNC, sect2->sect_info.size, sect2->sect_info.addr);
#endif /* QAK */

    /* Add second section's size to first section */
    sect1->sect_info.size += sect2->sect_info.size;

    /* Get rid of second section */
    if(H5HF_sect_single_free((H5FS_section_info_t *)sect2) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node")

    /* Defer checking if 'single' section should be converted into 'range' section
     *  until next pass through the "can merge" callback, to make certain that
     *  removing a direct block in the root indirect block gives neighboring
     *  "range" sections a chance to deserialize.  *ick*  -QAK
     */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_single_merge() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_can_shrink
 *
 * Purpose:	Can this section shrink the container?
 *
 * Note:        This isn't actually shrinking the heap (since that's already
 *              been done) as much as it's cleaning up _after_ the heap
 *              shrink.
 *
 * Return:	Success:	non-negative (TRUE/FALSE)
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, June  5, 2006
 *
 *-------------------------------------------------------------------------
 */
static htri_t
H5HF_sect_single_can_shrink(H5FS_section_info_t *_sect, void *_udata)
{
    H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect;   /* Fractal heap free section */
    H5HF_add_ud1_t *udata = (H5HF_add_ud1_t *)_udata;   /* User callback data */
    H5HF_hdr_t *hdr = udata->hdr;       /* Fractal heap header */
    size_t dblock_size;                 /* Section's direct block's size */
    size_t dblock_overhead;             /* Direct block's overhead */
    hid_t dxpl_id = udata->dxpl_id;     /* DXPL ID for operation */
    htri_t ret_value = FALSE;           /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_can_shrink)

    /* Check arguments. */
    HDassert(sect);
    HDassert(sect->sect_info.state == H5FS_SECT_LIVE);

#ifdef QAK
HDfprintf(stderr, "%s: sect->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect->sect_info.addr, sect->sect_info.size, sect->sect_info.type, (sect->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
#endif /* QAK */

    /* Check to see if we should revive section */
    if(sect->sect_info.state != H5FS_SECT_LIVE)
        if(H5HF_sect_single_revive(hdr, dxpl_id, sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive single free section")

    /* Check for section occupying entire direct block */
    dblock_size = sect->u.single.dblock_size;
    dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr);
#ifdef QAK
HDfprintf(stderr, "%s: dblock_size = %u\n", FUNC, dblock_size);
#endif /* QAK */
    if((dblock_size - dblock_overhead) == sect->sect_info.size) {
        H5HF_direct_t *dblock;          /* Pointer to direct block for section */
        haddr_t dblock_addr;            /* Section's direct block's address */
        htri_t status;                  /* Status from range 'can shrink' call */

        /* Protect the direct block for the section */
        dblock_addr = sect->u.single.dblock_addr;
#ifdef QAK
HDfprintf(stderr, "%s: dblock_addr = %a\n", FUNC, dblock_addr);
#endif /* QAK */
        if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, sect->u.single.parent, sect->u.single.par_entry, H5AC_READ)))
            HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block")
        HDassert(H5F_addr_eq(dblock->block_off + dblock_overhead, sect->sect_info.addr));

        /* Convert 'single' section into 'range' section */
        if(H5HF_sect_range_from_single(hdr, sect, dblock) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't convert single section into range section")

        /* Destroy direct block */
        if(H5HF_man_dblock_destroy(hdr, dxpl_id, dblock, dblock_addr) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block")
        dblock = NULL;

        /* Check if section can shrink container now */
        /* (i.e. assumes responsibility for passing along 'can shrink' callback) */
        if((status = H5HF_sect_range_can_shrink((H5FS_section_info_t *)sect, udata)) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTSHRINK, FAIL, "can't check for shrinking container")
        HGOTO_DONE(status)
    } /* end if */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_single_can_shrink() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_single_free
 *
 * Purpose:	Free a 'single' section node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, May 17, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_single_free(H5FS_section_info_t *_sect)
{
    H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect;   /* Pointer to section to free */
    H5HF_indirect_t *parent = NULL;     /* Parent indirect block for section */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_single_free)

    HDassert(sect);

    /* Check for live reference to an indirect block */
    if(sect->sect_info.state == H5FS_SECT_LIVE) {
        /* Get parent indirect block, if there was one */
        if(sect->u.single.parent)
            parent = sect->u.single.parent;
    } /* end if */

    /* Release the section */
    if(H5HF_sect_node_free(sect, parent) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node")

done:
    FUNC_LEAVE_NOAPI(ret_value)
}   /* H5HF_sect_single_free() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_init_cls
 *
 * Purpose:	Initialize the "range" class structure
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_init_cls(H5FS_section_class_t *cls, const void UNUSED *udata)
{
    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_range_init_cls)

    /* Check arguments. */
    HDassert(cls);

    /* Set the size of all serialized objects of this class of sections */
    cls->serial_size = 2                        /* Row */
        + 2                                     /* Column */
        + 2;                                    /* # of entries */

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5HF_sect_range_init_cls() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_add
 *
 * Purpose:	Add a new 'range' section to the free space manager for this
 *              heap
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 30 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_range_add(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t sect_off,
    hsize_t sect_size, H5HF_indirect_t *iblock,
    unsigned row, unsigned col, unsigned nentries)
{
    H5HF_free_section_t *sect = NULL;   /* 'Range' free space section to add */
    hbool_t iblock_incr = FALSE;        /* Indicate that parent iblock has been incremented */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_add)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(iblock);
    HDassert(sect_size);
    HDassert(nentries);
    HDassert(row < hdr->man_dtable.max_direct_rows);    /* Can't handle ranges on indirect blocks */

    /* Create free space section node */
    if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_RANGE, sect_off, sect_size, H5FS_SECT_LIVE)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for range section")

    /* Set the 'range' specific fields */
    sect->u.range.iblock = iblock;
    if(H5HF_iblock_incr(sect->u.range.iblock) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
    iblock_incr = TRUE;
    sect->u.range.row = row;
    sect->u.range.col = col;
    sect->u.range.num_entries = nentries;

    /* Add new free space to the free space manager for this heap */
    if(H5HF_space_add(hdr, dxpl_id, sect) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add range section to free space manager")

done:
    if(ret_value < 0 && sect) {
        /* Check if we should decrement parent ref. count */
        if(iblock_incr)
            if(H5HF_iblock_decr(sect->u.range.iblock) < 0)
                HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")

        /* Release the section */
        H5FL_FREE(H5HF_free_section_t, sect);
    } /* end if */

    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_range_add() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_revive
 *
 * Purpose:	Update the memory information for a 'range' free section
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May  8 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_range_revive(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect)
{
    H5HF_indirect_t *sec_iblock;        /* Pointer to section indirect block */
    unsigned sec_entry;                 /* Entry within section indirect block */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_revive)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED);

    /* Look up indirect block containing direct blocks for range */
    if(H5HF_man_locate_block(hdr, dxpl_id, sect->sect_info.addr, FALSE, &sec_iblock, &sec_entry, H5AC_READ) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section")

    /* Increment reference count on indirect block that free section is in */
    if(H5HF_iblock_incr(sec_iblock) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")

    /* Set the pointer to the section's indirect block */
    sect->u.range.iblock = sec_iblock;

    /* Unlock indirect block */
    if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, sec_iblock->addr, sec_iblock, H5AC__NO_FLAGS_SET) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
    sec_iblock = NULL;

    /* Section is "live" now */
    sect->sect_info.state = H5FS_SECT_LIVE;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_range_revive() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_reduce
 *
 * Purpose:	Reduce the size of a range section (possibly freeing it)
 *              and re-add it back to the free space manager for the heap
 *              (if it hasn't been freed)
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 31 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_range_reduce(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_reduce)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_RANGE);
    HDassert(sect->sect_info.state == H5FS_SECT_LIVE);

    /* Check for eliminating the section */
    if(sect->u.range.num_entries == 1) {
        /* Free range section */
        if(H5HF_sect_range_free((H5FS_section_info_t *)sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free range section node")
    } /* end if */
    else {
        /* Adjust section information */
        sect->sect_info.addr += hdr->man_dtable.row_block_size[sect->u.range.row];

        /* Adjust range information */
        sect->u.range.col++;
        sect->u.range.num_entries--;

        /* Add section back to free space list */
        if(H5HF_space_add(hdr, dxpl_id, sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add range section to free space manager")
    } /* end else */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_range_reduce() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_from_single
 *
 * Purpose:	Convert a 'single' section into a 'range' section
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 31 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_from_single(H5HF_hdr_t *hdr, H5HF_free_section_t *sect,
    H5HF_direct_t *dblock)
{
    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_range_from_single)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(dblock);
#ifdef QAK
HDfprintf(stderr, "%s: sect.sect_info = {%a, %Hu, %u, %s}\n", "H5HF_sect_range_from_single", sect->sect_info.addr, sect->sect_info.size, sect->sect_info.type, (sect->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: dblock->parent = %p\n", "H5HF_sect_range_from_single", dblock->parent);
HDfprintf(stderr, "%s: hdr->man_dtable.curr_root_rows = %u\n", "H5HF_sect_range_from_single", hdr->man_dtable.curr_root_rows);
#endif /* QAK */

    /* Update information for range block */
    sect->sect_info.addr = dblock->block_off;
    sect->sect_info.type = H5HF_FSPACE_SECT_RANGE;
    sect->u.range.iblock = dblock->parent;
    sect->u.range.row = dblock->par_entry / hdr->man_dtable.cparam.width;
    sect->u.range.col = dblock->par_entry % hdr->man_dtable.cparam.width;
    sect->u.range.num_entries = 1;

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5HF_sect_range_from_single() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_serialize
 *
 * Purpose:	Serialize a "live" range section into a buffer
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_serialize(const H5FS_section_info_t *_sect, uint8_t *buf)
{
    const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect;

    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_range_serialize)

    /* Check arguments. */
    HDassert(buf);
    HDassert(sect);

    /* Range's row */
    UINT16ENCODE(buf, sect->u.range.row);

    /* Range's column */
    UINT16ENCODE(buf, sect->u.range.col);

    /* Range's # of entries */
    UINT16ENCODE(buf, sect->u.range.num_entries);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5HF_sect_range_serialize() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_deserialize
 *
 * Purpose:	Deserialize a buffer into a "live" range section
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static H5FS_section_info_t *
H5HF_sect_range_deserialize(const uint8_t *buf, haddr_t sect_addr,
    hsize_t sect_size)
{
    H5HF_free_section_t *new_sect;      /* New section */
    H5FS_section_info_t *ret_value;     /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_deserialize)

    /* Check arguments. */
    HDassert(buf);
    HDassert(H5F_addr_defined(sect_addr));
    HDassert(sect_size);

    /* Create free list section node */
    if(NULL == (new_sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_RANGE, sect_addr, sect_size, H5FS_SECT_SERIALIZED)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "allocation failed for direct block free list section")

    /* Range's indirect block */
    /* (Section needs to be "revived" before this is correct) */
    new_sect->u.range.iblock = NULL;

    /* Range's row */
    UINT16DECODE(buf, new_sect->u.range.row);

    /* Range's column */
    UINT16DECODE(buf, new_sect->u.range.col);

    /* Range's # of entries */
    UINT16DECODE(buf, new_sect->u.range.num_entries);

    /* Set return value */
    ret_value = (H5FS_section_info_t *)new_sect;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_range_deserialize() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_can_merge
 *
 * Purpose:	Can two sections of this type merge?
 *
 * Note:        Second section must be "after" first section
 *
 * Return:	Success:	non-negative (TRUE/FALSE)
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, June  5, 2006
 *
 *-------------------------------------------------------------------------
 */
static htri_t
H5HF_sect_range_can_merge(H5FS_section_info_t *_sect1,
    H5FS_section_info_t *_sect2, void *_udata)
{
    H5HF_free_section_t *sect1 = (H5HF_free_section_t *)_sect1;   /* Fractal heap free section */
    H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2;   /* Fractal heap free section */
    H5HF_add_ud1_t *udata = (H5HF_add_ud1_t *)_udata;   /* User callback data */
    H5HF_hdr_t *hdr = udata->hdr;       /* Fractal heap header */
    hid_t dxpl_id = udata->dxpl_id;     /* DXPL ID for operation */
    size_t dblock_overhead = H5HF_MAN_ABS_DIRECT_OVERHEAD(hdr); /* Direct block's overhead */
    htri_t ret_value = FALSE;           /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_can_merge)

    /* Check arguments. */
    HDassert(sect1);
    HDassert(sect2);
    HDassert(H5F_addr_lt(sect1->sect_info.addr, sect2->sect_info.addr));

#ifdef QAK
HDfprintf(stderr, "%s: sect1->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect1->sect_info.addr, sect1->sect_info.size, sect1->sect_info.type, (sect1->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: sect2->sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect2->sect_info.addr, sect2->sect_info.size, sect2->sect_info.type, (sect2->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
#endif /* QAK */

    /* Check for special case of delayed conversion of 2nd section from
     *  single -> range section
     */
    if(sect2->sect_info.type == H5HF_FSPACE_SECT_SINGLE) {
        size_t dblock_size;                 /* Section's direct block's size */

        /* Check to see if we should revive the section */
        if(sect2->sect_info.state != H5FS_SECT_LIVE)
            if(H5HF_sect_revive(hdr, dxpl_id, sect2) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't revive free section")

        /* Check for section occupying entire direct block */
        dblock_size = sect2->u.single.dblock_size;
        if((dblock_size - dblock_overhead) == sect2->sect_info.size) {
            H5HF_direct_t *dblock;          /* Pointer to direct block for section */
            haddr_t dblock_addr;            /* Section's direct block's address */

            /* Protect the direct block for the section */
            dblock_addr = sect2->u.single.dblock_addr;
#ifdef QAK
HDfprintf(stderr, "%s: dblock_addr = %a\n", FUNC, dblock_addr);
#endif /* QAK */
            if(NULL == (dblock = H5HF_man_dblock_protect(hdr, dxpl_id, dblock_addr, dblock_size, sect2->u.single.parent, sect2->u.single.par_entry, H5AC_READ)))
                HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load fractal heap direct block")
            HDassert(H5F_addr_eq(dblock->block_off + dblock_overhead, sect2->sect_info.addr));

            /* Convert 'single' section into 'range' section */
            if(H5HF_sect_range_from_single(hdr, sect2, dblock) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTCONVERT, FAIL, "can't convert single section into range section")

            /* Destroy direct block */
            if(H5HF_man_dblock_destroy(hdr, dxpl_id, dblock, dblock_addr) < 0)
                HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't release direct block")
            dblock = NULL;
#ifdef QAK
HDfprintf(stderr, "%s: hdr->man_iter_off = %Hu\n", FUNC, hdr->man_iter_off);
#endif /* QAK */
        } /* end if */
    } /* end if */

#ifdef QAK
HDfprintf(stderr, "%s: sect1.u.range = {%p, %u, %u, %u}\n", FUNC, sect1->u.range.iblock, sect1->u.range.row, sect1->u.range.col, sect1->u.range.num_entries);
HDfprintf(stderr, "%s: sect2.u.range = {%p, %u, %u, %u}\n", FUNC, sect2->u.range.iblock, sect2->u.range.row, sect2->u.range.col, sect2->u.range.num_entries);
#endif /* QAK */

    /* Range section can only merge with other range sections */
    if(sect1->sect_info.type != sect2->sect_info.type)
        HGOTO_DONE(FALSE)

#ifdef QAK
HDfprintf(stderr, "%s: hdr->man_iter_off = %Hu\n", FUNC, hdr->man_iter_off);
#endif /* QAK */
    if(sect2->sect_info.addr >= hdr->man_iter_off)
        HGOTO_DONE(TRUE)

    /* Check if second section adjoins first section & is in the same row */
    if(H5F_addr_eq(sect1->sect_info.addr + (sect1->u.range.num_entries * (sect1->sect_info.size + dblock_overhead)), sect2->sect_info.addr) &&
            sect1->u.range.row == sect2->u.range.row)
        HGOTO_DONE(TRUE)

done:
#ifdef QAK
HDfprintf(stderr, "%s: ret_value = %t\n", FUNC, ret_value);
#endif /* QAK */
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_range_can_merge() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_merge
 *
 * Purpose:	Merge two sections of this type
 *
 * Note:        Second section always merges into first node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, June  5, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_merge(H5FS_section_info_t *_sect1, H5FS_section_info_t *_sect2,
    void *_udata)
{
    H5HF_free_section_t *sect1 = (H5HF_free_section_t *)_sect1;   /* Fractal heap free section */
    H5HF_free_section_t *sect2 = (H5HF_free_section_t *)_sect2;   /* Fractal heap free section */
    H5HF_add_ud1_t *udata = (H5HF_add_ud1_t *)_udata;   /* User callback data */
    H5HF_hdr_t *hdr = udata->hdr;       /* Fractal heap header */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_merge)

    /* Check arguments. */
    HDassert(sect1);
    HDassert(sect1->sect_info.type == H5HF_FSPACE_SECT_RANGE);
    HDassert(sect2);
    HDassert(sect2->sect_info.type == H5HF_FSPACE_SECT_RANGE);

#ifdef QAK
HDfprintf(stderr, "%s: sect1.sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect1->sect_info.addr, sect1->sect_info.size, sect1->sect_info.type, (sect1->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: sect1.u.range = {%p, %u, %u, %u}\n", FUNC, sect1->u.range.iblock, sect1->u.range.row, sect1->u.range.col, sect1->u.range.num_entries);
HDfprintf(stderr, "%s: sect2.sect_info = {%a, %Hu, %u, %s}\n", FUNC, sect2->sect_info.addr, sect2->sect_info.size, sect2->sect_info.type, (sect2->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: sect2.u.range = {%p, %u, %u, %u}\n", FUNC, sect2->u.range.iblock, sect2->u.range.row, sect2->u.range.col, sect2->u.range.num_entries);
#endif /* QAK */

    /* Add second section's size to first section, if it's in the same row */
    if(sect1->u.range.row == sect2->u.range.row)
        sect1->u.range.num_entries += sect2->u.range.num_entries;

    /* Get rid of second section */
    if(H5HF_sect_range_free((H5FS_section_info_t *)sect2) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node")

    /* Check if 'range' section should be converted into 'indirect' section (?) */
    if(sect1->u.range.num_entries == hdr->man_dtable.cparam.width &&
            sect1->u.range.row >= hdr->man_dtable.max_direct_rows) {
HDfprintf(stderr, "%s: converting range section to indirect section not supported yet!\n", FUNC);
HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "converting range section to indirect section not supported yet")
    } /* end if */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_range_merge() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_can_shrink
 *
 * Purpose:	Can this section shrink the container?
 *
 * Note:        This isn't actually shrinking the heap (since that's already
 *              been done) as much as it's cleaning up _after_ the heap
 *              shrink.
 *
 * Return:	Success:	non-negative (TRUE/FALSE)
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, June  5, 2006
 *
 *-------------------------------------------------------------------------
 */
static htri_t
H5HF_sect_range_can_shrink(H5FS_section_info_t *_sect, void UNUSED *_udata)
{
    const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect;   /* Fractal heap free section */
    H5HF_add_ud1_t *udata = (H5HF_add_ud1_t *)_udata;   /* User callback data */
    H5HF_hdr_t *hdr = udata->hdr;       /* Fractal heap header */
    htri_t ret_value = FALSE;           /* Return value */

    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_range_can_shrink)

    /* Check arguments. */
    HDassert(sect);
    HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_RANGE);

#ifdef QAK
HDfprintf(stderr, "%s: sect->sect_info = {%a, %Hu, %u, %s}\n", "H5HF_sect_range_can_shrink", sect->sect_info.addr, sect->sect_info.size, sect->sect_info.type, (sect->sect_info.state == H5FS_SECT_LIVE ? "H5FS_SECT_LIVE" : "H5FS_SECT_SERIALIZED"));
HDfprintf(stderr, "%s: sect->u.range = {%p, %u, %u, %u}\n", "H5HF_sect_range_can_shrink", sect->u.range.iblock, sect->u.range.row, sect->u.range.col, sect->u.range.num_entries);
#endif /* QAK */

    /* Check if section is past end of "next block" iterator */
#ifdef QAK
HDfprintf(stderr, "%s: hdr->man_iter_off = %Hu\n", "H5HF_sect_range_can_shrink", hdr->man_iter_off);
#endif /* QAK */
    if(sect->sect_info.addr >= hdr->man_iter_off)
        HGOTO_DONE(TRUE)

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_range_can_shrink() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_shrink
 *
 * Purpose:	Shrink container with section
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, June  5, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_shrink(H5FS_section_info_t **_sect, void UNUSED *_udata)
{
    H5HF_free_section_t **sect = (H5HF_free_section_t **)_sect;   /* Fractal heap free section */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_shrink)

    /* Check arguments. */
    HDassert(sect);
    HDassert(*sect);
    HDassert((*sect)->sect_info.type == H5HF_FSPACE_SECT_RANGE);

#ifdef QAK
HDfprintf(stderr, "%s: (*sect).sect_info = {%a, %Hu, %u}\n", FUNC, (*sect)->sect_info.addr, (*sect)->sect_info.size, (*sect)->sect_info.type);
HDfprintf(stderr, "%s: (*sect).u.range = {%p, %u, %u, %u}\n", FUNC, (*sect)->u.range.iblock, (*sect)->u.range.row, (*sect)->u.range.col, (*sect)->u.range.num_entries);
#endif /* QAK */

    /* Get rid of section */
    if(H5HF_sect_range_free((H5FS_section_info_t *)*sect) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node")

    /* Indicate that the section has been released */
    *sect = NULL;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_range_shrink() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_free
 *
 * Purpose:	Free a 'range' section node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, May 17, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_free(H5FS_section_info_t *_sect)
{
    H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect;   /* Pointer to section to free */
    H5HF_indirect_t *parent = NULL;     /* Parent indirect block for section */
    herr_t ret_value = SUCCEED;               /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_range_free)

    HDassert(sect);

    /* Check for live reference to an indirect block */
    if(sect->sect_info.state == H5FS_SECT_LIVE) {
        /* Get parent indirect block, if there was one */
        if(sect->u.range.iblock)
            parent = sect->u.range.iblock;
    } /* end if */

    /* Release the section */
    if(H5HF_sect_node_free(sect, parent) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node")

done:
    FUNC_LEAVE_NOAPI(ret_value)
}   /* H5HF_sect_range_free() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_range_debug
 *
 * Purpose:	Dump debugging information about an range free space section
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Saturday, May 13, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_range_debug(const H5FS_section_info_t *_sect,
    FILE *stream, int indent, int fwidth)
{
    const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect;       /* Section to dump info */

    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_range_debug)

    /* Check arguments. */
    HDassert(sect);

    /* Print range section information */
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Row:",
	      sect->u.range.row);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Column:",
	      sect->u.range.col);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Number of entries:",
	      sect->u.range.num_entries);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5HF_sect_range_debug() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_init_cls
 *
 * Purpose:	Initialize the "indirect" class structure
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_indirect_init_cls(H5FS_section_class_t *cls, const void UNUSED *udata)
{
    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_indirect_init_cls)

    /* Check arguments. */
    HDassert(cls);

    /* Set the size of all serialized objects of this class of sections */
    cls->serial_size = 2                        /* Row */
        + 2                                     /* Column */
        + 2                                     /* # of entries */
        + 2                                     /* Indirect row */
        + 2;                                    /* Indirect # of rows */

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5HF_sect_indirect_init_cls() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_add
 *
 * Purpose:	Add a new 'indirect' section to the free space manager for this
 *              heap
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 30 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_indirect_add(H5HF_hdr_t *hdr, hid_t dxpl_id,
    hsize_t sect_off, hsize_t sect_size, H5HF_indirect_t *iblock,
    unsigned row, unsigned col, unsigned nentries,
    unsigned indir_row, unsigned indir_nrows)
{
    H5HF_free_section_t *sect = NULL;   /* 'Indirect' free space section to add */
    hbool_t iblock_incr = FALSE;        /* Indicate that parent iblock has been incremented */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_indirect_add)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(iblock);
    HDassert(sect_size);
    HDassert(nentries);

    /* Create free space section node */
    if(NULL == (sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_INDIRECT, sect_off, sect_size, H5FS_SECT_LIVE)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for indirect section")

    /* Set the 'indirect' specific fields */
    sect->u.indirect.iblock = iblock;
    if(H5HF_iblock_incr(sect->u.indirect.iblock) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTINC, FAIL, "can't increment reference count on shared indirect block")
    iblock_incr = TRUE;
    sect->u.indirect.row = row;
    sect->u.indirect.col = col;
    sect->u.indirect.num_entries = nentries;
    sect->u.indirect.indir_row = indir_row;
    sect->u.indirect.indir_nrows = indir_nrows;

    /* Add new free space to the free space manager for the heap */
    if(H5HF_space_add(hdr, dxpl_id, sect) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't add indirect section to free space")

done:
    if(ret_value < 0 && sect) {
        /* Check if we should decrement parent ref. count */
        if(iblock_incr)
            if(H5HF_iblock_decr(sect->u.indirect.iblock) < 0)
                HDONE_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")

        /* Release the section */
        H5FL_FREE(H5HF_free_section_t, sect);
    } /* end if */

    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_indirect_add() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_revive
 *
 * Purpose:	Update the memory information for a 'indirect' free section
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May  8 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_indirect_revive(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect)
{
    H5HF_indirect_t *sec_iblock;        /* Pointer to section indirect block */
    unsigned sec_entry;                 /* Entry within section indirect block */
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_indirect_revive)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(sect->sect_info.state == H5FS_SECT_SERIALIZED);

    /* Look up indirect block containing indirect blocks for section */
    if(H5HF_man_locate_block(hdr, dxpl_id, sect->sect_info.addr, TRUE, &sec_iblock, &sec_entry, H5AC_READ) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPUTE, FAIL, "can't compute row & column of section")

    /* Increment reference count on indirect block that free section is in */
    if(H5HF_iblock_incr(sec_iblock) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't decrement reference count on shared indirect block")

    /* Set the pointer to the section's indirect block */
    sect->u.indirect.iblock = sec_iblock;

    /* Unlock indirect block */
    if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_FHEAP_IBLOCK, sec_iblock->addr, sec_iblock, H5AC__NO_FLAGS_SET) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release fractal heap indirect block")
    sec_iblock = NULL;

    /* Section is "live" now */
    sect->sect_info.state = H5FS_SECT_LIVE;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_indirect_revive() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_reduce
 *
 * Purpose:	Reduce the size of a indirect section (possibly freeing it)
 *              and re-add it back to the free space manager for the heap
 *              (if it hasn't been freed)
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Quincey Koziol
 *		koziol@ncsa.uiuc.edu
 *		May 31 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5HF_sect_indirect_reduce(H5HF_hdr_t *hdr, hid_t dxpl_id,
    H5HF_free_section_t *sect)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_indirect_reduce)

    /*
     * Check arguments.
     */
    HDassert(hdr);
    HDassert(sect);
    HDassert(sect->sect_info.type == H5HF_FSPACE_SECT_INDIRECT);
    HDassert(sect->sect_info.state == H5FS_SECT_LIVE);

    /* Check for eliminating the section */
    if(sect->u.indirect.num_entries == 1) {
        /* Free indirect section */
        if(H5HF_sect_indirect_free((H5FS_section_info_t *)sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free indirect section node")
    } /* end if */
    else {
        /* Adjust section information */
        sect->sect_info.addr += hdr->man_dtable.row_block_size[sect->u.indirect.row];

        /* Adjust range information */
        sect->u.indirect.col++;
        sect->u.indirect.num_entries--;

        /* Add 'indirect' section back to free space list */
        if(H5HF_space_add(hdr, dxpl_id, sect) < 0)
            HGOTO_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL, "can't re-add indirect section to free space manager")
    } /* end else */

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5HF_sect_indirect_reduce() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_serialize
 *
 * Purpose:	Serialize a "live" indirect section into a buffer
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_indirect_serialize(const H5FS_section_info_t *_sect, uint8_t *buf)
{
    const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect;

    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_indirect_serialize)

    /* Check arguments. */
    HDassert(buf);
    HDassert(_sect);

    /* Range's row */
    UINT16ENCODE(buf, sect->u.indirect.row);

    /* Range's column */
    UINT16ENCODE(buf, sect->u.indirect.col);

    /* Range's # of entries */
    UINT16ENCODE(buf, sect->u.indirect.num_entries);

    /* Range's indirect row */
    UINT16ENCODE(buf, sect->u.indirect.indir_row);

    /* Range's indirect # of rows */
    UINT16ENCODE(buf, sect->u.indirect.indir_nrows);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5HF_sect_indirect_serialize() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_deserialize
 *
 * Purpose:	Deserialize a buffer into a "live" indirect section
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Monday, May  1, 2006
 *
 *-------------------------------------------------------------------------
 */
static H5FS_section_info_t *
H5HF_sect_indirect_deserialize(const uint8_t *buf, haddr_t sect_addr,
    hsize_t sect_size)
{
    H5HF_free_section_t *new_sect;      /* New section */
    H5FS_section_info_t *ret_value;     /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_indirect_deserialize)

    /* Check arguments. */
    HDassert(buf);
    HDassert(H5F_addr_defined(sect_addr));
    HDassert(sect_size);

    /* Create free list section node */
    if(NULL == (new_sect = H5HF_sect_node_new(H5HF_FSPACE_SECT_INDIRECT, sect_addr, sect_size, H5FS_SECT_SERIALIZED)))
        HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "allocation failed for direct block free list section")

    /* Range's row */
    UINT16DECODE(buf, new_sect->u.indirect.row);

    /* Range's column */
    UINT16DECODE(buf, new_sect->u.indirect.col);

    /* Range's # of entries */
    UINT16DECODE(buf, new_sect->u.indirect.num_entries);

    /* Range's indirect row */
    UINT16DECODE(buf, new_sect->u.indirect.indir_row);

    /* Range's indirect # of rows */
    UINT16DECODE(buf, new_sect->u.indirect.indir_nrows);

    /* Set return value */
    ret_value = (H5FS_section_info_t *)new_sect;

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5HF_sect_indirect_deserialize() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_free
 *
 * Purpose:	Free a 'indirect' section node
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Wednesday, May 17, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_indirect_free(H5FS_section_info_t *_sect)
{
    H5HF_free_section_t *sect = (H5HF_free_section_t *)_sect;   /* Pointer to section to free */
    H5HF_indirect_t *parent = NULL;     /* Parent indirect block for section */
    herr_t ret_value = SUCCEED;               /* Return value */

    FUNC_ENTER_NOAPI_NOINIT(H5HF_sect_indirect_free)

    HDassert(sect);

    /* Check for live reference to an indirect block */
    if(sect->sect_info.state == H5FS_SECT_LIVE) {
        /* Get parent indirect block, if there was one */
        if(sect->u.indirect.iblock)
            parent = sect->u.indirect.iblock;
    } /* end if */

    /* Release the sections */
    if(H5HF_sect_node_free(sect, parent) < 0)
        HGOTO_ERROR(H5E_HEAP, H5E_CANTRELEASE, FAIL, "can't free section node")

done:
    FUNC_LEAVE_NOAPI(ret_value)
}   /* H5HF_sect_indirect_free() */


/*-------------------------------------------------------------------------
 * Function:	H5HF_sect_indirect_debug
 *
 * Purpose:	Dump debugging information about an indirect free space section
 *
 * Return:	Success:	non-negative
 *
 *		Failure:	negative
 *
 * Programmer:	Quincey Koziol
 *              Saturday, May 13, 2006
 *
 *-------------------------------------------------------------------------
 */
static herr_t
H5HF_sect_indirect_debug(const H5FS_section_info_t *_sect,
    FILE *stream, int indent, int fwidth)
{
    const H5HF_free_section_t *sect = (const H5HF_free_section_t *)_sect;       /* Section to dump info */

    FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5HF_sect_indirect_debug)

    /* Check arguments. */
    HDassert(sect);

    /* Print indirect section information */
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Row:",
	      sect->u.indirect.row);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Column:",
	      sect->u.indirect.col);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Number of entries:",
	      sect->u.indirect.num_entries);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Indirect row:",
	      sect->u.indirect.indir_row);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
	      "Indirect number of rows:",
	      sect->u.indirect.indir_nrows);

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5HF_sect_indirect_debug() */